From ff01cc5dfe8d86fdaf7b8b6bc9f829d8adea1fe9 Mon Sep 17 00:00:00 2001 From: vince-fugnitto Date: Fri, 19 May 2023 11:00:40 -0400 Subject: [PATCH] plugin: cleanup `proposed` api files Signed-off-by: vince-fugnitto --- .../plugin-ext/src/plugin/plugin-context.ts | 4 +- packages/plugin-ext/src/plugin/types-impl.ts | 6 + packages/plugin/src/theia-extra.d.ts | 86 ++ packages/plugin/src/theia-proposed.d.ts | 758 ------------------ packages/plugin/src/theia.d.ts | 16 +- .../src/theia.proposed.customEditorMove.d.ts | 41 + .../src/theia.proposed.diffCommand.d.ts | 55 ++ .../src/theia.proposed.documentPaste.d.ts | 90 +++ ...proposed.editSessionIdentityProvider.d.ts} | 4 +- .../src/theia.proposed.extensionsAny.d.ts | 57 ++ .../src/theia.proposed.externalUriOpener.d.ts | 2 +- .../src/theia.proposed.findTextInFiles.d.ts | 178 ++++ .../plugin/src/theia.proposed.fsChunks.d.ts | 32 + ...theia.proposed.profileContentHandlers.d.ts | 35 + .../plugin/src/theia.proposed.resolvers.d.ts | 44 + .../src/theia.proposed.scmValidation.d.ts | 70 ++ ...eia.proposed.terminalQuickFixProvider.d.ts | 90 +++ .../theia.proposed.textSearchProvider.d.ts | 145 ++++ .../plugin/src/theia.proposed.timeline.d.ts | 177 ++++ .../sample-namespace/plugin-a/extension.js | 2 +- .../sample-namespace/plugin-b/extension.js | 2 +- 21 files changed, 1127 insertions(+), 767 deletions(-) delete mode 100644 packages/plugin/src/theia-proposed.d.ts create mode 100644 packages/plugin/src/theia.proposed.customEditorMove.d.ts create mode 100644 packages/plugin/src/theia.proposed.diffCommand.d.ts create mode 100644 packages/plugin/src/theia.proposed.documentPaste.d.ts rename packages/plugin/src/{vscode.proposed.editSessionIdentityProvider.d.ts => theia.proposed.editSessionIdentityProvider.d.ts} (95%) create mode 100644 packages/plugin/src/theia.proposed.extensionsAny.d.ts create mode 100644 packages/plugin/src/theia.proposed.findTextInFiles.d.ts create mode 100644 packages/plugin/src/theia.proposed.fsChunks.d.ts create mode 100644 packages/plugin/src/theia.proposed.profileContentHandlers.d.ts create mode 100644 packages/plugin/src/theia.proposed.resolvers.d.ts create mode 100644 packages/plugin/src/theia.proposed.scmValidation.d.ts create mode 100644 packages/plugin/src/theia.proposed.terminalQuickFixProvider.d.ts create mode 100644 packages/plugin/src/theia.proposed.textSearchProvider.d.ts create mode 100644 packages/plugin/src/theia.proposed.timeline.d.ts diff --git a/packages/plugin-ext/src/plugin/plugin-context.ts b/packages/plugin-ext/src/plugin/plugin-context.ts index 49e10929e7235..f62f102e83a24 100644 --- a/packages/plugin-ext/src/plugin/plugin-context.ts +++ b/packages/plugin-ext/src/plugin/plugin-context.ts @@ -196,7 +196,8 @@ import { WebviewEditorTabInput, DocumentPasteEdit, ExternalUriOpenerPriority, - EditSessionIdentityMatch + EditSessionIdentityMatch, + TerminalOutputAnchor } from './types-impl'; import { AuthenticationExtImpl } from './authentication-ext'; import { SymbolKind } from '../common/plugin-api-rpc-model'; @@ -1376,6 +1377,7 @@ export function createAPIFactory( TabInputWebview: WebviewEditorTabInput, TabInputTerminal: TerminalEditorTabInput, TerminalLocation, + TerminalOutputAnchor, TerminalExitReason, DocumentPasteEdit, ExternalUriOpenerPriority, diff --git a/packages/plugin-ext/src/plugin/types-impl.ts b/packages/plugin-ext/src/plugin/types-impl.ts index 4983160bbc780..6356bab022356 100644 --- a/packages/plugin-ext/src/plugin/types-impl.ts +++ b/packages/plugin-ext/src/plugin/types-impl.ts @@ -2049,6 +2049,12 @@ export enum TerminalLocation { Panel = 1, Editor = 2 } + +export enum TerminalOutputAnchor { + Top = 0, + Bottom = 1 +} + export class TerminalProfile { /** * Creates a new terminal profile. diff --git a/packages/plugin/src/theia-extra.d.ts b/packages/plugin/src/theia-extra.d.ts index 234d2689667ce..f1826c780dd75 100644 --- a/packages/plugin/src/theia-extra.d.ts +++ b/packages/plugin/src/theia-extra.d.ts @@ -293,5 +293,91 @@ export module '@theia/plugin' { readonly logUri: Uri; } + export namespace commands { + + /** + * Get the keybindings associated to commandId. + * @param commandId The ID of the command for which we are looking for keybindings. + */ + export function getKeyBinding(commandId: string): Thenable; + } + + /** + * Key Binding of a command + */ + export interface CommandKeyBinding { + /** + * Identifier of the command. + */ + id: string; + /** + * Value of the keyBinding + */ + value: string; + } + + /** + * Enumeration of the supported operating systems. + */ + export enum OperatingSystem { + Windows = 'Windows', + Linux = 'Linux', + OSX = 'OSX' + } + + export namespace env { + + /** + * Returns the type of the operating system on the client side (like browser'OS if using browser mode). If it is neither [Windows](isWindows) nor [OS X](isOSX), then + * it always return with the `Linux` OS type. + */ + export function getClientOperatingSystem(): Thenable; + + } + + export interface DecorationData { + letter?: string; + title?: string; + color?: ThemeColor; + priority?: number; + bubble?: boolean; + source?: string; + } + + export interface SourceControl { + + /** + * Whether the source control is selected. + */ + readonly selected: boolean; + + /** + * An event signaling when the selection state changes. + */ + readonly onDidChangeSelection: Event; + } + + export interface SourceControlResourceDecorations { + source?: string; + letter?: string; + color?: ThemeColor; + } + } +/** + * Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise, + * and others. This API makes no assumption about what promise library is being used which + * enables reusing existing code without migrating to a specific promise implementation. Still, + * we recommend the use of native promises which are available in this editor. + */ +interface Thenable { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | Thenable, onrejected?: (reason: any) => TResult | Thenable): Thenable; + then(onfulfilled?: (value: T) => TResult | Thenable, onrejected?: (reason: any) => void): Thenable; +} diff --git a/packages/plugin/src/theia-proposed.d.ts b/packages/plugin/src/theia-proposed.d.ts deleted file mode 100644 index eedb60c36246e..0000000000000 --- a/packages/plugin/src/theia-proposed.d.ts +++ /dev/null @@ -1,758 +0,0 @@ -// ***************************************************************************** -// Copyright (C) 2018 Red Hat, Inc. and others. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License v. 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0. -// -// This Source Code may also be made available under the following Secondary -// Licenses when the conditions for such availability set forth in the Eclipse -// Public License v. 2.0 are satisfied: GNU General Public License, version 2 -// with the GNU Classpath Exception which is available at -// https://www.gnu.org/software/classpath/license.html. -// -// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 -// ***************************************************************************** - -/* eslint-disable @typescript-eslint/no-explicit-any */ - -/** - * This is the place for API experiments and proposals. - * These API are NOT stable and subject to change. Use it on own risk. - */ -export module '@theia/plugin' { - /** - * The contiguous set of modified lines in a diff. - */ - export interface LineChange { - readonly originalStartLineNumber: number; - readonly originalEndLineNumber: number; - readonly modifiedStartLineNumber: number; - readonly modifiedEndLineNumber: number; - } - - export namespace commands { - - /** - * Get the keybindings associated to commandId. - * @param commandId The ID of the command for which we are looking for keybindings. - */ - export function getKeyBinding(commandId: string): Thenable; - - /** - * Registers a diff information command that can be invoked via a keyboard shortcut, - * a menu item, an action, or directly. - * - * Diff information commands are different from ordinary [commands](#commands.registerCommand) as - * they only execute when there is an active diff editor when the command is called, and the diff - * information has been computed. Also, the command handler of an editor command has access to - * the diff information. - * - * @param command A unique identifier for the command. - * @param callback A command handler function with access to the [diff information](#LineChange). - * @param thisArg The `this` context used when invoking the handler function. - * @return Disposable which unregisters this command on disposal. - */ - export function registerDiffInformationCommand(command: string, callback: (diff: LineChange[], ...args: any[]) => any, thisArg?: any): Disposable; - - } - - /** - * Key Binding of a command - */ - export interface CommandKeyBinding { - /** - * Identifier of the command. - */ - id: string; - /** - * Value of the keyBinding - */ - value: string; - } - - /** - * Enumeration of the supported operating systems. - */ - export enum OperatingSystem { - Windows = 'Windows', - Linux = 'Linux', - OSX = 'OSX' - } - - export namespace env { - - /** - * Returns the type of the operating system on the client side (like browser'OS if using browser mode). If it is neither [Windows](isWindows) nor [OS X](isOSX), then - * it always return with the `Linux` OS type. - */ - export function getClientOperatingSystem(): Thenable; - - } - - export interface DecorationData { - letter?: string; - title?: string; - color?: ThemeColor; - priority?: number; - bubble?: boolean; - source?: string; - } - - // #region SCM validation - - /** - * Represents the validation type of the Source Control input. - */ - export enum SourceControlInputBoxValidationType { - - /** - * Something not allowed by the rules of a language or other means. - */ - Error = 0, - - /** - * Something suspicious but allowed. - */ - Warning = 1, - - /** - * Something to inform about but not a problem. - */ - Information = 2 - } - - export interface SourceControlInputBoxValidation { - - /** - * The validation message to display. - */ - readonly message: string; - - /** - * The validation type. - */ - readonly type: SourceControlInputBoxValidationType; - } - - /** - * Represents the input box in the Source Control viewlet. - */ - export interface SourceControlInputBox { - - /** - * A validation function for the input box. It's possible to change - * the validation provider simply by setting this property to a different function. - */ - validateInput?(value: string, cursorPosition: number): ProviderResult; - } - - // #endregion - - export interface SourceControl { - - /** - * Whether the source control is selected. - */ - readonly selected: boolean; - - /** - * An event signaling when the selection state changes. - */ - readonly onDidChangeSelection: Event; - } - - export interface SourceControlResourceDecorations { - source?: string; - letter?: string; - color?: ThemeColor; - } - - // #region search in workspace - /** - * The parameters of a query for text search. - */ - export interface TextSearchQuery { - /** - * The text pattern to search for. - */ - pattern: string; - - /** - * Whether or not `pattern` should match multiple lines of text. - */ - isMultiline?: boolean; - - /** - * Whether or not `pattern` should be interpreted as a regular expression. - */ - isRegExp?: boolean; - - /** - * Whether or not the search should be case-sensitive. - */ - isCaseSensitive?: boolean; - - /** - * Whether or not to search for whole word matches only. - */ - isWordMatch?: boolean; - } - - /** - * Options that can be set on a findTextInFiles search. - */ - export interface FindTextInFilesOptions { - /** - * A [glob pattern](#GlobPattern) that defines the files to search for. The glob pattern - * will be matched against the file paths of files relative to their workspace. Use a [relative pattern](#RelativePattern) - * to restrict the search results to a [workspace folder](#WorkspaceFolder). - */ - include?: GlobPattern; - - /** - * A [glob pattern](#GlobPattern) that defines files and folders to exclude. The glob pattern - * will be matched against the file paths of resulting matches relative to their workspace. When `undefined`, default excludes will - * apply. - */ - exclude?: GlobPattern; - - /** - * Whether to use the default and user-configured excludes. Defaults to true. - */ - useDefaultExcludes?: boolean; - - /** - * The maximum number of results to search for - */ - maxResults?: number; - - /** - * Whether external files that exclude files, like .gitignore, should be respected. - * See the vscode setting `"search.useIgnoreFiles"`. - */ - useIgnoreFiles?: boolean; - - /** - * Whether global files that exclude files, like .gitignore, should be respected. - * See the vscode setting `"search.useGlobalIgnoreFiles"`. - */ - useGlobalIgnoreFiles?: boolean; - - /** - * Whether symlinks should be followed while searching. - * See the vscode setting `"search.followSymlinks"`. - */ - followSymlinks?: boolean; - - /** - * Interpret files using this encoding. - * See the vscode setting `"files.encoding"` - */ - encoding?: string; - - /** - * Options to specify the size of the result text preview. - */ - previewOptions?: TextSearchPreviewOptions; - - /** - * Number of lines of context to include before each match. - */ - beforeContext?: number; - - /** - * Number of lines of context to include after each match. - */ - afterContext?: number; - } - - /** - * A match from a text search - */ - export interface TextSearchMatch { - /** - * The uri for the matching document. - */ - uri: Uri; - - /** - * The range of the match within the document, or multiple ranges for multiple matches. - */ - ranges: Range | Range[]; - - /** - * A preview of the text match. - */ - preview: TextSearchMatchPreview; - } - - /** - * A preview of the text result. - */ - export interface TextSearchMatchPreview { - /** - * The matching lines of text, or a portion of the matching line that contains the match. - */ - text: string; - - /** - * The Range within `text` corresponding to the text of the match. - * The number of matches must match the TextSearchMatch's range property. - */ - matches: Range | Range[]; - } - - /** - * Options to specify the size of the result text preview. - * These options don't affect the size of the match itself, just the amount of preview text. - */ - export interface TextSearchPreviewOptions { - /** - * The maximum number of lines in the preview. - * Only search providers that support multiline search will ever return more than one line in the match. - */ - matchLines: number; - - /** - * The maximum number of characters included per line. - */ - charsPerLine: number; - } - - /** - * A line of context surrounding a TextSearchMatch. - */ - export interface TextSearchContext { - /** - * The uri for the matching document. - */ - uri: Uri; - - /** - * One line of text. - * previewOptions.charsPerLine applies to this - */ - text: string; - - /** - * The line number of this line of context. - */ - lineNumber: number; - } - - export type TextSearchResult = TextSearchMatch | TextSearchContext; - - /** - * Information collected when text search is complete. - */ - export interface TextSearchComplete { - /** - * Whether the search hit the limit on the maximum number of search results. - * `maxResults` on [`TextSearchOptions`](#TextSearchOptions) specifies the max number of results. - * - If exactly that number of matches exist, this should be false. - * - If `maxResults` matches are returned and more exist, this should be true. - * - If search hits an internal limit which is less than `maxResults`, this should be true. - */ - limitHit?: boolean; - } - - export namespace workspace { - /** - * Find text in files across all [workspace folders] in the workspace - * @param query What to search - * @param optionsOrCallback - * @param callbackOrToken - * @param token - */ - export function findTextInFiles(query: TextSearchQuery, optionsOrCallback: FindTextInFilesOptions | ((result: TextSearchResult) => void), - callbackOrToken?: CancellationToken | ((result: TextSearchResult) => void), token?: CancellationToken): Promise; - } - // #endregion - - // #region read/write in chunks: https://github.com/microsoft/vscode/issues/84515 - - export interface FileSystemProvider { - open?(resource: Uri, options: { create: boolean; }): number | Thenable; - close?(fd: number): void | Thenable; - read?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): number | Thenable; - write?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): number | Thenable; - } - - // #endregion - - // #region Custom editor move https://github.com/microsoft/vscode/issues/86146 - // copied from https://github.com/microsoft/vscode/blob/53eac52308c4611000a171cc7bf1214293473c78/src/vs/vscode.proposed.d.ts#L986-L1007 - - // TODO: Also for custom editor - - export interface CustomTextEditorProvider { - - /** - * Handle when the underlying resource for a custom editor is renamed. - * - * This allows the webview for the editor be preserved throughout the rename. If this method is not implemented, - * Theia will destroy the previous custom editor and create a replacement one. - * - * @param newDocument New text document to use for the custom editor. - * @param existingWebviewPanel Webview panel for the custom editor. - * @param token A cancellation token that indicates the result is no longer needed. - * - * @return Thenable indicating that the webview editor has been moved. - */ - moveCustomTextEditor?(newDocument: TextDocument, existingWebviewPanel: WebviewPanel, token: CancellationToken): Thenable; - } - - // #endregion - - export interface ResourceLabelFormatter { - scheme: string; - authority?: string; - formatting: ResourceLabelFormatting; - } - - export interface ResourceLabelFormatting { - label: string; // myLabel:/${path} - // TODO@isi - separator: '/' | '\\' | ''; - tildify?: boolean; - normalizeDriveLetter?: boolean; - workspaceSuffix?: string; - authorityPrefix?: string; - } - - export namespace workspace { - export function registerResourceLabelFormatter(formatter: ResourceLabelFormatter): Disposable; - } - - // #region timeline - // copied from https://github.com/microsoft/vscode/blob/d69a79b73808559a91206d73d7717ff5f798f23c/src/vs/vscode.proposed.d.ts#L1870-L2017 - export class TimelineItem { - /** - * A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred. - */ - timestamp: number; - - /** - * A human-readable string describing the timeline item. - */ - label: string; - - /** - * Optional id for the timeline item. It must be unique across all the timeline items provided by this source. - * - * If not provided, an id is generated using the timeline item's timestamp. - */ - id?: string; - - /** - * The icon path or [ThemeIcon](#ThemeIcon) for the timeline item. - */ - iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon; - - /** - * A human readable string describing less prominent details of the timeline item. - */ - description?: string; - - /** - * The tooltip text when you hover over the timeline item. - */ - detail?: string; - - /** - * The [command](#Command) that should be executed when the timeline item is selected. - */ - command?: Command; - - /** - * Context value of the timeline item. This can be used to contribute specific actions to the item. - * For example, a timeline item is given a context value as `commit`. When contributing actions to `timeline/item/context` - * using `menus` extension point, you can specify context value for key `timelineItem` in `when` expression like `timelineItem == commit`. - * ``` - * "contributes": { - * "menus": { - * "timeline/item/context": [{ - * "command": "extension.copyCommitId", - * "when": "timelineItem == commit" - * }] - * } - * } - * ``` - * This will show the `extension.copyCommitId` action only for items where `contextValue` is `commit`. - */ - contextValue?: string; - - /** - * Accessibility information used when screen reader interacts with this timeline item. - */ - accessibilityInformation?: AccessibilityInformation; - - /** - * @param label A human-readable string describing the timeline item - * @param timestamp A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred - */ - constructor(label: string, timestamp: number); - } - - export interface TimelineChangeEvent { - /** - * The [uri](#Uri) of the resource for which the timeline changed. - */ - uri: Uri; - - /** - * A flag which indicates whether the entire timeline should be reset. - */ - reset?: boolean; - } - - export interface Timeline { - readonly paging?: { - /** - * A provider-defined cursor specifying the starting point of timeline items which are after the ones returned. - * Use `undefined` to signal that there are no more items to be returned. - */ - readonly cursor: string | undefined; - } - - /** - * An array of [timeline items](#TimelineItem). - */ - readonly items: readonly TimelineItem[]; - } - - export interface TimelineOptions { - /** - * A provider-defined cursor specifying the starting point of the timeline items that should be returned. - */ - cursor?: string; - - /** - * An optional maximum number timeline items or the all timeline items newer (inclusive) than the timestamp or id that should be returned. - * If `undefined` all timeline items should be returned. - */ - limit?: number | { timestamp: number; id?: string }; - } - - export interface TimelineProvider { - /** - * An optional event to signal that the timeline for a source has changed. - * To signal that the timeline for all resources (uris) has changed, do not pass any argument or pass `undefined`. - */ - onDidChange?: Event; - - /** - * An identifier of the source of the timeline items. This can be used to filter sources. - */ - readonly id: string; - - /** - * A human-readable string describing the source of the timeline items. This can be used as the display label when filtering sources. - */ - readonly label: string; - - /** - * Provide [timeline items](#TimelineItem) for a [Uri](#Uri). - * - * @param uri The [uri](#Uri) of the file to provide the timeline for. - * @param options A set of options to determine how results should be returned. - * @param token A cancellation token. - * @return The [timeline result](#TimelineResult) or a thenable that resolves to such. The lack of a result - * can be signaled by returning `undefined`, `null`, or an empty array. - */ - provideTimeline(uri: Uri, options: TimelineOptions, token: CancellationToken): ProviderResult; - } - - export namespace workspace { - /** - * Register a timeline provider. - * - * Multiple providers can be registered. In that case, providers are asked in - * parallel and the results are merged. A failing provider (rejected promise or exception) will - * not cause a failure of the whole operation. - * - * @param scheme A scheme or schemes that defines which documents this provider is applicable to. Can be `*` to target all documents. - * @param provider A timeline provider. - * @return A [disposable](#Disposable) that unregisters this provider when being disposed. - */ - export function registerTimelineProvider(scheme: string | string[], provider: TimelineProvider): Disposable; - } - - // Copied from https://github.com/microsoft/vscode/blob/ad4470522ecd858cfaf53a87c2702d7a40946ba1/src/vscode-dts/vscode.proposed.extensionsAny.d.ts - // https://github.com/microsoft/vscode/issues/145307 - - export interface Extension { - - /** - * `true` when the extension is associated to another extension host. - * - * *Note* that an extension from another extension host cannot export - * API, e.g {@link Extension.exports its exports} are always `undefined`. - */ - readonly isFromDifferentExtensionHost: boolean; - } - - export namespace extensions { - - /** - * Get an extension by its full identifier in the form of: `publisher.name`. - * - * @param extensionId An extension identifier. - * @param includeDifferentExtensionHosts Include extensions from different extension host - * @return An extension or `undefined`. - */ - export function getExtension(extensionId: string, includeDifferentExtensionHosts: boolean): Extension | undefined; - - /** - * All extensions across all extension hosts. - * - * @see {@link Extension.isFromDifferentExtensionHost} - */ - export const allAcrossExtensionHosts: readonly Extension[]; - - } - - // #region DocumentPaste - - // https://github.com/microsoft/vscode/issues/30066/ - - /** - * Provider invoked when the user copies and pastes code. - */ - export interface DocumentPasteEditProvider { - - /** - * Optional method invoked after the user copies text in a file. - * - * During {@link prepareDocumentPaste}, an extension can compute metadata that is attached to - * a {@link DataTransfer} and is passed back to the provider in {@link provideDocumentPasteEdits}. - * - * @param document Document where the copy took place. - * @param ranges Ranges being copied in the `document`. - * @param dataTransfer The data transfer associated with the copy. You can store additional values on this for later use in {@link provideDocumentPasteEdits}. - * @param token A cancellation token. - */ - prepareDocumentPaste?(document: TextDocument, ranges: readonly Range[], dataTransfer: DataTransfer, token: CancellationToken): void | Thenable; - - /** - * Invoked before the user pastes into a document. - * - * In this method, extensions can return a workspace edit that replaces the standard pasting behavior. - * - * @param document Document being pasted into - * @param ranges Currently selected ranges in the document. - * @param dataTransfer The data transfer associated with the paste. - * @param token A cancellation token. - * - * @return Optional workspace edit that applies the paste. Return undefined to use standard pasting. - */ - provideDocumentPasteEdits(document: TextDocument, ranges: readonly Range[], dataTransfer: DataTransfer, token: CancellationToken): ProviderResult; - } - - /** - * An operation applied on paste - */ - class DocumentPasteEdit { - /** - * The text or snippet to insert at the pasted locations. - */ - insertText: string | SnippetString; - - /** - * An optional additional edit to apply on paste. - */ - additionalEdit?: WorkspaceEdit; - - /** - * @param insertText The text or snippet to insert at the pasted locations. - */ - constructor(insertText: string | SnippetString); - } - - interface DocumentPasteProviderMetadata { - /** - * Mime types that `provideDocumentPasteEdits` should be invoked for. - * - * Use the special `files` mimetype to indicate the provider should be invoked if any files are present in the `DataTransfer`. - */ - readonly pasteMimeTypes: readonly string[]; - } - - namespace languages { - export function registerDocumentPasteEditProvider(selector: DocumentSelector, provider: DocumentPasteEditProvider, metadata: DocumentPasteProviderMetadata): Disposable; - } - // #endregion - - // #region ProfileContentHandler - - export interface ProfileContentHandler { - readonly name: string; - saveProfile(name: string, content: string, token: CancellationToken): Thenable; - readProfile(uri: Uri, token: CancellationToken): Thenable; - } - - export namespace window { - export function registerProfileContentHandler(id: string, profileContentHandler: ProfileContentHandler): Disposable; - } - - // #endregion ProfileContentHandler - - // #region TerminalQuickFixProvider - - export namespace window { - /** - * @param provider A terminal quick fix provider - * @return A {@link Disposable} that un-registers the provider when being disposed - */ - export function registerTerminalQuickFixProvider(id: string, provider: TerminalQuickFixProvider): Disposable; - } - - export interface TerminalQuickFixProvider { - /** - * Provides terminal quick fixes - * @param commandMatchResult The command match result for which to provide quick fixes - * @param token A cancellation token indicating the result is no longer needed - * @return Terminal quick fix(es) if any - */ - provideTerminalQuickFixes(commandMatchResult: TerminalCommandMatchResult, token: CancellationToken): TerminalQuickFix[] | TerminalQuickFix | undefined; - } - - export interface TerminalCommandMatchResult { - commandLine: string; - commandLineMatch: RegExpMatchArray; - outputMatch?: { - regexMatch: RegExpMatchArray; - outputLines?: string[]; - }; - } - - interface TerminalQuickFix { - type: TerminalQuickFixType; - } - - enum TerminalQuickFixType { - command = 'command', - opener = 'opener' - } - - // #endRegion TerminalQuickFixProvider -} - -/** - * Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise, - * and others. This API makes no assumption about what promise library is being used which - * enables reusing existing code without migrating to a specific promise implementation. Still, - * we recommend the use of native promises which are available in this editor. - */ -interface Thenable { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: (value: T) => TResult | Thenable, onrejected?: (reason: any) => TResult | Thenable): Thenable; - then(onfulfilled?: (value: T) => TResult | Thenable, onrejected?: (reason: any) => void): Thenable; -} - diff --git a/packages/plugin/src/theia.d.ts b/packages/plugin/src/theia.d.ts index f7461bcb45b44..13cee3a27044f 100644 --- a/packages/plugin/src/theia.d.ts +++ b/packages/plugin/src/theia.d.ts @@ -20,10 +20,22 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ + import './theia-extra'; -import './theia-proposed'; +import './theia.proposed.customEditorMove'; +import './theia.proposed.diffCommand'; +import './theia.proposed.documentPaste'; +import './theia.proposed.editSessionIdentityProvider'; +import './theia.proposed.extensionsAny'; import './theia.proposed.externalUriOpener'; -import './vscode.proposed.editSessionIdentityProvider'; +import './theia.proposed.findTextInFiles'; +import './theia.proposed.fsChunks'; +import './theia.proposed.profileContentHandlers'; +import './theia.proposed.resolvers'; +import './theia.proposed.scmValidation'; +import './theia.proposed.terminalQuickFixProvider'; +import './theia.proposed.textSearchProvider'; +import './theia.proposed.timeline'; /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable max-len */ diff --git a/packages/plugin/src/theia.proposed.customEditorMove.d.ts b/packages/plugin/src/theia.proposed.customEditorMove.d.ts new file mode 100644 index 0000000000000..0736bbe320009 --- /dev/null +++ b/packages/plugin/src/theia.proposed.customEditorMove.d.ts @@ -0,0 +1,41 @@ +// ***************************************************************************** +// Copyright (C) 2023 Ericsson and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 +// ***************************************************************************** + +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.customEditorMove.d.ts + +export module '@theia/plugin' { + + export interface CustomTextEditorProvider { + + /** + * Handle when the underlying resource for a custom editor is renamed. + * + * This allows the webview for the editor be preserved throughout the rename. If this method is not implemented, + * the editor will destroy the previous custom editor and create a replacement one. + * + * @param newDocument New text document to use for the custom editor. + * @param existingWebviewPanel Webview panel for the custom editor. + * @param token A cancellation token that indicates the result is no longer needed. + * + * @return Thenable indicating that the webview editor has been moved. + */ + moveCustomTextEditor?(newDocument: TextDocument, existingWebviewPanel: WebviewPanel, token: CancellationToken): Thenable; + } +} diff --git a/packages/plugin/src/theia.proposed.diffCommand.d.ts b/packages/plugin/src/theia.proposed.diffCommand.d.ts new file mode 100644 index 0000000000000..38fe99b9fe5d8 --- /dev/null +++ b/packages/plugin/src/theia.proposed.diffCommand.d.ts @@ -0,0 +1,55 @@ +// ***************************************************************************** +// Copyright (C) 2023 Ericsson and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 +// ***************************************************************************** + +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.diffCommand.d.ts + +export module '@theia/plugin' { + + /** + * The contiguous set of modified lines in a diff. + */ + export interface LineChange { + readonly originalStartLineNumber: number; + readonly originalEndLineNumber: number; + readonly modifiedStartLineNumber: number; + readonly modifiedEndLineNumber: number; + } + + export namespace commands { + + /** + * Registers a diff information command that can be invoked via a keyboard shortcut, + * a menu item, an action, or directly. + * + * Diff information commands are different from ordinary {@link commands.registerCommand commands} as + * they only execute when there is an active diff editor when the command is called, and the diff + * information has been computed. Also, the command handler of an editor command has access to + * the diff information. + * + * @param command A unique identifier for the command. + * @param callback A command handler function with access to the {@link LineChange diff information}. + * @param thisArg The `this` context used when invoking the handler function. + * @return Disposable which unregisters this command on disposal. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + export function registerDiffInformationCommand(command: string, callback: (diff: LineChange[], ...args: any[]) => any, thisArg?: any): Disposable; + } + +} diff --git a/packages/plugin/src/theia.proposed.documentPaste.d.ts b/packages/plugin/src/theia.proposed.documentPaste.d.ts new file mode 100644 index 0000000000000..5060cedd74587 --- /dev/null +++ b/packages/plugin/src/theia.proposed.documentPaste.d.ts @@ -0,0 +1,90 @@ +// ***************************************************************************** +// Copyright (C) 2023 Ericsson and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 +// ***************************************************************************** + +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.documentPaste.d.ts + +export module '@theia/plugin' { + + /** + * Provider invoked when the user copies and pastes code. + */ + export interface DocumentPasteEditProvider { + + /** + * Optional method invoked after the user copies text in a file. + * + * During {@link prepareDocumentPaste}, an extension can compute metadata that is attached to + * a {@link DataTransfer} and is passed back to the provider in {@link provideDocumentPasteEdits}. + * + * @param document Document where the copy took place. + * @param ranges Ranges being copied in the `document`. + * @param dataTransfer The data transfer associated with the copy. You can store additional values on this for later use in {@link provideDocumentPasteEdits}. + * @param token A cancellation token. + */ + prepareDocumentPaste?(document: TextDocument, ranges: readonly Range[], dataTransfer: DataTransfer, token: CancellationToken): void | Thenable; + + /** + * Invoked before the user pastes into a document. + * + * In this method, extensions can return a workspace edit that replaces the standard pasting behavior. + * + * @param document Document being pasted into + * @param ranges Currently selected ranges in the document. + * @param dataTransfer The data transfer associated with the paste. + * @param token A cancellation token. + * + * @return Optional workspace edit that applies the paste. Return undefined to use standard pasting. + */ + provideDocumentPasteEdits(document: TextDocument, ranges: readonly Range[], dataTransfer: DataTransfer, token: CancellationToken): ProviderResult; + } + + /** + * An operation applied on paste + */ + class DocumentPasteEdit { + /** + * The text or snippet to insert at the pasted locations. + */ + insertText: string | SnippetString; + + /** + * An optional additional edit to apply on paste. + */ + additionalEdit?: WorkspaceEdit; + + /** + * @param insertText The text or snippet to insert at the pasted locations. + */ + constructor(insertText: string | SnippetString); + } + + interface DocumentPasteProviderMetadata { + /** + * Mime types that `provideDocumentPasteEdits` should be invoked for. + * + * Use the special `files` mimetype to indicate the provider should be invoked if any files are present in the `DataTransfer`. + */ + readonly pasteMimeTypes: readonly string[]; + } + + namespace languages { + export function registerDocumentPasteEditProvider(selector: DocumentSelector, provider: DocumentPasteEditProvider, metadata: DocumentPasteProviderMetadata): Disposable; + } +} diff --git a/packages/plugin/src/vscode.proposed.editSessionIdentityProvider.d.ts b/packages/plugin/src/theia.proposed.editSessionIdentityProvider.d.ts similarity index 95% rename from packages/plugin/src/vscode.proposed.editSessionIdentityProvider.d.ts rename to packages/plugin/src/theia.proposed.editSessionIdentityProvider.d.ts index d0e8a8aa6a51d..bb7c0a63cf087 100644 --- a/packages/plugin/src/vscode.proposed.editSessionIdentityProvider.d.ts +++ b/packages/plugin/src/theia.proposed.editSessionIdentityProvider.d.ts @@ -14,13 +14,11 @@ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** -// Copied from: https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.editSessionIdentityProvider.d.ts -// and slightly adapted to work in Theia - /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.editSessionIdentityProvider.d.ts export module '@theia/plugin' { diff --git a/packages/plugin/src/theia.proposed.extensionsAny.d.ts b/packages/plugin/src/theia.proposed.extensionsAny.d.ts new file mode 100644 index 0000000000000..7d05daae7341e --- /dev/null +++ b/packages/plugin/src/theia.proposed.extensionsAny.d.ts @@ -0,0 +1,57 @@ +// ***************************************************************************** +// Copyright (C) 2023 Ericsson and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 +// ***************************************************************************** + +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.extensionsAny.d.ts + +export module '@theia/plugin' { + + export interface Extension { + + /** + * `true` when the extension is associated to another extension host. + * + * *Note* that an extension from another extension host cannot export + * API, e.g {@link Extension.exports its exports} are always `undefined`. + */ + readonly isFromDifferentExtensionHost: boolean; + } + + export namespace extensions { + + /** + * Get an extension by its full identifier in the form of: `publisher.name`. + * + * @param extensionId An extension identifier. + * @param includeDifferentExtensionHosts Include extensions from different extension host + * @return An extension or `undefined`. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + export function getExtension(extensionId: string, includeDifferentExtensionHosts: boolean): Extension | undefined; + + /** + * All extensions across all extension hosts. + * + * @see {@link Extension.isFromDifferentExtensionHost} + */ + export const allAcrossExtensionHosts: readonly Extension[]; + + } + +} diff --git a/packages/plugin/src/theia.proposed.externalUriOpener.d.ts b/packages/plugin/src/theia.proposed.externalUriOpener.d.ts index c0d42d5f0ffd1..9fedd051c6797 100644 --- a/packages/plugin/src/theia.proposed.externalUriOpener.d.ts +++ b/packages/plugin/src/theia.proposed.externalUriOpener.d.ts @@ -18,7 +18,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -// code copied and modified from https://vscode.dev/github/microsoft/vscode/blob/1.77.3/src/vscode-dts/vscode.proposed.externalUriOpener.d.ts +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.externalUriOpener.d.ts export module '@theia/plugin' { /** diff --git a/packages/plugin/src/theia.proposed.findTextInFiles.d.ts b/packages/plugin/src/theia.proposed.findTextInFiles.d.ts new file mode 100644 index 0000000000000..57b671e5cda40 --- /dev/null +++ b/packages/plugin/src/theia.proposed.findTextInFiles.d.ts @@ -0,0 +1,178 @@ +// ***************************************************************************** +// Copyright (C) 2023 Ericsson and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 +// ***************************************************************************** + +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.findTextInFiles.d.ts + +export module '@theia/plugin' { + + /** + * Options that can be set on a findTextInFiles search. + */ + export interface FindTextInFilesOptions { + /** + * A [glob pattern](#GlobPattern) that defines the files to search for. The glob pattern + * will be matched against the file paths of files relative to their workspace. Use a [relative pattern](#RelativePattern) + * to restrict the search results to a [workspace folder](#WorkspaceFolder). + */ + include?: GlobPattern; + + /** + * A [glob pattern](#GlobPattern) that defines files and folders to exclude. The glob pattern + * will be matched against the file paths of resulting matches relative to their workspace. When `undefined`, default excludes will + * apply. + */ + exclude?: GlobPattern; + + /** + * Whether to use the default and user-configured excludes. Defaults to true. + */ + useDefaultExcludes?: boolean; + + /** + * The maximum number of results to search for + */ + maxResults?: number; + + /** + * Whether external files that exclude files, like .gitignore, should be respected. + * See the vscode setting `"search.useIgnoreFiles"`. + */ + useIgnoreFiles?: boolean; + + /** + * Whether global files that exclude files, like .gitignore, should be respected. + * See the vscode setting `"search.useGlobalIgnoreFiles"`. + */ + useGlobalIgnoreFiles?: boolean; + + /** + * Whether symlinks should be followed while searching. + * See the vscode setting `"search.followSymlinks"`. + */ + followSymlinks?: boolean; + + /** + * Interpret files using this encoding. + * See the vscode setting `"files.encoding"` + */ + encoding?: string; + + /** + * Options to specify the size of the result text preview. + */ + previewOptions?: TextSearchPreviewOptions; + + /** + * Number of lines of context to include before each match. + */ + beforeContext?: number; + + /** + * Number of lines of context to include after each match. + */ + afterContext?: number; + } + + /** + * A match from a text search + */ + export interface TextSearchMatch { + /** + * The uri for the matching document. + */ + uri: Uri; + + /** + * The range of the match within the document, or multiple ranges for multiple matches. + */ + ranges: Range | Range[]; + + /** + * A preview of the text match. + */ + preview: TextSearchMatchPreview; + } + + /** + * A preview of the text result. + */ + export interface TextSearchMatchPreview { + /** + * The matching lines of text, or a portion of the matching line that contains the match. + */ + text: string; + + /** + * The Range within `text` corresponding to the text of the match. + * The number of matches must match the TextSearchMatch's range property. + */ + matches: Range | Range[]; + } + + /** + * A line of context surrounding a TextSearchMatch. + */ + export interface TextSearchContext { + /** + * The uri for the matching document. + */ + uri: Uri; + + /** + * One line of text. + * previewOptions.charsPerLine applies to this + */ + text: string; + + /** + * The line number of this line of context. + */ + lineNumber: number; + } + + export type TextSearchResult = TextSearchMatch | TextSearchContext; + + /** + * Information collected when text search is complete. + */ + export interface TextSearchComplete { + /** + * Whether the search hit the limit on the maximum number of search results. + * `maxResults` on [`TextSearchOptions`](#TextSearchOptions) specifies the max number of results. + * - If exactly that number of matches exist, this should be false. + * - If `maxResults` matches are returned and more exist, this should be true. + * - If search hits an internal limit which is less than `maxResults`, this should be true. + */ + limitHit?: boolean; + } + + export namespace workspace { + /** + * Find text in files across all [workspace folders] in the workspace + * @param query What to search + * @param optionsOrCallback + * @param callbackOrToken + * @param token + */ + export function findTextInFiles(query: TextSearchQuery, optionsOrCallback: FindTextInFilesOptions | ((result: TextSearchResult) => void), + callbackOrToken?: CancellationToken | ((result: TextSearchResult) => void), token?: CancellationToken): Promise; + } + +} diff --git a/packages/plugin/src/theia.proposed.fsChunks.d.ts b/packages/plugin/src/theia.proposed.fsChunks.d.ts new file mode 100644 index 0000000000000..cad38ac0e5631 --- /dev/null +++ b/packages/plugin/src/theia.proposed.fsChunks.d.ts @@ -0,0 +1,32 @@ +// ***************************************************************************** +// Copyright (C) 2023 Ericsson and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 +// ***************************************************************************** + +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.fsChunks.d.ts + +export module '@theia/plugin' { + + export interface FileSystemProvider { + open?(resource: Uri, options: { create: boolean }): number | Thenable; + close?(fd: number): void | Thenable; + read?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): number | Thenable; + write?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): number | Thenable; + } + +} diff --git a/packages/plugin/src/theia.proposed.profileContentHandlers.d.ts b/packages/plugin/src/theia.proposed.profileContentHandlers.d.ts new file mode 100644 index 0000000000000..d205a0800f227 --- /dev/null +++ b/packages/plugin/src/theia.proposed.profileContentHandlers.d.ts @@ -0,0 +1,35 @@ +// ***************************************************************************** +// Copyright (C) 2023 Ericsson and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 +// ***************************************************************************** + +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.profileContentHandlers.d.ts + +export module '@theia/plugin' { + + export interface ProfileContentHandler { + readonly name: string; + saveProfile(name: string, content: string, token: CancellationToken): Thenable; + readProfile(uri: Uri, token: CancellationToken): Thenable; + } + + export namespace window { + export function registerProfileContentHandler(id: string, profileContentHandler: ProfileContentHandler): Disposable; + } + +} diff --git a/packages/plugin/src/theia.proposed.resolvers.d.ts b/packages/plugin/src/theia.proposed.resolvers.d.ts new file mode 100644 index 0000000000000..6f123d63e89a2 --- /dev/null +++ b/packages/plugin/src/theia.proposed.resolvers.d.ts @@ -0,0 +1,44 @@ +// ***************************************************************************** +// Copyright (C) 2023 Ericsson and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 +// ***************************************************************************** + +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.resolvers.d.ts + +export module '@theia/plugin' { + + export interface ResourceLabelFormatter { + scheme: string; + authority?: string; + formatting: ResourceLabelFormatting; + } + + export interface ResourceLabelFormatting { + label: string; // myLabel:/${path} + separator: '/' | '\\' | ''; + tildify?: boolean; + normalizeDriveLetter?: boolean; + workspaceSuffix?: string; + authorityPrefix?: string; + } + + export namespace workspace { + export function registerResourceLabelFormatter(formatter: ResourceLabelFormatter): Disposable; + } + +} diff --git a/packages/plugin/src/theia.proposed.scmValidation.d.ts b/packages/plugin/src/theia.proposed.scmValidation.d.ts new file mode 100644 index 0000000000000..f9c2458fce555 --- /dev/null +++ b/packages/plugin/src/theia.proposed.scmValidation.d.ts @@ -0,0 +1,70 @@ +// ***************************************************************************** +// Copyright (C) 2023 Ericsson and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 +// ***************************************************************************** + +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.scmValidation.d.ts + +export module '@theia/plugin' { + + /** + * Represents the validation type of the Source Control input. + */ + export enum SourceControlInputBoxValidationType { + + /** + * Something not allowed by the rules of a language or other means. + */ + Error = 0, + + /** + * Something suspicious but allowed. + */ + Warning = 1, + + /** + * Something to inform about but not a problem. + */ + Information = 2 + } + + export interface SourceControlInputBoxValidation { + + /** + * The validation message to display. + */ + readonly message: string; + + /** + * The validation type. + */ + readonly type: SourceControlInputBoxValidationType; + } + + /** + * Represents the input box in the Source Control viewlet. + */ + export interface SourceControlInputBox { + + /** + * A validation function for the input box. It's possible to change + * the validation provider simply by setting this property to a different function. + */ + validateInput?(value: string, cursorPosition: number): ProviderResult; + } +} diff --git a/packages/plugin/src/theia.proposed.terminalQuickFixProvider.d.ts b/packages/plugin/src/theia.proposed.terminalQuickFixProvider.d.ts new file mode 100644 index 0000000000000..c04280b8d8529 --- /dev/null +++ b/packages/plugin/src/theia.proposed.terminalQuickFixProvider.d.ts @@ -0,0 +1,90 @@ +// ***************************************************************************** +// Copyright (C) 2023 Ericsson and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 +// ***************************************************************************** + +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.terminalQuickFixProvider.d.ts + +export module '@theia/plugin' { + + export namespace window { + /** + * @param provider A terminal quick fix provider + * @return A {@link Disposable} that un-registers the provider when being disposed + */ + export function registerTerminalQuickFixProvider(id: string, provider: TerminalQuickFixProvider): Disposable; + } + + export interface TerminalQuickFixProvider { + /** + * Provides terminal quick fixes + * @param commandMatchResult The command match result for which to provide quick fixes + * @param token A cancellation token indicating the result is no longer needed + * @return Terminal quick fix(es) if any + */ + provideTerminalQuickFixes(commandMatchResult: TerminalCommandMatchResult, token: CancellationToken): TerminalQuickFix[] | TerminalQuickFix | undefined; + } + + export interface TerminalCommandMatchResult { + commandLine: string; + commandLineMatch: RegExpMatchArray; + outputMatch?: { + regexMatch: RegExpMatchArray; + outputLines?: string[]; + }; + } + + interface TerminalQuickFix { + type: TerminalQuickFixType; + } + + enum TerminalQuickFixType { + command = 'command', + opener = 'opener' + } + + /** + * A matcher that runs on a sub-section of a terminal command's output + */ + interface TerminalOutputMatcher { + /** + * A string or regex to match against the unwrapped line. If this is a regex with the multiline + * flag, it will scan an amount of lines equal to `\n` instances in the regex + 1. + */ + lineMatcher: string | RegExp; + /** + * Which side of the output to anchor the {@link offset} and {@link length} against. + */ + anchor: TerminalOutputAnchor; + /** + * The number of rows above or below the {@link anchor} to start matching against. + */ + offset: number; + /** + * The number of wrapped lines to match against, this should be as small as possible for performance + * reasons. This is capped at 40. + */ + length: number; + } + + enum TerminalOutputAnchor { + Top = 0, + Bottom = 1 + } + +} diff --git a/packages/plugin/src/theia.proposed.textSearchProvider.d.ts b/packages/plugin/src/theia.proposed.textSearchProvider.d.ts new file mode 100644 index 0000000000000..9ba7fa1eed01b --- /dev/null +++ b/packages/plugin/src/theia.proposed.textSearchProvider.d.ts @@ -0,0 +1,145 @@ +// ***************************************************************************** +// Copyright (C) 2023 Ericsson and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 +// ***************************************************************************** + +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.textSearchQuery.d.ts + +export module '@theia/plugin' { + + /** + * The parameters of a query for text search. + */ + export interface TextSearchQuery { + /** + * The text pattern to search for. + */ + pattern: string; + + /** + * Whether or not `pattern` should match multiple lines of text. + */ + isMultiline?: boolean; + + /** + * Whether or not `pattern` should be interpreted as a regular expression. + */ + isRegExp?: boolean; + + /** + * Whether or not the search should be case-sensitive. + */ + isCaseSensitive?: boolean; + + /** + * Whether or not to search for whole word matches only. + */ + isWordMatch?: boolean; + } + + /** + * A match from a text search + */ + export interface TextSearchMatch { + /** + * The uri for the matching document. + */ + uri: Uri; + + /** + * The range of the match within the document, or multiple ranges for multiple matches. + */ + ranges: Range | Range[]; + + /** + * A preview of the text match. + */ + preview: TextSearchMatchPreview; + } + + /** + * A preview of the text result. + */ + export interface TextSearchMatchPreview { + /** + * The matching lines of text, or a portion of the matching line that contains the match. + */ + text: string; + + /** + * The Range within `text` corresponding to the text of the match. + * The number of matches must match the TextSearchMatch's range property. + */ + matches: Range | Range[]; + } + + /** + * Options to specify the size of the result text preview. + * These options don't affect the size of the match itself, just the amount of preview text. + */ + export interface TextSearchPreviewOptions { + /** + * The maximum number of lines in the preview. + * Only search providers that support multiline search will ever return more than one line in the match. + */ + matchLines: number; + + /** + * The maximum number of characters included per line. + */ + charsPerLine: number; + } + + /** + * A line of context surrounding a TextSearchMatch. + */ + export interface TextSearchContext { + /** + * The uri for the matching document. + */ + uri: Uri; + + /** + * One line of text. + * previewOptions.charsPerLine applies to this + */ + text: string; + + /** + * The line number of this line of context. + */ + lineNumber: number; + } + + export type TextSearchResult = TextSearchMatch | TextSearchContext; + + /** + * Information collected when text search is complete. + */ + export interface TextSearchComplete { + /** + * Whether the search hit the limit on the maximum number of search results. + * `maxResults` on [`TextSearchOptions`](#TextSearchOptions) specifies the max number of results. + * - If exactly that number of matches exist, this should be false. + * - If `maxResults` matches are returned and more exist, this should be true. + * - If search hits an internal limit which is less than `maxResults`, this should be true. + */ + limitHit?: boolean; + } + +} diff --git a/packages/plugin/src/theia.proposed.timeline.d.ts b/packages/plugin/src/theia.proposed.timeline.d.ts new file mode 100644 index 0000000000000..0d0c05ea890fb --- /dev/null +++ b/packages/plugin/src/theia.proposed.timeline.d.ts @@ -0,0 +1,177 @@ +// ***************************************************************************** +// Copyright (C) 2023 Ericsson and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 +// ***************************************************************************** + +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +// code copied and modified from https://github.com/microsoft/vscode/blob/1.77.0/src/vscode-dts/vscode.proposed.timeline.d.ts + +export module '@theia/plugin' { + + export class TimelineItem { + /** + * A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred. + */ + timestamp: number; + + /** + * A human-readable string describing the timeline item. + */ + label: string; + + /** + * Optional id for the timeline item. It must be unique across all the timeline items provided by this source. + * + * If not provided, an id is generated using the timeline item's timestamp. + */ + id?: string; + + /** + * The icon path or [ThemeIcon](#ThemeIcon) for the timeline item. + */ + iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon; + + /** + * A human readable string describing less prominent details of the timeline item. + */ + description?: string; + + /** + * The tooltip text when you hover over the timeline item. + */ + detail?: string; + + /** + * The [command](#Command) that should be executed when the timeline item is selected. + */ + command?: Command; + + /** + * Context value of the timeline item. This can be used to contribute specific actions to the item. + * For example, a timeline item is given a context value as `commit`. When contributing actions to `timeline/item/context` + * using `menus` extension point, you can specify context value for key `timelineItem` in `when` expression like `timelineItem == commit`. + * ``` + * "contributes": { + * "menus": { + * "timeline/item/context": [{ + * "command": "extension.copyCommitId", + * "when": "timelineItem == commit" + * }] + * } + * } + * ``` + * This will show the `extension.copyCommitId` action only for items where `contextValue` is `commit`. + */ + contextValue?: string; + + /** + * Accessibility information used when screen reader interacts with this timeline item. + */ + accessibilityInformation?: AccessibilityInformation; + + /** + * @param label A human-readable string describing the timeline item + * @param timestamp A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred + */ + constructor(label: string, timestamp: number); + } + + export interface TimelineChangeEvent { + /** + * The [uri](#Uri) of the resource for which the timeline changed. + */ + uri: Uri; + + /** + * A flag which indicates whether the entire timeline should be reset. + */ + reset?: boolean; + } + + export interface Timeline { + readonly paging?: { + /** + * A provider-defined cursor specifying the starting point of timeline items which are after the ones returned. + * Use `undefined` to signal that there are no more items to be returned. + */ + readonly cursor: string | undefined; + } + + /** + * An array of [timeline items](#TimelineItem). + */ + readonly items: readonly TimelineItem[]; + } + + export interface TimelineOptions { + /** + * A provider-defined cursor specifying the starting point of the timeline items that should be returned. + */ + cursor?: string; + + /** + * An optional maximum number timeline items or the all timeline items newer (inclusive) than the timestamp or id that should be returned. + * If `undefined` all timeline items should be returned. + */ + limit?: number | { timestamp: number; id?: string }; + } + + export interface TimelineProvider { + /** + * An optional event to signal that the timeline for a source has changed. + * To signal that the timeline for all resources (uris) has changed, do not pass any argument or pass `undefined`. + */ + onDidChange?: Event; + + /** + * An identifier of the source of the timeline items. This can be used to filter sources. + */ + readonly id: string; + + /** + * A human-readable string describing the source of the timeline items. This can be used as the display label when filtering sources. + */ + readonly label: string; + + /** + * Provide [timeline items](#TimelineItem) for a [Uri](#Uri). + * + * @param uri The [uri](#Uri) of the file to provide the timeline for. + * @param options A set of options to determine how results should be returned. + * @param token A cancellation token. + * @return The [timeline result](#TimelineResult) or a thenable that resolves to such. The lack of a result + * can be signaled by returning `undefined`, `null`, or an empty array. + */ + provideTimeline(uri: Uri, options: TimelineOptions, token: CancellationToken): ProviderResult; + } + + export namespace workspace { + /** + * Register a timeline provider. + * + * Multiple providers can be registered. In that case, providers are asked in + * parallel and the results are merged. A failing provider (rejected promise or exception) will + * not cause a failure of the whole operation. + * + * @param scheme A scheme or schemes that defines which documents this provider is applicable to. Can be `*` to target all documents. + * @param provider A timeline provider. + * @return A [disposable](#Disposable) that unregisters this provider when being disposed. + */ + export function registerTimelineProvider(scheme: string | string[], provider: TimelineProvider): Disposable; + } + +} diff --git a/sample-plugins/sample-namespace/plugin-a/extension.js b/sample-plugins/sample-namespace/plugin-a/extension.js index cc954154f7893..444471f16aff0 100644 --- a/sample-plugins/sample-namespace/plugin-a/extension.js +++ b/sample-plugins/sample-namespace/plugin-a/extension.js @@ -11,7 +11,7 @@ // with the GNU Classpath Exception which is available at // https://www.gnu.org/software/classpath/license.html. // -// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** const vscode = require('vscode'); diff --git a/sample-plugins/sample-namespace/plugin-b/extension.js b/sample-plugins/sample-namespace/plugin-b/extension.js index a4e01b37c1ff0..798ac28130589 100644 --- a/sample-plugins/sample-namespace/plugin-b/extension.js +++ b/sample-plugins/sample-namespace/plugin-b/extension.js @@ -11,7 +11,7 @@ // with the GNU Classpath Exception which is available at // https://www.gnu.org/software/classpath/license.html. // -// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** const vscode = require('vscode');