새 프로젝트에 투입되었으나 수행할 업무가 묘연해진 나머지 extension 개발을 마저 하려 API 문서를 읽다가 vscode 모듈 내에서 사용하게 될 거 같은 interface들을 발견해 메모해 둘 겸 기록을 남기게 되었다.
javaScript로 개발하려 했는데 공식 문서도 참고자료도 typescritp여서 투입 프로젝트 역시 typescript인 김에 활용 연습겸 언어도 전환하려 한다.
/**
* A range represents an ordered pair of two positions.
* It is guaranteed that {@link Range.start start}.isBeforeOrEqual({@link Range.end end})
*
* Range objects are __immutable__. Use the {@link Range.with with},
* {@link Range.intersection intersection}, or {@link Range.union union} methods
* to derive new ranges from an existing range.
*/
export class Range {
/**
* The start position. It is before or equal to {@link Range.end end}.
*/
readonly start: Position;
/**
* The end position. It is after or equal to {@link Range.start start}.
*/
readonly end: Position;
/**
* Create a new range from two positions. If `start` is not
* before or equal to `end`, the values will be swapped.
*
* @param start A position.
* @param end A position.
*/
constructor(start: Position, end: Position);
/**
* Create a new range from number coordinates. It is a shorter equivalent of
* using `new Range(new Position(startLine, startCharacter), new Position(endLine, endCharacter))`
*
* @param startLine A zero-based line value.
* @param startCharacter A zero-based character value.
* @param endLine A zero-based line value.
* @param endCharacter A zero-based character value.
*/
constructor(startLine: number, startCharacter: number, endLine: number, endCharacter: number);
/**
* `true` if `start` and `end` are equal.
*/
isEmpty: boolean;
/**
* `true` if `start.line` and `end.line` are equal.
*/
isSingleLine: boolean;
/**
* Check if a position or a range is contained in this range.
*
* @param positionOrRange A position or a range.
* @return `true` if the position or range is inside or equal
* to this range.
*/
contains(positionOrRange: Position | Range): boolean;
/**
* Check if `other` equals this range.
*
* @param other A range.
* @return `true` when start and end are {@link Position.isEqual equal} to
* start and end of this range.
*/
isEqual(other: Range): boolean;
/**
* Intersect `range` with this range and returns a new range or `undefined`
* if the ranges have no overlap.
*
* @param range A range.
* @return A range of the greater start and smaller end positions. Will
* return undefined when there is no overlap.
*/
intersection(range: Range): Range | undefined;
/**
* Compute the union of `other` with this range.
*
* @param other A range.
* @return A range of smaller start position and the greater end position.
*/
union(other: Range): Range;
/**
* Derived a new range from this range.
*
* @param start A position that should be used as start. The default value is the {@link Range.start current start}.
* @param end A position that should be used as end. The default value is the {@link Range.end current end}.
* @return A range derived from this range with the given start and end position.
* If start and end are not different `this` range will be returned.
*/
with(start?: Position, end?: Position): Range;
/**
* Derived a new range from this range.
*
* @param change An object that describes a change to this range.
* @return A range that reflects the given change. Will return `this` range if the change
* is not changing anything.
*/
with(change: { start?: Position; end?: Position }): Range;
}
/**
* Represents a text selection in an editor.
*/
export class Selection extends Range {
/**
* The position at which the selection starts.
* This position might be before or after {@link Selection.active active}.
*/
anchor: Position;
/**
* The position of the cursor.
* This position might be before or after {@link Selection.anchor anchor}.
*/
active: Position;
/**
* Create a selection from two positions.
*
* @param anchor A position.
* @param active A position.
*/
constructor(anchor: Position, active: Position);
/**
* Create a selection from four coordinates.
*
* @param anchorLine A zero-based line value.
* @param anchorCharacter A zero-based character value.
* @param activeLine A zero-based line value.
* @param activeCharacter A zero-based character value.
*/
constructor(anchorLine: number, anchorCharacter: number, activeLine: number, activeCharacter: number);
/**
* A selection is reversed if its {@link Selection.anchor anchor} is the {@link Selection.end end} position.
*/
isReversed: boolean;
}
/**
* Represents an editor that is attached to a {@link TextDocument document}.
*/
export interface TextEditor {
/**
* The document associated with this text editor. The document will be the same for the entire lifetime of this text editor.
*/
readonly document: TextDocument;
/**
* The primary selection on this text editor. Shorthand for `TextEditor.selections[0]`.
*/
selection: Selection;
/**
* The selections in this text editor. The primary selection is always at index 0.
*/
selections: readonly Selection[];
/**
* The current visible ranges in the editor (vertically).
* This accounts only for vertical scrolling, and not for horizontal scrolling.
*/
readonly visibleRanges: readonly Range[];
/**
* Text editor options.
*/
options: TextEditorOptions;
/**
* The column in which this editor shows. Will be `undefined` in case this
* isn't one of the main editors, e.g. an embedded editor, or when the editor
* column is larger than three.
*/
readonly viewColumn: ViewColumn | undefined;
/**
* Perform an edit on the document associated with this text editor.
*
* The given callback-function is invoked with an {@link TextEditorEdit edit-builder} which must
* be used to make edits. Note that the edit-builder is only valid while the
* callback executes.
*
* @param callback A function which can create edits using an {@link TextEditorEdit edit-builder}.
* @param options The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.
* @return A promise that resolves with a value indicating if the edits could be applied.
*/
edit(callback: (editBuilder: TextEditorEdit) => void, options?: { readonly undoStopBefore: boolean; readonly undoStopAfter: boolean }): Thenable<boolean>;
/**
* Insert a {@link SnippetString snippet} and put the editor into snippet mode. "Snippet mode"
* means the editor adds placeholders and additional cursors so that the user can complete
* or accept the snippet.
*
* @param snippet The snippet to insert in this edit.
* @param location Position or range at which to insert the snippet, defaults to the current editor selection or selections.
* @param options The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.
* @return A promise that resolves with a value indicating if the snippet could be inserted. Note that the promise does not signal
* that the snippet is completely filled-in or accepted.
*/
insertSnippet(snippet: SnippetString, location?: Position | Range | readonly Position[] | readonly Range[], options?: { readonly undoStopBefore: boolean; readonly undoStopAfter: boolean }): Thenable<boolean>;
/**
* Adds a set of decorations to the text editor. If a set of decorations already exists with
* the given {@link TextEditorDecorationType decoration type}, they will be replaced. If
* `rangesOrOptions` is empty, the existing decorations with the given {@link TextEditorDecorationType decoration type}
* will be removed.
*
* @see {@link window.createTextEditorDecorationType createTextEditorDecorationType}.
*
* @param decorationType A decoration type.
* @param rangesOrOptions Either {@link Range ranges} or more detailed {@link DecorationOptions options}.
*/
setDecorations(decorationType: TextEditorDecorationType, rangesOrOptions: readonly Range[] | readonly DecorationOptions[]): void;
/**
* Scroll as indicated by `revealType` in order to reveal the given range.
*
* @param range A range.
* @param revealType The scrolling strategy for revealing `range`.
*/
revealRange(range: Range, revealType?: TextEditorRevealType): void;
/**
* Show the text editor.
*
* @deprecated Use {@link window.showTextDocument} instead.
*
* @param column The {@link ViewColumn column} in which to show this editor.
* This method shows unexpected behavior and will be removed in the next major update.
*/
show(column?: ViewColumn): void;
/**
* Hide the text editor.
*
* @deprecated Use the command `workbench.action.closeActiveEditor` instead.
* This method shows unexpected behavior and will be removed in the next major update.
*/
hide(): void;
}
/**
* The kind of {@link QuickPickItem quick pick item}.
*/
export enum QuickPickItemKind {
/**
* When a {@link QuickPickItem} has a kind of {@link Separator}, the item is just a visual separator and does not represent a real item.
* The only property that applies is {@link QuickPickItem.label label }. All other properties on {@link QuickPickItem} will be ignored and have no effect.
*/
Separator = -1,
/**
* The default {@link QuickPickItem.kind} is an item that can be selected in the quick pick.
*/
Default = 0,
}
/**
* Represents an item that can be selected from
* a list of items.
*/
export interface QuickPickItem {
/**
* A human-readable string which is rendered prominent. Supports rendering of {@link ThemeIcon theme icons} via
* the `$(<name>)`-syntax.
*/
label: string;
/**
* The kind of QuickPickItem that will determine how this item is rendered in the quick pick. When not specified,
* the default is {@link QuickPickItemKind.Default}.
*/
kind?: QuickPickItemKind;
/**
* A human-readable string which is rendered less prominent in the same line. Supports rendering of
* {@link ThemeIcon theme icons} via the `$(<name>)`-syntax.
*
* Note: this property is ignored when {@link QuickPickItem.kind kind} is set to {@link QuickPickItemKind.Separator}
*/
description?: string;
/**
* A human-readable string which is rendered less prominent in a separate line. Supports rendering of
* {@link ThemeIcon theme icons} via the `$(<name>)`-syntax.
*
* Note: this property is ignored when {@link QuickPickItem.kind kind} is set to {@link QuickPickItemKind.Separator}
*/
detail?: string;
/**
* Optional flag indicating if this item is picked initially. This is only honored when using
* the {@link window.showQuickPick showQuickPick()} API. To do the same thing with
* the {@link window.createQuickPick createQuickPick()} API, simply set the {@link QuickPick.selectedItems}
* to the items you want picked initially.
* (*Note:* This is only honored when the picker allows multiple selections.)
*
* @see {@link QuickPickOptions.canPickMany}
*
* Note: this property is ignored when {@link QuickPickItem.kind kind} is set to {@link QuickPickItemKind.Separator}
*/
picked?: boolean;
/**
* Always show this item.
*
* Note: this property is ignored when {@link QuickPickItem.kind kind} is set to {@link QuickPickItemKind.Separator}
*/
alwaysShow?: boolean;
/**
* Optional buttons that will be rendered on this particular item. These buttons will trigger
* an {@link QuickPickItemButtonEvent} when clicked. Buttons are only rendered when using a quickpick
* created by the {@link window.createQuickPick createQuickPick()} API. Buttons are not rendered when using
* the {@link window.showQuickPick showQuickPick()} API.
*
* Note: this property is ignored when {@link QuickPickItem.kind kind} is set to {@link QuickPickItemKind.Separator}
*/
buttons?: readonly QuickInputButton[];
}
/**
* The document highlight provider interface defines the contract between extensions and
* the word-highlight-feature.
*/
export interface DocumentHighlightProvider {
/**
* Provide a set of document highlights, like all occurrences of a variable or
* all exit-points of a function.
*
* @param document The document in which the command was invoked.
* @param position The position at which the command was invoked.
* @param token A cancellation token.
* @return An array of document highlights or a thenable that resolves to such. The lack of a result can be
* signaled by returning `undefined`, `null`, or an empty array.
*/
provideDocumentHighlights(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<DocumentHighlight[]>;
}
/**
* A selection range represents a part of a selection hierarchy. A selection range
* may have a parent selection range that contains it.
*/
export class SelectionRange {
/**
* The {@link Range} of this selection range.
*/
range: Range;
/**
* The parent selection range containing this range.
*/
parent?: SelectionRange;
/**
* Creates a new selection range.
*
* @param range The range of the selection range.
* @param parent The parent of the selection range.
*/
constructor(range: Range, parent?: SelectionRange);
}
export interface SelectionRangeProvider {
/**
* Provide selection ranges for the given positions.
*
* Selection ranges should be computed individually and independent for each position. The editor will merge
* and deduplicate ranges but providers must return hierarchies of selection ranges so that a range
* is {@link Range.contains contained} by its parent.
*
* @param document The document in which the command was invoked.
* @param positions The positions at which the command was invoked.
* @param token A cancellation token.
* @return Selection ranges or a thenable that resolves to such. The lack of a result can be
* signaled by returning `undefined` or `null`.
*/
provideSelectionRanges(document: TextDocument, positions: readonly Position[], token: CancellationToken): ProviderResult<SelectionRange[]>;
}
/**
* Namespace for dealing with commands. In short, a command is a function with a
* unique identifier. The function is sometimes also called _command handler_.
*
* Commands can be added to the editor using the {@link commands.registerCommand registerCommand}
* and {@link commands.registerTextEditorCommand registerTextEditorCommand} functions. Commands
* can be executed {@link commands.executeCommand manually} or from a UI gesture. Those are:
*
* * palette - Use the `commands`-section in `package.json` to make a command show in
* the [command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette).
* * keybinding - Use the `keybindings`-section in `package.json` to enable
* [keybindings](https://code.visualstudio.com/docs/getstarted/keybindings#_customizing-shortcuts)
* for your extension.
*
* Commands from other extensions and from the editor itself are accessible to an extension. However,
* when invoking an editor command not all argument types are supported.
*
* This is a sample that registers a command handler and adds an entry for that command to the palette. First
* register a command handler with the identifier `extension.sayHello`.
* ```javascript
* commands.registerCommand('extension.sayHello', () => {
* window.showInformationMessage('Hello World!');
* });
* ```
* Second, bind the command identifier to a title under which it will show in the palette (`package.json`).
* ```json
* {
* "contributes": {
* "commands": [{
* "command": "extension.sayHello",
* "title": "Hello World"
* }]
* }
* }
* ```
*/
export namespace commands {
/**
* Registers a command that can be invoked via a keyboard shortcut,
* a menu item, an action, or directly.
*
* Registering a command with an existing command identifier twice
* will cause an error.
*
* @param command A unique identifier for the command.
* @param callback A command handler function.
* @param thisArg The `this` context used when invoking the handler function.
* @return Disposable which unregisters this command on disposal.
*/
export function registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable;
/**
* Registers a text editor command that can be invoked via a keyboard shortcut,
* a menu item, an action, or directly.
*
* Text editor commands are different from ordinary {@link commands.registerCommand commands} as
* they only execute when there is an active editor when the command is called. Also, the
* command handler of an editor command has access to the active editor and to an
* {@link TextEditorEdit edit}-builder. Note that the edit-builder is only valid while the
* callback executes.
*
* @param command A unique identifier for the command.
* @param callback A command handler function with access to an {@link TextEditor editor} and an {@link TextEditorEdit edit}.
* @param thisArg The `this` context used when invoking the handler function.
* @return Disposable which unregisters this command on disposal.
*/
export function registerTextEditorCommand(command: string, callback: (textEditor: TextEditor, edit: TextEditorEdit, ...args: any[]) => void, thisArg?: any): Disposable;
/**
* Executes the command denoted by the given command identifier.
*
* * *Note 1:* When executing an editor command not all types are allowed to
* be passed as arguments. Allowed are the primitive types `string`, `boolean`,
* `number`, `undefined`, and `null`, as well as {@linkcode Position}, {@linkcode Range}, {@linkcode Uri} and {@linkcode Location}.
* * *Note 2:* There are no restrictions when executing commands that have been contributed
* by extensions.
*
* @param command Identifier of the command to execute.
* @param rest Parameters passed to the command function.
* @return A thenable that resolves to the returned value of the given command. Returns `undefined` when
* the command handler function doesn't return anything.
*/
export function executeCommand<T = unknown>(command: string, ...rest: any[]): Thenable<T>;
/**
* Retrieve the list of all available commands. Commands starting with an underscore are
* treated as internal commands.
*
* @param filterInternal Set `true` to not see internal commands (starting with an underscore)
* @return Thenable that resolves to a list of command ids.
*/
export function getCommands(filterInternal?: boolean): Thenable<string[]>;
}
/**
* Represents the state of a window.
*/
export interface WindowState {
/**
* Whether the current window is focused.
*/
readonly focused: boolean;
}
/**
* Namespace for dealing with the current window of the editor. That is visible
* and active editors, as well as, UI elements to show messages, selections, and
* asking for user input.
*/
export namespace window {
/**
* Represents the grid widget within the main editor area
*/
export const tabGroups: TabGroups;
/**
* The currently active editor or `undefined`. The active editor is the one
* that currently has focus or, when none has focus, the one that has changed
* input most recently.
*/
export let activeTextEditor: TextEditor | undefined;
/**
* The currently visible editors or an empty array.
*/
export let visibleTextEditors: readonly TextEditor[];
/**
* An {@link Event} which fires when the {@link window.activeTextEditor active editor}
* has changed. *Note* that the event also fires when the active editor changes
* to `undefined`.
*/
export const onDidChangeActiveTextEditor: Event<TextEditor | undefined>;
/**
* An {@link Event} which fires when the array of {@link window.visibleTextEditors visible editors}
* has changed.
*/
export const onDidChangeVisibleTextEditors: Event<readonly TextEditor[]>;
/**
* An {@link Event} which fires when the selection in an editor has changed.
*/
export const onDidChangeTextEditorSelection: Event<TextEditorSelectionChangeEvent>;
/**
* An {@link Event} which fires when the visible ranges of an editor has changed.
*/
export const onDidChangeTextEditorVisibleRanges: Event<TextEditorVisibleRangesChangeEvent>;
/**
* An {@link Event} which fires when the options of an editor have changed.
*/
export const onDidChangeTextEditorOptions: Event<TextEditorOptionsChangeEvent>;
/**
* An {@link Event} which fires when the view column of an editor has changed.
*/
export const onDidChangeTextEditorViewColumn: Event<TextEditorViewColumnChangeEvent>;
/**
* The currently visible {@link NotebookEditor notebook editors} or an empty array.
*/
export const visibleNotebookEditors: readonly NotebookEditor[];
/**
* An {@link Event} which fires when the {@link window.visibleNotebookEditors visible notebook editors}
* has changed.
*/
export const onDidChangeVisibleNotebookEditors: Event<readonly NotebookEditor[]>;
/**
* The currently active {@link NotebookEditor notebook editor} or `undefined`. The active editor is the one
* that currently has focus or, when none has focus, the one that has changed
* input most recently.
*/
export const activeNotebookEditor: NotebookEditor | undefined;
/**
* An {@link Event} which fires when the {@link window.activeNotebookEditor active notebook editor}
* has changed. *Note* that the event also fires when the active editor changes
* to `undefined`.
*/
export const onDidChangeActiveNotebookEditor: Event<NotebookEditor | undefined>;
/**
* An {@link Event} which fires when the {@link NotebookEditor.selections notebook editor selections}
* have changed.
*/
export const onDidChangeNotebookEditorSelection: Event<NotebookEditorSelectionChangeEvent>;
/**
* An {@link Event} which fires when the {@link NotebookEditor.visibleRanges notebook editor visible ranges}
* have changed.
*/
export const onDidChangeNotebookEditorVisibleRanges: Event<NotebookEditorVisibleRangesChangeEvent>;
/**
* The currently opened terminals or an empty array.
*/
export const terminals: readonly Terminal[];
/**
* The currently active terminal or `undefined`. The active terminal is the one that
* currently has focus or most recently had focus.
*/
export const activeTerminal: Terminal | undefined;
/**
* An {@link Event} which fires when the {@link window.activeTerminal active terminal}
* has changed. *Note* that the event also fires when the active terminal changes
* to `undefined`.
*/
export const onDidChangeActiveTerminal: Event<Terminal | undefined>;
/**
* An {@link Event} which fires when a terminal has been created, either through the
* {@link window.createTerminal createTerminal} API or commands.
*/
export const onDidOpenTerminal: Event<Terminal>;
/**
* An {@link Event} which fires when a terminal is disposed.
*/
export const onDidCloseTerminal: Event<Terminal>;
/**
* An {@link Event} which fires when a {@link Terminal.state terminal's state} has changed.
*/
export const onDidChangeTerminalState: Event<Terminal>;
/**
* Represents the current window's state.
*/
export const state: WindowState;
/**
* An {@link Event} which fires when the focus state of the current window
* changes. The value of the event represents whether the window is focused.
*/
export const onDidChangeWindowState: Event<WindowState>;
/**
* Show the given document in a text editor. A {@link ViewColumn column} can be provided
* to control where the editor is being shown. Might change the {@link window.activeTextEditor active editor}.
*
* @param document A text document to be shown.
* @param column A view column in which the {@link TextEditor editor} should be shown. The default is the {@link ViewColumn.Active active}.
* Columns that do not exist will be created as needed up to the maximum of {@linkcode ViewColumn.Nine}. Use {@linkcode ViewColumn.Beside}
* to open the editor to the side of the currently active one.
* @param preserveFocus When `true` the editor will not take focus.
* @return A promise that resolves to an {@link TextEditor editor}.
*/
export function showTextDocument(document: TextDocument, column?: ViewColumn, preserveFocus?: boolean): Thenable<TextEditor>;
/**
* Show the given document in a text editor. {@link TextDocumentShowOptions Options} can be provided
* to control options of the editor is being shown. Might change the {@link window.activeTextEditor active editor}.
*
* @param document A text document to be shown.
* @param options {@link TextDocumentShowOptions Editor options} to configure the behavior of showing the {@link TextEditor editor}.
* @return A promise that resolves to an {@link TextEditor editor}.
*/
export function showTextDocument(document: TextDocument, options?: TextDocumentShowOptions): Thenable<TextEditor>;
/**
* A short-hand for `openTextDocument(uri).then(document => showTextDocument(document, options))`.
*
* @see {@link workspace.openTextDocument}
*
* @param uri A resource identifier.
* @param options {@link TextDocumentShowOptions Editor options} to configure the behavior of showing the {@link TextEditor editor}.
* @return A promise that resolves to an {@link TextEditor editor}.
*/
export function showTextDocument(uri: Uri, options?: TextDocumentShowOptions): Thenable<TextEditor>;
/**
* Show the given {@link NotebookDocument} in a {@link NotebookEditor notebook editor}.
*
* @param document A text document to be shown.
* @param options {@link NotebookDocumentShowOptions Editor options} to configure the behavior of showing the {@link NotebookEditor notebook editor}.
*
* @return A promise that resolves to an {@link NotebookEditor notebook editor}.
*/
export function showNotebookDocument(document: NotebookDocument, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
/**
* Create a TextEditorDecorationType that can be used to add decorations to text editors.
*
* @param options Rendering options for the decoration type.
* @return A new decoration type instance.
*/
export function createTextEditorDecorationType(options: DecorationRenderOptions): TextEditorDecorationType;
/**
* Show an information message to users. Optionally provide an array of items which will be presented as
* clickable buttons.
*
* @param message The message to show.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
export function showInformationMessage<T extends string>(message: string, ...items: T[]): Thenable<T | undefined>;
/**
* Show an information message to users. Optionally provide an array of items which will be presented as
* clickable buttons.
*
* @param message The message to show.
* @param options Configures the behaviour of the message.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
export function showInformationMessage<T extends string>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
/**
* Show an information message.
*
* @see {@link window.showInformationMessage showInformationMessage}
*
* @param message The message to show.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
export function showInformationMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;
/**
* Show an information message.
*
* @see {@link window.showInformationMessage showInformationMessage}
*
* @param message The message to show.
* @param options Configures the behaviour of the message.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
export function showInformationMessage<T extends MessageItem>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
/**
* Show a warning message.
*
* @see {@link window.showInformationMessage showInformationMessage}
*
* @param message The message to show.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
export function showWarningMessage<T extends string>(message: string, ...items: T[]): Thenable<T | undefined>;
/**
* Show a warning message.
*
* @see {@link window.showInformationMessage showInformationMessage}
*
* @param message The message to show.
* @param options Configures the behaviour of the message.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
export function showWarningMessage<T extends string>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
/**
* Show a warning message.
*
* @see {@link window.showInformationMessage showInformationMessage}
*
* @param message The message to show.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
export function showWarningMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;
/**
* Show a warning message.
*
* @see {@link window.showInformationMessage showInformationMessage}
*
* @param message The message to show.
* @param options Configures the behaviour of the message.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
export function showWarningMessage<T extends MessageItem>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
/**
* Show an error message.
*
* @see {@link window.showInformationMessage showInformationMessage}
*
* @param message The message to show.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
export function showErrorMessage<T extends string>(message: string, ...items: T[]): Thenable<T | undefined>;
/**
* Show an error message.
*
* @see {@link window.showInformationMessage showInformationMessage}
*
* @param message The message to show.
* @param options Configures the behaviour of the message.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
export function showErrorMessage<T extends string>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
/**
* Show an error message.
*
* @see {@link window.showInformationMessage showInformationMessage}
*
* @param message The message to show.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
export function showErrorMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;
/**
* Show an error message.
*
* @see {@link window.showInformationMessage showInformationMessage}
*
* @param message The message to show.
* @param options Configures the behaviour of the message.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
export function showErrorMessage<T extends MessageItem>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
/**
* Shows a selection list allowing multiple selections.
*
* @param items An array of strings, or a promise that resolves to an array of strings.
* @param options Configures the behavior of the selection list.
* @param token A token that can be used to signal cancellation.
* @return A promise that resolves to the selected items or `undefined`.
*/
export function showQuickPick(items: readonly string[] | Thenable<readonly string[]>, options: QuickPickOptions & { canPickMany: true }, token?: CancellationToken): Thenable<string[] | undefined>;
/**
* Shows a selection list.
*
* @param items An array of strings, or a promise that resolves to an array of strings.
* @param options Configures the behavior of the selection list.
* @param token A token that can be used to signal cancellation.
* @return A promise that resolves to the selection or `undefined`.
*/
export function showQuickPick(items: readonly string[] | Thenable<readonly string[]>, options?: QuickPickOptions, token?: CancellationToken): Thenable<string | undefined>;
/**
* Shows a selection list allowing multiple selections.
*
* @param items An array of items, or a promise that resolves to an array of items.
* @param options Configures the behavior of the selection list.
* @param token A token that can be used to signal cancellation.
* @return A promise that resolves to the selected items or `undefined`.
*/
export function showQuickPick<T extends QuickPickItem>(items: readonly T[] | Thenable<readonly T[]>, options: QuickPickOptions & { canPickMany: true }, token?: CancellationToken): Thenable<T[] | undefined>;
/**
* Shows a selection list.
*
* @param items An array of items, or a promise that resolves to an array of items.
* @param options Configures the behavior of the selection list.
* @param token A token that can be used to signal cancellation.
* @return A promise that resolves to the selected item or `undefined`.
*/
export function showQuickPick<T extends QuickPickItem>(items: readonly T[] | Thenable<readonly T[]>, options?: QuickPickOptions, token?: CancellationToken): Thenable<T | undefined>;
/**
* Shows a selection list of {@link workspace.workspaceFolders workspace folders} to pick from.
* Returns `undefined` if no folder is open.
*
* @param options Configures the behavior of the workspace folder list.
* @return A promise that resolves to the workspace folder or `undefined`.
*/
export function showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions): Thenable<WorkspaceFolder | undefined>;
/**
* Shows a file open dialog to the user which allows to select a file
* for opening-purposes.
*
* @param options Options that control the dialog.
* @returns A promise that resolves to the selected resources or `undefined`.
*/
export function showOpenDialog(options?: OpenDialogOptions): Thenable<Uri[] | undefined>;
/**
* Shows a file save dialog to the user which allows to select a file
* for saving-purposes.
*
* @param options Options that control the dialog.
* @returns A promise that resolves to the selected resource or `undefined`.
*/
export function showSaveDialog(options?: SaveDialogOptions): Thenable<Uri | undefined>;
/**
* Opens an input box to ask the user for input.
*
* The returned value will be `undefined` if the input box was canceled (e.g. pressing ESC). Otherwise the
* returned value will be the string typed by the user or an empty string if the user did not type
* anything but dismissed the input box with OK.
*
* @param options Configures the behavior of the input box.
* @param token A token that can be used to signal cancellation.
* @return A promise that resolves to a string the user provided or to `undefined` in case of dismissal.
*/
export function showInputBox(options?: InputBoxOptions, token?: CancellationToken): Thenable<string | undefined>;
/**
* Creates a {@link QuickPick} to let the user pick an item from a list
* of items of type T.
*
* Note that in many cases the more convenient {@link window.showQuickPick}
* is easier to use. {@link window.createQuickPick} should be used
* when {@link window.showQuickPick} does not offer the required flexibility.
*
* @return A new {@link QuickPick}.
*/
export function createQuickPick<T extends QuickPickItem>(): QuickPick<T>;
/**
* Creates a {@link InputBox} to let the user enter some text input.
*
* Note that in many cases the more convenient {@link window.showInputBox}
* is easier to use. {@link window.createInputBox} should be used
* when {@link window.showInputBox} does not offer the required flexibility.
*
* @return A new {@link InputBox}.
*/
export function createInputBox(): InputBox;
/**
* Creates a new {@link OutputChannel output channel} with the given name and language id
* If language id is not provided, then **Log** is used as default language id.
*
* You can access the visible or active output channel as a {@link TextDocument text document} from {@link window.visibleTextEditors visible editors} or {@link window.activeTextEditor active editor}
* and use the language id to contribute language features like syntax coloring, code lens etc.,
*
* @param name Human-readable string which will be used to represent the channel in the UI.
* @param languageId The identifier of the language associated with the channel.
*/
export function createOutputChannel(name: string, languageId?: string): OutputChannel;
/**
* Creates a new {@link LogOutputChannel log output channel} with the given name.
*
* @param name Human-readable string which will be used to represent the channel in the UI.
* @param options Options for the log output channel.
*/
export function createOutputChannel(name: string, options: { log: true }): LogOutputChannel;
/**
* Create and show a new webview panel.
*
* @param viewType Identifies the type of the webview panel.
* @param title Title of the panel.
* @param showOptions Where to show the webview in the editor. If preserveFocus is set, the new webview will not take focus.
* @param options Settings for the new panel.
*
* @return New webview panel.
*/
export function createWebviewPanel(viewType: string, title: string, showOptions: ViewColumn | { readonly viewColumn: ViewColumn; readonly preserveFocus?: boolean }, options?: WebviewPanelOptions & WebviewOptions): WebviewPanel;
/**
* Set a message to the status bar. This is a short hand for the more powerful
* status bar {@link window.createStatusBarItem items}.
*
* @param text The message to show, supports icon substitution as in status bar {@link StatusBarItem.text items}.
* @param hideAfterTimeout Timeout in milliseconds after which the message will be disposed.
* @return A disposable which hides the status bar message.
*/
export function setStatusBarMessage(text: string, hideAfterTimeout: number): Disposable;
/**
* Set a message to the status bar. This is a short hand for the more powerful
* status bar {@link window.createStatusBarItem items}.
*
* @param text The message to show, supports icon substitution as in status bar {@link StatusBarItem.text items}.
* @param hideWhenDone Thenable on which completion (resolve or reject) the message will be disposed.
* @return A disposable which hides the status bar message.
*/
export function setStatusBarMessage(text: string, hideWhenDone: Thenable<any>): Disposable;
/**
* Set a message to the status bar. This is a short hand for the more powerful
* status bar {@link window.createStatusBarItem items}.
*
* *Note* that status bar messages stack and that they must be disposed when no
* longer used.
*
* @param text The message to show, supports icon substitution as in status bar {@link StatusBarItem.text items}.
* @return A disposable which hides the status bar message.
*/
export function setStatusBarMessage(text: string): Disposable;
/**
* Show progress in the Source Control viewlet while running the given callback and while
* its returned promise isn't resolve or rejected.
*
* @deprecated Use `withProgress` instead.
*
* @param task A callback returning a promise. Progress increments can be reported with
* the provided {@link Progress}-object.
* @return The thenable the task did return.
*/
export function withScmProgress<R>(task: (progress: Progress<number>) => Thenable<R>): Thenable<R>;
/**
* Show progress in the editor. Progress is shown while running the given callback
* and while the promise it returned isn't resolved nor rejected. The location at which
* progress should show (and other details) is defined via the passed {@linkcode ProgressOptions}.
*
* @param task A callback returning a promise. Progress state can be reported with
* the provided {@link Progress}-object.
*
* To report discrete progress, use `increment` to indicate how much work has been completed. Each call with
* a `increment` value will be summed up and reflected as overall progress until 100% is reached (a value of
* e.g. `10` accounts for `10%` of work done).
* Note that currently only `ProgressLocation.Notification` is capable of showing discrete progress.
*
* To monitor if the operation has been cancelled by the user, use the provided {@linkcode CancellationToken}.
* Note that currently only `ProgressLocation.Notification` is supporting to show a cancel button to cancel the
* long running operation.
*
* @return The thenable the task-callback returned.
*/
export function withProgress<R>(options: ProgressOptions, task: (progress: Progress<{ message?: string; increment?: number }>, token: CancellationToken) => Thenable<R>): Thenable<R>;
/**
* Creates a status bar {@link StatusBarItem item}.
*
* @param alignment The alignment of the item.
* @param priority The priority of the item. Higher values mean the item should be shown more to the left.
* @return A new status bar item.
*/
export function createStatusBarItem(alignment?: StatusBarAlignment, priority?: number): StatusBarItem;
/**
* Creates a status bar {@link StatusBarItem item}.
*
* @param id The unique identifier of the item.
* @param alignment The alignment of the item.
* @param priority The priority of the item. Higher values mean the item should be shown more to the left.
* @return A new status bar item.
*/
export function createStatusBarItem(id: string, alignment?: StatusBarAlignment, priority?: number): StatusBarItem;
/**
* Creates a {@link Terminal} with a backing shell process. The cwd of the terminal will be the workspace
* directory if it exists.
*
* @param name Optional human-readable string which will be used to represent the terminal in the UI.
* @param shellPath Optional path to a custom shell executable to be used in the terminal.
* @param shellArgs Optional args for the custom shell executable. A string can be used on Windows only which
* allows specifying shell args in
* [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6).
* @return A new Terminal.
* @throws When running in an environment where a new process cannot be started.
*/
export function createTerminal(name?: string, shellPath?: string, shellArgs?: readonly string[] | string): Terminal;
/**
* Creates a {@link Terminal} with a backing shell process.
*
* @param options A TerminalOptions object describing the characteristics of the new terminal.
* @return A new Terminal.
* @throws When running in an environment where a new process cannot be started.
*/
export function createTerminal(options: TerminalOptions): Terminal;
/**
* Creates a {@link Terminal} where an extension controls its input and output.
*
* @param options An {@link ExtensionTerminalOptions} object describing
* the characteristics of the new terminal.
* @return A new Terminal.
*/
export function createTerminal(options: ExtensionTerminalOptions): Terminal;
/**
* Register a {@link TreeDataProvider} for the view contributed using the extension point `views`.
* This will allow you to contribute data to the {@link TreeView} and update if the data changes.
*
* **Note:** To get access to the {@link TreeView} and perform operations on it, use {@link window.createTreeView createTreeView}.
*
* @param viewId Id of the view contributed using the extension point `views`.
* @param treeDataProvider A {@link TreeDataProvider} that provides tree data for the view
*/
export function registerTreeDataProvider<T>(viewId: string, treeDataProvider: TreeDataProvider<T>): Disposable;
/**
* Create a {@link TreeView} for the view contributed using the extension point `views`.
* @param viewId Id of the view contributed using the extension point `views`.
* @param options Options for creating the {@link TreeView}
* @returns a {@link TreeView}.
*/
export function createTreeView<T>(viewId: string, options: TreeViewOptions<T>): TreeView<T>;
/**
* Registers a {@link UriHandler uri handler} capable of handling system-wide {@link Uri uris}.
* In case there are multiple windows open, the topmost window will handle the uri.
* A uri handler is scoped to the extension it is contributed from; it will only
* be able to handle uris which are directed to the extension itself. A uri must respect
* the following rules:
*
* - The uri-scheme must be `vscode.env.uriScheme`;
* - The uri-authority must be the extension id (e.g. `my.extension`);
* - The uri-path, -query and -fragment parts are arbitrary.
*
* For example, if the `my.extension` extension registers a uri handler, it will only
* be allowed to handle uris with the prefix `product-name://my.extension`.
*
* An extension can only register a single uri handler in its entire activation lifetime.
*
* * *Note:* There is an activation event `onUri` that fires when a uri directed for
* the current extension is about to be handled.
*
* @param handler The uri handler to register for this extension.
*/
export function registerUriHandler(handler: UriHandler): Disposable;
/**
* Registers a webview panel serializer.
*
* Extensions that support reviving should have an `"onWebviewPanel:viewType"` activation event and
* make sure that `registerWebviewPanelSerializer` is called during activation.
*
* Only a single serializer may be registered at a time for a given `viewType`.
*
* @param viewType Type of the webview panel that can be serialized.
* @param serializer Webview serializer.
*/
export function registerWebviewPanelSerializer(viewType: string, serializer: WebviewPanelSerializer): Disposable;
/**
* Register a new provider for webview views.
*
* @param viewId Unique id of the view. This should match the `id` from the
* `views` contribution in the package.json.
* @param provider Provider for the webview views.
*
* @return Disposable that unregisters the provider.
*/
export function registerWebviewViewProvider(viewId: string, provider: WebviewViewProvider, options?: {
/**
* Content settings for the webview created for this view.
*/
readonly webviewOptions?: {
/**
* Controls if the webview element itself (iframe) is kept around even when the view
* is no longer visible.
*
* Normally the webview's html context is created when the view becomes visible
* and destroyed when it is hidden. Extensions that have complex state
* or UI can set the `retainContextWhenHidden` to make the editor keep the webview
* context around, even when the webview moves to a background tab. When a webview using
* `retainContextWhenHidden` becomes hidden, its scripts and other dynamic content are suspended.
* When the view becomes visible again, the context is automatically restored
* in the exact same state it was in originally. You cannot send messages to a
* hidden webview, even with `retainContextWhenHidden` enabled.
*
* `retainContextWhenHidden` has a high memory overhead and should only be used if
* your view's context cannot be quickly saved and restored.
*/
readonly retainContextWhenHidden?: boolean;
};
}): Disposable;
/**
* Register a provider for custom editors for the `viewType` contributed by the `customEditors` extension point.
*
* When a custom editor is opened, an `onCustomEditor:viewType` activation event is fired. Your extension
* must register a {@linkcode CustomTextEditorProvider}, {@linkcode CustomReadonlyEditorProvider},
* {@linkcode CustomEditorProvider}for `viewType` as part of activation.
*
* @param viewType Unique identifier for the custom editor provider. This should match the `viewType` from the
* `customEditors` contribution point.
* @param provider Provider that resolves custom editors.
* @param options Options for the provider.
*
* @return Disposable that unregisters the provider.
*/
export function registerCustomEditorProvider(viewType: string, provider: CustomTextEditorProvider | CustomReadonlyEditorProvider | CustomEditorProvider, options?: {
/**
* Content settings for the webview panels created for this custom editor.
*/
readonly webviewOptions?: WebviewPanelOptions;
/**
* Only applies to `CustomReadonlyEditorProvider | CustomEditorProvider`.
*
* Indicates that the provider allows multiple editor instances to be open at the same time for
* the same resource.
*
* By default, the editor only allows one editor instance to be open at a time for each resource. If the
* user tries to open a second editor instance for the resource, the first one is instead moved to where
* the second one was to be opened.
*
* When `supportsMultipleEditorsPerDocument` is enabled, users can split and create copies of the custom
* editor. In this case, the custom editor must make sure it can properly synchronize the states of all
* editor instances for a resource so that they are consistent.
*/
readonly supportsMultipleEditorsPerDocument?: boolean;
}): Disposable;
/**
* Register provider that enables the detection and handling of links within the terminal.
* @param provider The provider that provides the terminal links.
* @return Disposable that unregisters the provider.
*/
export function registerTerminalLinkProvider(provider: TerminalLinkProvider): Disposable;
/**
* Registers a provider for a contributed terminal profile.
* @param id The ID of the contributed terminal profile.
* @param provider The terminal profile provider.
*/
export function registerTerminalProfileProvider(id: string, provider: TerminalProfileProvider): Disposable;
/**
* Register a file decoration provider.
*
* @param provider A {@link FileDecorationProvider}.
* @return A {@link Disposable} that unregisters the provider.
*/
export function registerFileDecorationProvider(provider: FileDecorationProvider): Disposable;
/**
* The currently active color theme as configured in the settings. The active
* theme can be changed via the `workbench.colorTheme` setting.
*/
export let activeColorTheme: ColorTheme;
/**
* An {@link Event} which fires when the active color theme is changed or has changes.
*/
export const onDidChangeActiveColorTheme: Event<ColorTheme>;
}
/**
* A concrete {@link QuickInput} to let the user pick an item from a
* list of items of type T. The items can be filtered through a filter text field and
* there is an option {@link QuickPick.canSelectMany canSelectMany} to allow for
* selecting multiple items.
*
* Note that in many cases the more convenient {@link window.showQuickPick}
* is easier to use. {@link window.createQuickPick} should be used
* when {@link window.showQuickPick} does not offer the required flexibility.
*/
export interface QuickPick<T extends QuickPickItem> extends QuickInput {
/**
* Current value of the filter text.
*/
value: string;
/**
* Optional placeholder shown in the filter textbox when no filter has been entered.
*/
placeholder: string | undefined;
/**
* An event signaling when the value of the filter text has changed.
*/
readonly onDidChangeValue: Event<string>;
/**
* An event signaling when the user indicated acceptance of the selected item(s).
*/
readonly onDidAccept: Event<void>;
/**
* Buttons for actions in the UI.
*/
buttons: readonly QuickInputButton[];
/**
* An event signaling when a button in the title bar was triggered.
* This event does not fire for buttons on a {@link QuickPickItem}.
*/
readonly onDidTriggerButton: Event<QuickInputButton>;
/**
* An event signaling when a button in a particular {@link QuickPickItem} was triggered.
* This event does not fire for buttons in the title bar.
*/
readonly onDidTriggerItemButton: Event<QuickPickItemButtonEvent<T>>;
/**
* Items to pick from. This can be read and updated by the extension.
*/
items: readonly T[];
/**
* If multiple items can be selected at the same time. Defaults to false.
*/
canSelectMany: boolean;
/**
* If the filter text should also be matched against the description of the items. Defaults to false.
*/
matchOnDescription: boolean;
/**
* If the filter text should also be matched against the detail of the items. Defaults to false.
*/
matchOnDetail: boolean;
/*
* An optional flag to maintain the scroll position of the quick pick when the quick pick items are updated. Defaults to false.
*/
keepScrollPosition?: boolean;
/**
* Active items. This can be read and updated by the extension.
*/
activeItems: readonly T[];
/**
* An event signaling when the active items have changed.
*/
readonly onDidChangeActive: Event<readonly T[]>;
/**
* Selected items. This can be read and updated by the extension.
*/
selectedItems: readonly T[];
/**
* An event signaling when the selected items have changed.
*/
readonly onDidChangeSelection: Event<readonly T[]>;
}
/**
* Represents a tab within a {@link TabGroup group of tabs}.
* Tabs are merely the graphical representation within the editor area.
* A backing editor is not a guarantee.
*/
export interface Tab {
/**
* The text displayed on the tab.
*/
readonly label: string;
/**
* The group which the tab belongs to.
*/
readonly group: TabGroup;
/**
* Defines the structure of the tab i.e. text, notebook, custom, etc.
* Resource and other useful properties are defined on the tab kind.
*/
readonly input: TabInputText | TabInputTextDiff | TabInputCustom | TabInputWebview | TabInputNotebook | TabInputNotebookDiff | TabInputTerminal | unknown;
/**
* Whether or not the tab is currently active.
* This is dictated by being the selected tab in the group.
*/
readonly isActive: boolean;
/**
* Whether or not the dirty indicator is present on the tab.
*/
readonly isDirty: boolean;
/**
* Whether or not the tab is pinned (pin icon is present).
*/
readonly isPinned: boolean;
/**
* Whether or not the tab is in preview mode.
*/
readonly isPreview: boolean;
}
/**
* An event describing change to tabs.
*/
export interface TabChangeEvent {
/**
* The tabs that have been opened.
*/
readonly opened: readonly Tab[];
/**
* The tabs that have been closed.
*/
readonly closed: readonly Tab[];
/**
* Tabs that have changed, e.g have changed
* their {@link Tab.isActive active} state.
*/
readonly changed: readonly Tab[];
}
/**
* 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<T> {
/**
* 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<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
}
검색... 관련한 매서드는 아직 발견 못했다... editor 같은 부분에 포함되어 있을 거라고 생각했는데.
built-in commands 중에 있었으면 제공되는 기능이면 좋겠다... 제발... 검색 기능까지 구현하는 건 너무 스케일이 커질 거 같아서 꺼려진다...
https://code.visualstudio.com/api/references/commands
workbench.action.findInFiles 이거!!!!! 를 찾고 있었는데 드디어 찾았다!!!
search viewlet의 기능을 사용하면 될 거 같다.
일단 여기까지. 빨리 퇴근하고싶다ㅎㅎ