Skip to content

Commit

Permalink
move file decoration API to stable, #54938
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Nov 26, 2020
1 parent 38a200c commit b491231
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 83 deletions.
74 changes: 74 additions & 0 deletions src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5546,6 +5546,72 @@ declare module 'vscode' {
tooltip?: string;
}

/**
* A file decoration represents metadata that can be rendered with a file.
*/
export class FileDecoration {

/**
* A very short string that represents this decoration.
*/
badge?: string;

/**
* A human-readable tooltip for this decoration.
*/
tooltip?: string;

/**
* The color of this decoration.
*/
color?: ThemeColor;

/**
* A flag expressing that this decoration should be
* propagated to its parents.
*/
propagate?: boolean;

/**
* Creates a new decoration.
*
* @param badge A letter that represents the decoration.
* @param tooltip The tooltip of the decoration.
* @param color The color of the decoration.
*/
constructor(badge?: string, tooltip?: string, color?: ThemeColor);
}

/**
* The decoration provider interfaces defines the contract between extensions and
* file decorations.
*/
export interface FileDecorationProvider {

/**
* An optional event to signal that decorations for one or many files have changed.
*
* *Note* that this event should be used to propagate information about children.
*
* @see [EventEmitter](#EventEmitter)
*/
onDidChangeFileDecorations?: Event<undefined | Uri | Uri[]>;

/**
* Provide decorations for a given uri.
*
* *Note* that this function is only called when a file gets rendered in the UI.
* This means a decoration from a descendent that propagates upwards must be signaled
* to the editor via the [onDidChangeFileDecorations](#FileDecorationProvider.onDidChangeFileDecorations)-event.
*
* @param uri The uri of the file to provide a decoration for.
* @param token A cancellation token.
* @returns A decoration or a thenable that resolves to such.
*/
provideFileDecoration(uri: Uri, token: CancellationToken): ProviderResult<FileDecoration>;
}


/**
* In a remote window the extension kind describes if an extension
* runs where the UI (window) runs or if an extension runs remotely.
Expand Down Expand Up @@ -8559,6 +8625,14 @@ declare module 'vscode' {
*/
export function registerTerminalLinkProvider(provider: TerminalLinkProvider): Disposable;

/**
* Register a file decoration provider.
*
* @param provider A [FileDecorationProvider](#FileDecorationProvider).
* @return A [disposable](#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.
Expand Down
82 changes: 0 additions & 82 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -748,88 +748,6 @@ declare module 'vscode' {

//#endregion

//#region file-decorations: https://github.com/microsoft/vscode/issues/54938


/**
* A file decoration represents metadata that can be rendered with a file.
*/
export class FileDecoration {

/**
* A very short string that represents this decoration.
*/
badge?: string;

/**
* A human-readable tooltip for this decoration.
*/
tooltip?: string;

/**
* The color of this decoration.
*/
color?: ThemeColor;

/**
* A flag expressing that this decoration should be
* propagated to its parents.
*/
propagate?: boolean;

/**
* Creates a new decoration.
*
* @param badge A letter that represents the decoration.
* @param tooltip The tooltip of the decoration.
* @param color The color of the decoration.
*/
constructor(badge?: string, tooltip?: string, color?: ThemeColor);
}

/**
* The decoration provider interfaces defines the contract between extensions and
* file decorations.
*/
export interface FileDecorationProvider {

/**
* An optional event to signal that decorations for one or many files have changed.
*
*
* *Note* that this event should be used to propagate information about children.
*
* @see [EventEmitter](#EventEmitter)
*/
onDidChangeFileDecorations?: Event<undefined | Uri | Uri[]>;

/**
* Provide decorations for a given uri.
*
* *Note* that this function is only called when a file gets rendered in the UI.
* This means a decoration from a descendent that propagates upwards must be signaled
* to the editor via the [onDidChangeFileDecorations](#FileDecorationProvider.onDidChangeFileDecorations)-event.
*
* @param uri The uri of the file to provide a decoration for.
* @param token A cancellation token.
* @returns A decoration or a thenable that resolves to such.
*/
provideFileDecoration(uri: Uri, token: CancellationToken): ProviderResult<FileDecoration>;
}

export namespace window {

/**
* Register a file decoration provider.
*
* @param provider A [FileDecorationProvider](#FileDecorationProvider).
* @return A [disposable](#Disposable) that unregisters the provider.
*/
export function registerFileDecorationProvider(provider: FileDecorationProvider): Disposable;
}

//#endregion

//#region debug

/**
Expand Down
1 change: 0 additions & 1 deletion src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostCustomEditors.registerCustomEditorProvider(extension, viewType, provider, options);
},
registerFileDecorationProvider(provider: vscode.FileDecorationProvider) {
checkProposedApiEnabled(extension);
return extHostDecorations.registerFileDecorationProvider(provider, extension.identifier);
},
registerUriHandler(handler: vscode.UriHandler) {
Expand Down

0 comments on commit b491231

Please sign in to comment.