vscode.proposed.d.ts 5.8 KB
Newer Older
1 2 3 4 5 6 7 8 9
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

// This is the place for API experiments and proposal.

declare module 'vscode' {

10
	/**
J
Johannes Rieken 已提交
11
	 * Defines a generalized way of reporing progress updates.
12 13
	 */
	export interface Progress<T> {
J
Johannes Rieken 已提交
14 15 16 17 18 19

		/**
		 * Report a progress update.
		 * @param value A progress item, like a message or an updated percentage value
		 */
		report(value: T): void
20 21
	}

22 23
	export namespace window {

J
Johannes Rieken 已提交
24 25
		/**
		 * Show window-wide progress, e.g. in the status bar, for the provided task. The task is
J
Johannes Rieken 已提交
26
		 * considering running as long as the promise it returned isn't resolved or rejected.
J
Johannes Rieken 已提交
27 28 29
		 *
		 * @param task A function callback that represents a long running operation.
		 */
30
		export function withWindowProgress<R>(title: string, task: (progress: Progress<string>, token: CancellationToken) => Thenable<R>): Thenable<R>;
31

32
		export function withScmProgress<R>(task: (progress: Progress<number>) => Thenable<R>): Thenable<R>;
33

34 35
		export function sampleFunction(): Thenable<any>;
	}
P
Pine Wu 已提交
36

37
	export namespace window {
P
Pine Wu 已提交
38 39 40 41 42 43 44 45 46 47 48 49 50 51

		/**
		 * Register a [TreeExplorerNodeProvider](#TreeExplorerNodeProvider).
		 *
		 * @param providerId A unique id that identifies the provider.
		 * @param provider A [TreeExplorerNodeProvider](#TreeExplorerNodeProvider).
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
		export function registerTreeExplorerNodeProvider(providerId: string, provider: TreeExplorerNodeProvider<any>): Disposable;
	}

	/**
	 * A node provider for a tree explorer contribution.
	 *
P
Pine Wu 已提交
52
	 * Providers are registered through (#window.registerTreeExplorerNodeProvider) with a
P
Pine Wu 已提交
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
	 * `providerId` that corresponds to the `treeExplorerNodeProviderId` in the extension's
	 * `contributes.explorer` section.
	 *
	 * The contributed tree explorer will ask the corresponding provider to provide the root
	 * node and resolve children for each node. In addition, the provider could **optionally**
	 * provide the following information for each node:
	 * - label: A human-readable label used for rendering the node.
	 * - hasChildren: Whether the node has children and is expandable.
	 * - clickCommand: A command to execute when the node is clicked.
	 */
	export interface TreeExplorerNodeProvider<T> {

		/**
		 * Provide the root node. This function will be called when the tree explorer is activated
		 * for the first time. The root node is hidden and its direct children will be displayed on the first level of
		 * the tree explorer.
		 *
		 * @return The root node.
		 */
		provideRootNode(): T | Thenable<T>;

		/**
		 * Resolve the children of `node`.
		 *
		 * @param node The node from which the provider resolves children.
		 * @return Children of `node`.
		 */
		resolveChildren(node: T): T[] | Thenable<T[]>;

		/**
		 * Provide a human-readable string that will be used for rendering the node. Default to use
		 * `node.toString()` if not provided.
		 *
		 * @param node The node from which the provider computes label.
		 * @return A human-readable label.
		 */
		getLabel?(node: T): string;

		/**
		 * Determine if `node` has children and is expandable. Default to `true` if not provided.
		 *
		 * @param node The node to determine if it has children and is expandable.
		 * @return A boolean that determines if `node` has children and is expandable.
		 */
		getHasChildren?(node: T): boolean;

		/**
		 * Get the command to execute when `node` is clicked.
		 *
		 * Commands can be registered through [registerCommand](#commands.registerCommand). `node` will be provided
		 * as the first argument to the command's callback function.
		 *
		 * @param node The node that the command is associated with.
		 * @return The command to execute when `node` is clicked.
		 */
		getClickCommand?(node: T): string;
	}
J
Joao Moreno 已提交
110

J
Joao Moreno 已提交
111
	export interface SCMResourceThemableDecorations {
J
Joao Moreno 已提交
112
		readonly iconPath?: string | Uri;
J
Joao Moreno 已提交
113 114 115
	}

	export interface SCMResourceDecorations extends SCMResourceThemableDecorations {
J
Joao Moreno 已提交
116
		readonly strikeThrough?: boolean;
J
Joao Moreno 已提交
117 118
		readonly light?: SCMResourceThemableDecorations;
		readonly dark?: SCMResourceThemableDecorations;
J
Joao Moreno 已提交
119 120
	}

J
Joao Moreno 已提交
121
	export interface SCMResource {
J
Joao Moreno 已提交
122
		readonly uri: Uri;
J
Joao Moreno 已提交
123
		readonly decorations?: SCMResourceDecorations;
J
Joao Moreno 已提交
124 125
	}

J
Joao Moreno 已提交
126
	export interface SCMResourceGroup {
J
Joao Moreno 已提交
127 128 129
		readonly id: string;
		readonly label: string;
		readonly resources: SCMResource[];
J
Joao Moreno 已提交
130 131 132
	}

	export interface SCMProvider {
J
Joao Moreno 已提交
133 134 135
		readonly label: string;
		readonly resources: SCMResourceGroup[];
		readonly onDidChange: Event<SCMResourceGroup[]>;
J
Joao Moreno 已提交
136
		readonly count?: number | undefined;
J
Joao Moreno 已提交
137
		readonly state?: string;
J
Joao Moreno 已提交
138

J
Joao Moreno 已提交
139
		getOriginalResource?(uri: Uri, token: CancellationToken): ProviderResult<Uri>;
J
Joao Moreno 已提交
140 141
		open?(resource: SCMResource, token: CancellationToken): ProviderResult<void>;
		drag?(resource: SCMResource, resourceGroup: SCMResourceGroup, token: CancellationToken): ProviderResult<void>;
J
Joao Moreno 已提交
142
		acceptChanges?(token: CancellationToken): ProviderResult<void>;
J
Joao Moreno 已提交
143 144
	}

145 146 147 148 149
	export interface SCMInputBox {
		value: string;
		readonly onDidChange: Event<string>;
	}

J
Joao Moreno 已提交
150 151 152
	export namespace scm {
		export const onDidChangeActiveProvider: Event<SCMProvider>;
		export let activeProvider: SCMProvider | undefined;
153 154
		export const inputBox: SCMInputBox;

J
Joao Moreno 已提交
155
		export function getResourceFromURI(uri: Uri): SCMResource | SCMResourceGroup | undefined;
J
Joao Moreno 已提交
156
		export function registerSCMProvider(id: string, provider: SCMProvider): Disposable;
J
Joao Moreno 已提交
157
	}
J
Joao Moreno 已提交
158 159 160 161 162 163 164 165 166

	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

	export function computeDiff(oneDocument: TextDocument, otherDocument: TextDocument): Thenable<LineChange[]>;
P
Pine Wu 已提交
167
}