From 591a43e8dec1db6fc40741055e6325219eefea60 Mon Sep 17 00:00:00 2001 From: Pine Wu Date: Fri, 17 Jan 2020 17:13:45 +0100 Subject: [PATCH] label2 --- src/vs/editor/common/modes.ts | 11 +++++---- src/vs/monaco.d.ts | 4 ---- src/vs/vscode.d.ts | 2 +- src/vs/vscode.proposed.d.ts | 24 +++++++++++-------- .../api/browser/mainThreadLanguageFeatures.ts | 8 ++----- .../workbench/api/common/extHost.protocol.ts | 6 ++++- .../api/common/extHostLanguageFeatures.ts | 7 ++---- .../api/common/extHostTypeConverters.ts | 4 +++- src/vs/workbench/api/common/extHostTypes.ts | 7 ++++-- 9 files changed, 38 insertions(+), 35 deletions(-) diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index e3e1d21a759..395107e650b 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -376,11 +376,12 @@ export interface CompletionItemLabel { */ name: string; - /** - * A description of the completion item which is rendered - * less prominent. - */ - // description?: string; + // The signature, without the return type. is render directly after `name` + // signature?: string; // parameters + // The fully qualified name, like package name, file path etc + // qualifier?: string; + // The return-type of a function or type of a property, variable etc + // type?: string; /** * Details of the completion item that is rendered less diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 303be1c1479..bd6d736758f 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -5178,10 +5178,6 @@ declare namespace monaco.languages { * The name of this completion item's label. */ name: string; - /** - * A description of the completion item which is rendered - * less prominent. - */ /** * Details of the completion item that is rendered less * prominent to the right. diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 63443b17b31..82a627a207a 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -3360,7 +3360,7 @@ declare module 'vscode' { * this is also the text that is inserted when selecting * this completion. */ - label: string | CompletionItemLabel; + label: string; /** * The kind of this completion item. Based on the kind diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 88404b3e2cd..d25e6a0552a 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1529,23 +1529,27 @@ declare module 'vscode' { //#region https://github.com/microsoft/vscode/issues/39441 + export interface CompletionItem { + /** + * Will be merged into CompletionItem#label + */ + label2?: string | CompletionItemLabel; + } + export interface CompletionItemLabel { /** - * The name of this completion item's label. + * The function or variable */ name: string; - /** - * A description of the completion item which is rendered - * less prominent. - */ - // description?: string; + // The signature, without the return type. is render directly after `name` + // signature?: string; // parameters + // The fully qualified name, like package name, file path etc + // qualifier?: string; + // The return-type of a function or type of a property, variable etc + // type?: string; - /** - * Details of the completion item that is rendered less - * prominent to the right. - */ details?: string; } diff --git a/src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts b/src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts index ced66f0b4ab..11b0645a640 100644 --- a/src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts +++ b/src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts @@ -338,13 +338,9 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha // --- suggest private static _inflateSuggestDto(defaultRange: IRange | { insert: IRange, replace: IRange }, data: ISuggestDataDto): modes.CompletionItem { - const label = data[ISuggestDataDtoField.label]; - const labelText = typeof label === 'string' - ? label - : label.name; return { - label: data[ISuggestDataDtoField.label], + label: data[ISuggestDataDtoField.label2] || data[ISuggestDataDtoField.label], kind: data[ISuggestDataDtoField.kind], tags: data[ISuggestDataDtoField.kindModifier], detail: data[ISuggestDataDtoField.detail], @@ -352,7 +348,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha sortText: data[ISuggestDataDtoField.sortText], filterText: data[ISuggestDataDtoField.filterText], preselect: data[ISuggestDataDtoField.preselect], - insertText: typeof data.h === 'undefined' ? labelText : data.h, + insertText: typeof data.h === 'undefined' ? data[ISuggestDataDtoField.label] : data.h, range: data[ISuggestDataDtoField.range] || defaultRange, insertTextRules: data[ISuggestDataDtoField.insertTextRules], commitCharacters: data[ISuggestDataDtoField.commitCharacters], diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 43a99b0b651..d5f81c3fcf6 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -999,10 +999,14 @@ export const enum ISuggestDataDtoField { additionalTextEdits = 'l', command = 'm', kindModifier = 'n', + + // to merge into label + label2 = 'o', } export interface ISuggestDataDto { - [ISuggestDataDtoField.label]: string | modes.CompletionItemLabel; + [ISuggestDataDtoField.label]: string; + [ISuggestDataDtoField.label2]?: string | modes.CompletionItemLabel; [ISuggestDataDtoField.kind]: modes.CompletionItemKind; [ISuggestDataDtoField.detail]?: string; [ISuggestDataDtoField.documentation]?: string | IMarkdownString; diff --git a/src/vs/workbench/api/common/extHostLanguageFeatures.ts b/src/vs/workbench/api/common/extHostLanguageFeatures.ts index 829e45d79ec..761fe64fc2b 100644 --- a/src/vs/workbench/api/common/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/common/extHostLanguageFeatures.ts @@ -896,11 +896,7 @@ class SuggestAdapter { } private _convertCompletionItem(item: vscode.CompletionItem, position: vscode.Position, id: extHostProtocol.ChainedCacheId): extHostProtocol.ISuggestDataDto | undefined { - const label = typeof item.label === 'string' - ? item.label - : item.label.name; - - if (typeof label !== 'string' || label.length === 0) { + if (typeof item.label !== 'string' || item.label.length === 0) { this._logService.warn('INVALID text edit -> must have at least a label'); return undefined; } @@ -915,6 +911,7 @@ class SuggestAdapter { x: id, // [extHostProtocol.ISuggestDataDtoField.label]: item.label, + [extHostProtocol.ISuggestDataDtoField.label2]: item.label2, [extHostProtocol.ISuggestDataDtoField.kind]: typeConvert.CompletionItemKind.from(item.kind), [extHostProtocol.ISuggestDataDtoField.kindModifier]: item.tags && item.tags.map(typeConvert.CompletionItemTag.from), [extHostProtocol.ISuggestDataDtoField.detail]: item.detail, diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index 6875799dc69..0c4d21337d8 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -832,7 +832,9 @@ export namespace CompletionItemKind { export namespace CompletionItem { export function to(suggestion: modes.CompletionItem, converter?: CommandsConverter): types.CompletionItem { - const result = new types.CompletionItem(suggestion.label); + + const result = new types.CompletionItem(typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name); + result.label2 = suggestion.label; result.insertText = suggestion.insertText; result.kind = CompletionItemKind.to(suggestion.kind); result.tags = suggestion.tags && suggestion.tags.map(CompletionItemTag.to); diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index 62ccd97b595..7e78a66249e 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -1361,7 +1361,8 @@ export interface CompletionItemLabel { @es5ClassCompat export class CompletionItem implements vscode.CompletionItem { - label: string | CompletionItemLabel; + label: string; + label2?: string | CompletionItemLabel; kind?: CompletionItemKind; tags?: CompletionItemTag[]; detail?: string; @@ -1377,14 +1378,16 @@ export class CompletionItem implements vscode.CompletionItem { additionalTextEdits?: TextEdit[]; command?: vscode.Command; - constructor(label: string | CompletionItemLabel, kind?: CompletionItemKind) { + constructor(label: string, kind?: CompletionItemKind) { this.label = label; + this.label2 = { name: label }; this.kind = kind; } toJSON(): any { return { label: this.label, + label2: this.label2, kind: this.kind && CompletionItemKind[this.kind], detail: this.detail, documentation: this.documentation,