Skip to content

Commit be76e31

Browse files
committed
microsoft#26948 Publish tree api
1 parent 038703d commit be76e31

2 files changed

Lines changed: 100 additions & 102 deletions

File tree

src/vs/vscode.d.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4007,6 +4007,106 @@ declare module 'vscode' {
40074007
* @return A new Terminal.
40084008
*/
40094009
export function createTerminal(options: TerminalOptions): Terminal;
4010+
4011+
/**
4012+
* Register a [TreeDataProvider](#TreeDataProvider) for the view contributed using the extension point `views`.
4013+
* @param viewId Id of the view contributed using the extension point `views`.
4014+
* @param treeDataProvider A [TreeDataProvider](#TreeDataProvider) that provides tree data for the view
4015+
*/
4016+
export function registerTreeDataProvider<T>(viewId: string, treeDataProvider: TreeDataProvider<T>): Disposable;
4017+
}
4018+
4019+
/**
4020+
* A data provider that provides tree data
4021+
*/
4022+
export interface TreeDataProvider<T> {
4023+
/**
4024+
* An optional event to signal that an element or root has changed.
4025+
* To signal that root has changed, do not pass any argument or pass `undefined` or `null`.
4026+
*/
4027+
onDidChangeTreeData?: Event<T | undefined | null>;
4028+
4029+
/**
4030+
* Get [TreeItem](#TreeItem) representation of the `element`
4031+
*
4032+
* @param element The element for which [TreeItem](#TreeItem) representation is asked for.
4033+
* @return [TreeItem](#TreeItem) representation of the element
4034+
*/
4035+
getTreeItem(element: T): TreeItem | Thenable<TreeItem>;
4036+
4037+
/**
4038+
* Get the children of `element` or root if no element is passed.
4039+
*
4040+
* @param element The element from which the provider gets children. Can be `undefined`.
4041+
* @return Children of `element` or root if no element is passed.
4042+
*/
4043+
getChildren(element?: T): ProviderResult<T[]>;
4044+
}
4045+
4046+
export class TreeItem {
4047+
/**
4048+
* A human-readable string describing this item
4049+
*/
4050+
label: string;
4051+
4052+
/**
4053+
* The icon path for the tree item
4054+
*/
4055+
iconPath?: string | Uri | { light: string | Uri; dark: string | Uri };
4056+
4057+
/**
4058+
* The [command](#Command) which should be run when the tree item is selected.
4059+
*/
4060+
command?: Command;
4061+
4062+
/**
4063+
* [TreeItemCollapsibleState](#TreeItemCollapsibleState) of the tree item.
4064+
*/
4065+
collapsibleState?: TreeItemCollapsibleState;
4066+
4067+
/**
4068+
* Context value of the tree item. This can be used to contribute item specific actions in the tree.
4069+
* For example, a tree item is given a context value as `folder`. When contributing actions to `view/item/context`
4070+
* using `menus` extension point, you can specify context value for key `viewItem` in `when` expression like `viewItem == folder`.
4071+
* ```
4072+
* "contributes": {
4073+
* "menus": {
4074+
* "view/item/context": [
4075+
* {
4076+
* "command": "extension.deleteFolder",
4077+
* "when": "viewItem == folder"
4078+
* }
4079+
* ]
4080+
* }
4081+
* }
4082+
* ```
4083+
* This will show action `extension.deleteFolder` only for items with `contextValue` is `folder`.
4084+
*/
4085+
contextValue?: string;
4086+
4087+
/**
4088+
* @param label A human-readable string describing this item
4089+
* @param collapsibleState [TreeItemCollapsibleState](#TreeItemCollapsibleState) of the tree item. Default is [TreeItemCollapsibleState.None](#TreeItemCollapsibleState.None)
4090+
*/
4091+
constructor(label: string, collapsibleState?: TreeItemCollapsibleState);
4092+
}
4093+
4094+
/**
4095+
* Collapsible state of the tree item
4096+
*/
4097+
export enum TreeItemCollapsibleState {
4098+
/**
4099+
* Determines an item can be neither collapsed nor expanded. Implies it has no children.
4100+
*/
4101+
None = 0,
4102+
/**
4103+
* Determines an item is collapsed
4104+
*/
4105+
Collapsed = 1,
4106+
/**
4107+
* Determines an item is expanded
4108+
*/
4109+
Expanded = 2
40104110
}
40114111

40124112
/**

src/vs/vscode.proposed.d.ts

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -341,108 +341,6 @@ declare module 'vscode' {
341341
export function sampleFunction(): Thenable<any>;
342342
}
343343

344-
export namespace window {
345-
/**
346-
* Register a [TreeDataProvider](#TreeDataProvider) for the view contributed using the extension point `views`.
347-
* @param viewId Id of the view contributed using the extension point `views`.
348-
* @param treeDataProvider A [TreeDataProvider](#TreeDataProvider) that provides tree data for the view
349-
*/
350-
export function registerTreeDataProvider<T>(viewId: string, treeDataProvider: TreeDataProvider<T>): Disposable;
351-
}
352-
353-
/**
354-
* A data provider that provides tree data
355-
*/
356-
export interface TreeDataProvider<T> {
357-
/**
358-
* An optional event to signal that an element or root has changed.
359-
* To signal that root has changed, do not pass any argument or pass `undefined` or `null`.
360-
*/
361-
onDidChangeTreeData?: Event<T | undefined | null>;
362-
363-
/**
364-
* Get [TreeItem](#TreeItem) representation of the `element`
365-
*
366-
* @param element The element for which [TreeItem](#TreeItem) representation is asked for.
367-
* @return [TreeItem](#TreeItem) representation of the element
368-
*/
369-
getTreeItem(element: T): TreeItem | Thenable<TreeItem>;
370-
371-
/**
372-
* Get the children of `element` or root if no element is passed.
373-
*
374-
* @param element The element from which the provider gets children. Can be `undefined`.
375-
* @return Children of `element` or root if no element is passed.
376-
*/
377-
getChildren(element?: T): ProviderResult<T[]>;
378-
}
379-
380-
export class TreeItem {
381-
/**
382-
* A human-readable string describing this item
383-
*/
384-
label: string;
385-
386-
/**
387-
* The icon path for the tree item
388-
*/
389-
iconPath?: string | Uri | { light: string | Uri; dark: string | Uri };
390-
391-
/**
392-
* The [command](#Command) which should be run when the tree item is selected.
393-
*/
394-
command?: Command;
395-
396-
/**
397-
* [TreeItemCollapsibleState](#TreeItemCollapsibleState) of the tree item.
398-
*/
399-
collapsibleState?: TreeItemCollapsibleState;
400-
401-
/**
402-
* Context value of the tree item. This can be used to contribute item specific actions in the tree.
403-
* For example, a tree item is given a context value as `folder`. When contributing actions to `view/item/context`
404-
* using `menus` extension point, you can specify context value for key `viewItem` in `when` expression like `viewItem == folder`.
405-
* ```
406-
* "contributes": {
407-
* "menus": {
408-
* "view/item/context": [
409-
* {
410-
* "command": "extension.deleteFolder",
411-
* "when": "viewItem == folder"
412-
* }
413-
* ]
414-
* }
415-
* }
416-
* ```
417-
* This will show action `extension.deleteFolder` only for items with `contextValue` is `folder`.
418-
*/
419-
contextValue?: string;
420-
421-
/**
422-
* @param label A human-readable string describing this item
423-
* @param collapsibleState [TreeItemCollapsibleState](#TreeItemCollapsibleState) of the tree item. Default is [TreeItemCollapsibleState.None](#TreeItemCollapsibleState.None)
424-
*/
425-
constructor(label: string, collapsibleState?: TreeItemCollapsibleState);
426-
}
427-
428-
/**
429-
* Collapsible state of the tree item
430-
*/
431-
export enum TreeItemCollapsibleState {
432-
/**
433-
* Determines an item can be neither collapsed nor expanded. Implies it has no children.
434-
*/
435-
None = 0,
436-
/**
437-
* Determines an item is collapsed
438-
*/
439-
Collapsed = 1,
440-
/**
441-
* Determines an item is expanded
442-
*/
443-
Expanded = 2
444-
}
445-
446344
/**
447345
* The contiguous set of modified lines in a diff.
448346
*/

0 commit comments

Comments
 (0)