mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 09:38:38 +01:00
make DecorationData a class and rename it to Decoration, #54938
This commit is contained in:
@@ -890,7 +890,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
WorkspaceEdit: extHostTypes.WorkspaceEdit,
|
||||
// proposed
|
||||
CallHierarchyDirection: extHostTypes.CallHierarchyDirection,
|
||||
CallHierarchyItem: extHostTypes.CallHierarchyItem
|
||||
CallHierarchyItem: extHostTypes.CallHierarchyItem,
|
||||
Decoration: extHostTypes.Decoration
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { MainContext, ExtHostDecorationsShape, MainThreadDecorationsShape, DecorationData, DecorationRequest, DecorationReply } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { Disposable } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { Disposable, Decoration } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
import { asArray } from 'vs/base/common/arrays';
|
||||
@@ -59,12 +59,14 @@ export class ExtHostDecorations implements IExtHostDecorations {
|
||||
}
|
||||
const { provider, extensionId } = entry;
|
||||
return Promise.resolve(provider.provideDecoration(URI.revive(uri), token)).then(data => {
|
||||
if (data && data.letter && data.letter.length !== 1) {
|
||||
console.warn(`INVALID decoration from extension '${extensionId.value}'. The 'letter' must be set and be one character, not '${data.letter}'.`);
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
if (data) {
|
||||
try {
|
||||
Decoration.validate(data);
|
||||
result[id] = <DecorationData>[data.priority, data.bubble, data.title, data.letter, data.color];
|
||||
|
||||
} catch (e) {
|
||||
console.warn(`INVALID decoration from extension '${extensionId.value}': ${e}`);
|
||||
}
|
||||
}, err => {
|
||||
console.error(err);
|
||||
|
||||
@@ -2349,3 +2349,21 @@ export enum ExtensionKind {
|
||||
UI = 1,
|
||||
Workspace = 2
|
||||
}
|
||||
|
||||
export class Decoration {
|
||||
|
||||
static validate(d: Decoration): void {
|
||||
if (d.letter && d.letter.length !== 1) {
|
||||
throw new Error(`The 'letter'-property must be undefined or a single character`);
|
||||
}
|
||||
if (!d.bubble && !d.color && !d.letter && !d.priority && !d.title) {
|
||||
throw new Error(`The decoration is empty`);
|
||||
}
|
||||
}
|
||||
|
||||
letter?: string;
|
||||
title?: string;
|
||||
color?: vscode.ThemeColor;
|
||||
priority?: number;
|
||||
bubble?: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user