diff --git a/tree-view-sample/src/ftpExplorer.fileSystemProvider.ts b/tree-view-sample/src/ftpExplorer.fileSystemProvider.ts index 5c0717ea..af742376 100644 --- a/tree-view-sample/src/ftpExplorer.fileSystemProvider.ts +++ b/tree-view-sample/src/ftpExplorer.fileSystemProvider.ts @@ -251,7 +251,7 @@ export class FtpExplorer { const treeDataProvider = new FtpTreeDataProvider(fileProvider); context.subscriptions.push(vscode.workspace.registerFileSystemProvider('ftp', fileProvider)); - this.ftpViewer = vscode.window.registerTreeDataProvider('ftpExplorer', treeDataProvider); + this.ftpViewer = vscode.window.createTreeView('ftpExplorer', { treeDataProvider }); vscode.commands.registerCommand('ftpExplorer.refresh', () => treeDataProvider.refresh()); vscode.commands.registerCommand('ftpExplorer.openFtpResource', resource => this.openResource(resource)); diff --git a/tree-view-sample/src/ftpExplorer.textDocumentContentProvider.ts b/tree-view-sample/src/ftpExplorer.textDocumentContentProvider.ts index f3ece297..b33167d8 100644 --- a/tree-view-sample/src/ftpExplorer.textDocumentContentProvider.ts +++ b/tree-view-sample/src/ftpExplorer.textDocumentContentProvider.ts @@ -164,7 +164,7 @@ export class FtpExplorer { const treeDataProvider = new FtpTreeDataProvider(ftpModel); context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider('ftp', treeDataProvider)); - this.ftpViewer = vscode.window.registerTreeDataProvider('ftpExplorer', treeDataProvider); + this.ftpViewer = vscode.window.createTreeView('ftpExplorer', { treeDataProvider }); vscode.commands.registerCommand('ftpExplorer.refresh', () => treeDataProvider.refresh()); vscode.commands.registerCommand('ftpExplorer.openFtpResource', resource => this.openResource(resource)); diff --git a/tree-view-sample/vscode.proposed.d.ts b/tree-view-sample/vscode.proposed.d.ts index b6f93ca0..28b6923f 100644 --- a/tree-view-sample/vscode.proposed.d.ts +++ b/tree-view-sample/vscode.proposed.d.ts @@ -1,5 +1,3 @@ -import { ProviderResult } from "vscode"; - /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. @@ -9,6 +7,38 @@ import { ProviderResult } from "vscode"; declare module 'vscode' { + export namespace window { + export function sampleFunction(): Thenable; + } + + //#region Joh: readable diagnostics + + export interface DiagnosticChangeEvent { + uris: Uri[]; + } + + export namespace languages { + + /** + * + */ + export const onDidChangeDiagnostics: Event; + + /** + * + */ + export function getDiagnostics(resource: Uri): Diagnostic[]; + + /** + * + */ + export function getDiagnostics(): [Uri, Diagnostic[]][]; + } + + //#endregion + + //#region Aeschli: folding + export class FoldingRangeList { /** @@ -28,12 +58,12 @@ declare module 'vscode' { export class FoldingRange { /** - * The start line number (0-based) + * The start line number (zero-based) of the range to fold. The hidden area starts after the last character of that line. */ startLine: number; /** - * The end line number (0-based) + * The end line number (0-based) of the range to fold. The hidden area ends at the last character of that line. */ endLine: number; @@ -48,7 +78,7 @@ declare module 'vscode' { * @param startLineNumber The first line of the fold * @param type The last line of the fold */ - constructor(startLineNumber: number, endLineNumber: number, type?: FoldingRangeType); + constructor(startLineNumber: number, endLineNumber: number, type?: FoldingRangeType | string); } export enum FoldingRangeType { @@ -66,6 +96,37 @@ declare module 'vscode' { Region = 'region' } + export namespace languages { + + /** + * Register a folding provider. + * + * Multiple folding can be registered for a language. In that case providers are sorted + * by their [score](#languages.match) and the best-matching provider is used. Failure + * of the selected provider will cause a failure of the whole operation. + * + * @param selector A selector that defines the documents this provider is applicable to. + * @param provider A folding provider. + * @return A [disposable](#Disposable) that unregisters this provider when being disposed. + */ + export function registerFoldingProvider(selector: DocumentSelector, provider: FoldingProvider): Disposable; + } + + export interface FoldingContext { + maxRanges?: number; + } + + export interface FoldingProvider { + /** + * Returns a list of folding ranges or null if the provider does not want to participate or was cancelled. + */ + provideFoldingRanges(document: TextDocument, context: FoldingContext, token: CancellationToken): ProviderResult; + } + + //#endregion + + //#region Joh: file system provider + // export enum FileErrorCodes { // /** // * Not owner. @@ -142,24 +203,6 @@ declare module 'vscode' { type: FileType; } - export interface TextSearchQuery { - pattern: string; - isRegex?: boolean; - isCaseSensitive?: boolean; - isWordMatch?: boolean; - } - - export interface TextSearchOptions { - includes: GlobPattern[]; - excludes: GlobPattern[]; - } - - export interface TextSearchResult { - uri: Uri; - range: Range; - preview: { leading: string, matching: string, trailing: string }; - } - // todo@joh discover files etc // todo@joh CancellationToken everywhere // todo@joh add open/close calls? @@ -167,9 +210,6 @@ declare module 'vscode' { readonly onDidChange?: Event; - // todo@joh - remove this - readonly root?: Uri; - // more... // utimes(resource: Uri, mtime: number, atime: number): Thenable; @@ -207,65 +247,47 @@ declare module 'vscode' { // todo@remote // create(resource: Uri): Thenable; - - // find files by names - // todo@joh, move into its own provider - findFiles?(query: string, progress: Progress, token: CancellationToken): Thenable; - provideTextSearchResults?(query: TextSearchQuery, options: TextSearchOptions, progress: Progress, token: CancellationToken): Thenable; } export namespace workspace { export function registerFileSystemProvider(scheme: string, provider: FileSystemProvider): Disposable; - - /** - * This method replaces `deleteCount` [workspace folders](#workspace.workspaceFolders) starting at index `start` - * by an optional set of `workspaceFoldersToAdd` on the `vscode.workspace.workspaceFolders` array. This "splice" - * behavior can be used to add, remove and change workspace folders in a single operation. - * - * If the first workspace folder is added, removed or changed, the currently executing extensions (including the - * one that called this method) will be terminated and restarted so that the (deprecated) `rootPath` property is - * updated to point to the first workspace folder. - * - * Use the [`onDidChangeWorkspaceFolders()`](#onDidChangeWorkspaceFolders) event to get notified when the - * workspace folders have been updated. - * - * **Example:** adding a new workspace folder at the end of workspace folders - * ```typescript - * workspace.updateWorkspaceFolders(workspace.workspaceFolders ? workspace.workspaceFolders.length : 0, null, { uri: ...}); - * ``` - * - * **Example:** removing the first workspace folder - * ```typescript - * workspace.updateWorkspaceFolders(0, 1); - * ``` - * - * **Example:** replacing an existing workspace folder with a new one - * ```typescript - * workspace.updateWorkspaceFolders(0, 1, { uri: ...}); - * ``` - * - * It is valid to remove an existing workspace folder and add it again with a different name - * to rename that folder. - * - * **Note:** it is not valid to call [updateWorkspaceFolders()](#updateWorkspaceFolders) multiple times - * without waiting for the [`onDidChangeWorkspaceFolders()`](#onDidChangeWorkspaceFolders) to fire. - * - * @param start the zero-based location in the list of currently opened [workspace folders](#WorkspaceFolder) - * from which to start deleting workspace folders. - * @param deleteCount the optional number of workspace folders to remove. - * @param workspaceFoldersToAdd the optional variable set of workspace folders to add in place of the deleted ones. - * Each workspace is identified with a mandatory URI and an optional name. - * @return true if the operation was successfully started and false otherwise if arguments were used that would result - * in invalid workspace folder state (e.g. 2 folders with the same URI). - */ - export function updateWorkspaceFolders(start: number, deleteCount: number, ...workspaceFoldersToAdd: { uri: Uri, name?: string }[]): boolean; } - export namespace window { + //#endregion - export function sampleFunction(): Thenable; + //#region Joh: remote, search provider + + export interface TextSearchQuery { + pattern: string; + isRegExp?: boolean; + isCaseSensitive?: boolean; + isWordMatch?: boolean; } + export interface TextSearchOptions { + includes: GlobPattern[]; + excludes: GlobPattern[]; + } + + export interface TextSearchResult { + uri: Uri; + range: Range; + preview: { leading: string, matching: string, trailing: string }; + } + + export interface SearchProvider { + provideFileSearchResults?(query: string, progress: Progress, token: CancellationToken): Thenable; + provideTextSearchResults?(query: TextSearchQuery, options: TextSearchOptions, progress: Progress, token: CancellationToken): Thenable; + } + + export namespace workspace { + export function registerSearchProvider(scheme: string, provider: SearchProvider): Disposable; + } + + //#endregion + + //#region Joao: diff command + /** * The contiguous set of modified lines in a diff. */ @@ -295,7 +317,9 @@ declare module 'vscode' { export function registerDiffInformationCommand(command: string, callback: (diff: LineChange[], ...args: any[]) => any, thisArg?: any): Disposable; } - //#region decorations + //#endregion + + //#region Joh: decorations //todo@joh -> make class export interface DecorationData { @@ -324,6 +348,8 @@ declare module 'vscode' { //#endregion + //#region André: debug + /** * Represents a debug adapter executable and optional arguments passed to it. */ @@ -357,6 +383,10 @@ declare module 'vscode' { debugAdapterExecutable?(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult; } + //#endregion + + //#region Rob, Matt: logging + /** * The severity level of a log message */ @@ -374,10 +404,6 @@ declare module 'vscode' { * A logger for writing to an extension's log file, and accessing its dedicated log directory. */ export interface Logger { - readonly onDidChangeLogLevel: Event; - readonly currentLevel: LogLevel; - readonly logDirectory: Thenable; - trace(message: string, ...args: any[]): void; debug(message: string, ...args: any[]): void; info(message: string, ...args: any[]): void; @@ -391,36 +417,53 @@ declare module 'vscode' { * This extension's logger */ logger: Logger; - } - - export interface RenameInitialValue { - range: Range; - text?: string; - } - - export namespace languages { /** - * Register a folding provider. + * Path where an extension can write log files. * - * Multiple folding can be registered for a language. In that case providers are sorted - * by their [score](#languages.match) and the best-matching provider is used. Failure - * of the selected provider will cause a failure of the whole operation. - * - * @param selector A selector that defines the documents this provider is applicable to. - * @param provider A folding provider. - * @return A [disposable](#Disposable) that unregisters this provider when being disposed. + * Extensions must create this directory before writing to it. The parent directory will always exist. */ - export function registerFoldingProvider(selector: DocumentSelector, provider: FoldingProvider): Disposable; + readonly logDirectory: string; + } - export interface RenameProvider2 extends RenameProvider { - resolveInitialRenameValue?(document: TextDocument, position: Position, token: CancellationToken): ProviderResult; - } + export namespace env { + /** + * Current logging level. + * + * @readonly + */ + export const logLevel: LogLevel; } - export interface FoldingProvider { - provideFoldingRanges(document: TextDocument, token: CancellationToken): ProviderResult; + + //#endregion + + //#region Joh: rename context + + export interface RenameContext { + range?: Range; + newName?: string; + message?: string; } + export interface RenameProvider2 extends RenameProvider { + + /** + * Optional function for resolving and validating a position at which rename is + * being carried out. + * + * @param document The document in which rename will be invoked. + * @param position The position at which rename will be invoked. + * @param token A cancellation token. + * @return A `RenameContext` with more information. The lack of a result can signaled by returning `undefined` or `null`. + */ + resolveRenameLocation?(document: TextDocument, position: Position, token: CancellationToken): ProviderResult; + + } + + //#endregion + + //#region Joao: SCM validation + /** * Represents the validation type of the Source Control input. */ @@ -467,6 +510,10 @@ declare module 'vscode' { validateInput?(value: string, cursorPosition: number): ProviderResult; } + //#endregion + + //#region Matt: WebView + /** * Content settings for a webview. */ @@ -486,49 +533,68 @@ declare module 'vscode' { readonly enableCommandUris?: boolean; /** - * Should the webview content be kept arount even when the webview is no longer visible? + * Should the find widget be enabled in the webview? * - * Normally a webview content is created when the webview becomes visible - * and destroyed when the webview is hidden. Apps that have complex state - * or UI can set the `keepAlive` property to make VS Code keep the webview - * content around, even when the webview itself is no longer visible. When - * the webview becomes visible again, the content is automatically restored - * in the exact same state it was in originally - * - * `keepAlive` has a high memory overhead and should only be used if your - * webview content cannot be quickly saved and restored. + * Defaults to false. */ - readonly keepAlive?: boolean; + readonly enableFindWidget?: boolean; /** - * Root paths from which the webview can load local (filesystem) resources using the `vscode-workspace-resource:` scheme. + * Should the webview's context be kept around even when the webview is no longer visible? * - * Default to the root folders of the current workspace. + * Normally a webview's context is created when the webview becomes visible + * and destroyed when the webview is hidden. Apps that have complex state + * or UI can set the `retainContextWhenHidden` to make VS Code keep the webview + * context around, even when the webview moves to a background tab. When + * the webview becomes visible again, the context is automatically restored + * in the exact same state it was in originally. + * + * `retainContextWhenHidden` has a high memory overhead and should only be used if + * your webview's context cannot be quickly saved and restored. + */ + readonly retainContextWhenHidden?: boolean; + + /** + * Root paths from which the webview can load local (filesystem) resources using the `vscode-resource:` scheme. + * + * Default to the root folders of the current workspace plus the extension's install directory. * * Pass in an empty array to disallow access to any local resources. */ readonly localResourceRoots?: Uri[]; } + export interface WebViewOnDidChangeViewStateEvent { + readonly viewColumn: ViewColumn; + readonly active: boolean; + } + /** - * A webview is an editor with html content, like an iframe. + * A webview displays html content, like an iframe. */ export interface Webview { /** - * Title of the webview. + * The type of the webview, such as `'markdownw.preview'` + */ + readonly viewType: string; + + /** + * Content settings for the webview. + */ + readonly options: WebviewOptions; + + /** + * Title of the webview shown in UI. */ title: string; /** * Contents of the webview. + * + * Should be a complete html document. */ html: string; - /** - * Content settings for the webview. - */ - options: WebviewOptions; - /** * The column in which the webview is showing. */ @@ -537,17 +603,17 @@ declare module 'vscode' { /** * Fired when the webview content posts a message. */ - readonly onMessage: Event; + readonly onDidReceiveMessage: Event; /** - * Fired when the webview becomes the active editor. + * Fired when the webview is disposed. */ - readonly onBecameActive: Event; + readonly onDidDispose: Event; /** - * Fired when the webview stops being the active editor + * Fired when the webview's view state changes. */ - readonly onBecameInactive: Event; + readonly onDidChangeViewState: Event; /** * Post a message to the webview content. @@ -556,10 +622,22 @@ declare module 'vscode' { * * @param message Body of the message. */ - postMessage(message: any): Thenable; + postMessage(message: any): Thenable; /** - * Dispose the webview. + * Shows the webview in a given column. + * + * A webview may only be in a single column at a time. If it is already showing, this + * command moves it to a new column. + */ + reveal(viewColumn: ViewColumn): void; + + /** + * Dispose of the the webview. + * + * This closes the webview if it showing and disposes of the resources owned by the webview. + * Webview are also disposed when the user closes the webview editor. Both cases fire `onDispose` + * event. Trying to use the webview after it has been disposed throws an exception. */ dispose(): any; } @@ -568,75 +646,112 @@ declare module 'vscode' { /** * Create and show a new webview. * + * @param viewType Identifier the type of the webview. * @param title Title of the webview. * @param column Editor column to show the new webview in. - * @param options Webview content options. + * @param options Content settings for the webview. */ - export function createWebview(title: string, column: ViewColumn, options: WebviewOptions): Webview; + export function createWebview(viewType: string, title: string, column: ViewColumn, options: WebviewOptions): Webview; + } + + //#endregion + + //#region Alex: TextEditor.visibleRange and related event + + export interface TextEditor { + /** + * The current visible ranges in the editor (vertically). + * This accounts only for vertical scrolling, and not for horizontal scrolling. + */ + readonly visibleRanges: Range[]; + } + + /** + * Represents an event describing the change in a [text editor's visible ranges](#TextEditor.visibleRanges). + */ + export interface TextEditorVisibleRangesChangeEvent { + /** + * The [text editor](#TextEditor) for which the visible ranges have changed. + */ + textEditor: TextEditor; + /** + * The new value for the [text editor's visible ranges](#TextEditor.visibleRanges). + */ + visibleRanges: Range[]; } export namespace window { - /** - * Register a [TreeDataProvider](#TreeDataProvider) for the view contributed using the extension point `views`. - * @param viewId Id of the view contributed using the extension point `views`. - * @param treeDataProvider A [TreeDataProvider](#TreeDataProvider) that provides tree data for the view - * @return handle to the [treeview](#TreeView) that can be disposable. + * An [event](#Event) which fires when the selection in an editor has changed. */ - export function registerTreeDataProvider(viewId: string, treeDataProvider: TreeDataProvider): TreeView; + export const onDidChangeTextEditorVisibleRanges: Event; + } + //#endregion + + //#region Tasks + + /** + * An object representing an executed Task. It can be used + * to terminate a task. + */ + export interface TaskExecution { } /** - * Represents a Tree view + * An event signaling the start of a task execution. */ - export interface TreeView extends Disposable { - + interface TaskStartEvent { /** - * Reveal an element. By default revealed element is selected. - * - * In order to not to select, set the option `donotSelect` to `true`. + * The task item representing the task that got started. */ - reveal(element: T, options?: { donotSelect?: boolean }): Thenable; + execution: TaskExecution; } /** - * A data provider that provides tree data + * An event signaling the end of an executed task. */ - export interface TreeDataProvider { + interface TaskEndEvent { /** - * An optional event to signal that an element or root has changed. - * This will trigger the view to update the changed element/root and its children recursively (if shown). - * To signal that root has changed, do not pass any argument or pass `undefined` or `null`. + * The task item representing the task that finished. */ - onDidChangeTreeData?: Event; - - /** - * Get [TreeItem](#TreeItem) representation of the `element` - * - * @param element The element for which [TreeItem](#TreeItem) representation is asked for. - * @return [TreeItem](#TreeItem) representation of the element - */ - getTreeItem(element: T): TreeItem | Thenable; - - /** - * Get the children of `element` or root if no element is passed. - * - * @param element The element from which the provider gets children. Can be `undefined`. - * @return Children of `element` or root if no element is passed. - */ - getChildren(element?: T): ProviderResult; - - /** - * Optional method to return the parent of `element`. - * Return `null` or `undefined` if `element` is a child of root. - * - * **NOTE:** This method should be implemented in order to use [TreeVie](#TreeView) API. - * - * @param element The element for which the parent has to be returned. - * @return Parent of `element`. - */ - getParent?(element: T): ProviderResult; - + execution: TaskExecution; } -} \ No newline at end of file + + export namespace workspace { + + /** + * Fetches all task available in the systems. This includes tasks + * from `tasks.json` files as well as tasks from task providers + * contributed through extensions. + */ + export function fetchTasks(): Thenable; + + /** + * Executes a task that is managed by VS Code. The returned + * task execution can be used to terminate the task. + * + * @param task the task to execute + */ + export function executeTask(task: Task): Thenable; + + /** + * Fires when a task starts. + */ + export const onDidStartTask: Event; + + /** + * Terminates a task that was previously started using `executeTask` + * + * @param task the task to terminate + */ + export function terminateTask(task: TaskExecution): void; + + /** + * Fires when a task ends. + */ + export const onDidEndTask: Event; + } + + //#endregion +}