mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
Also support MarkdownString in signature help, #11877
This commit is contained in:
@@ -53,7 +53,6 @@ import { TextEditorCursorStyle } from 'vs/editor/common/config/editorOptions';
|
||||
import { ExtHostThreadService } from 'vs/workbench/services/thread/node/extHostThreadService';
|
||||
import { ProxyIdentifier } from 'vs/workbench/services/thread/common/threadService';
|
||||
import { ExtHostDialogs } from 'vs/workbench/api/node/extHostDialogs';
|
||||
import { MarkdownString } from 'vs/base/common/htmlContent';
|
||||
|
||||
export interface IExtensionApiFactory {
|
||||
(extension: IExtensionDescription): typeof vscode;
|
||||
@@ -567,7 +566,7 @@ export function createApiFactory(
|
||||
Hover: extHostTypes.Hover,
|
||||
IndentAction: languageConfiguration.IndentAction,
|
||||
Location: extHostTypes.Location,
|
||||
MarkdownString: MarkdownString,
|
||||
MarkdownString: extHostTypes.MarkdownString,
|
||||
OverviewRulerLane: EditorCommon.OverviewRulerLane,
|
||||
ParameterInformation: extHostTypes.ParameterInformation,
|
||||
Position: extHostTypes.Position,
|
||||
|
||||
@@ -354,7 +354,7 @@ export namespace Suggest {
|
||||
result.insertText = suggestion.insertText;
|
||||
result.kind = CompletionItemKind.to(suggestion.type);
|
||||
result.detail = suggestion.detail;
|
||||
result.documentation = typeof suggestion.documentation === 'string' ? suggestion.documentation : MarkdownString.to(suggestion.documentation);
|
||||
result.documentation = htmlContent.isMarkdownString(suggestion.documentation) ? MarkdownString.to(suggestion.documentation) : suggestion.documentation;
|
||||
result.sortText = suggestion.sortText;
|
||||
result.filterText = suggestion.filterText;
|
||||
|
||||
@@ -381,14 +381,56 @@ export namespace Suggest {
|
||||
}
|
||||
};
|
||||
|
||||
export namespace SignatureHelp {
|
||||
export namespace ParameterInformation {
|
||||
export function from(info: types.ParameterInformation): modes.ParameterInformation {
|
||||
return {
|
||||
label: info.label,
|
||||
documentation: info.documentation && MarkdownString.from(info.documentation)
|
||||
};
|
||||
}
|
||||
export function to(info: modes.ParameterInformation): types.ParameterInformation {
|
||||
return {
|
||||
label: info.label,
|
||||
documentation: htmlContent.isMarkdownString(info.documentation) ? MarkdownString.to(info.documentation) : info.documentation
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function from(signatureHelp: types.SignatureHelp): modes.SignatureHelp {
|
||||
return signatureHelp;
|
||||
export namespace SignatureInformation {
|
||||
|
||||
export function from(info: types.SignatureInformation): modes.SignatureInformation {
|
||||
return {
|
||||
label: info.label,
|
||||
documentation: info.documentation && MarkdownString.from(info.documentation),
|
||||
parameters: info.parameters && info.parameters.map(ParameterInformation.from)
|
||||
};
|
||||
}
|
||||
|
||||
export function to(hints: modes.SignatureHelp): types.SignatureHelp {
|
||||
return hints;
|
||||
export function to(info: modes.SignatureInformation): types.SignatureInformation {
|
||||
return {
|
||||
label: info.label,
|
||||
documentation: htmlContent.isMarkdownString(info.documentation) ? MarkdownString.to(info.documentation) : info.documentation,
|
||||
parameters: info.parameters && info.parameters.map(ParameterInformation.to)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export namespace SignatureHelp {
|
||||
|
||||
export function from(help: types.SignatureHelp): modes.SignatureHelp {
|
||||
return {
|
||||
activeSignature: help.activeSignature,
|
||||
activeParameter: help.activeParameter,
|
||||
signatures: help.signatures && help.signatures.map(SignatureInformation.from)
|
||||
};
|
||||
}
|
||||
|
||||
export function to(help: modes.SignatureHelp): types.SignatureHelp {
|
||||
return {
|
||||
activeSignature: help.activeSignature,
|
||||
activeParameter: help.activeParameter,
|
||||
signatures: help.signatures && help.signatures.map(SignatureInformation.to)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -824,12 +824,33 @@ export class CodeLens {
|
||||
}
|
||||
}
|
||||
|
||||
export class MarkdownString {
|
||||
|
||||
value: string;
|
||||
isTrusted?: boolean;
|
||||
|
||||
constructor(value?: string) {
|
||||
this.value = value || '';
|
||||
}
|
||||
|
||||
appendText(value: string): MarkdownString {
|
||||
// escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
|
||||
this.value += value.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&');
|
||||
return this;
|
||||
}
|
||||
|
||||
appendMarkdown(value: string): MarkdownString {
|
||||
this.value += value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
export class ParameterInformation {
|
||||
|
||||
label: string;
|
||||
documentation?: string;
|
||||
documentation?: string | MarkdownString;
|
||||
|
||||
constructor(label: string, documentation?: string) {
|
||||
constructor(label: string, documentation?: string | MarkdownString) {
|
||||
this.label = label;
|
||||
this.documentation = documentation;
|
||||
}
|
||||
@@ -838,10 +859,10 @@ export class ParameterInformation {
|
||||
export class SignatureInformation {
|
||||
|
||||
label: string;
|
||||
documentation?: string;
|
||||
documentation?: string | MarkdownString;
|
||||
parameters: ParameterInformation[];
|
||||
|
||||
constructor(label: string, documentation?: string) {
|
||||
constructor(label: string, documentation?: string | MarkdownString) {
|
||||
this.label = label;
|
||||
this.documentation = documentation;
|
||||
this.parameters = [];
|
||||
@@ -892,7 +913,7 @@ export class CompletionItem {
|
||||
label: string;
|
||||
kind: CompletionItemKind;
|
||||
detail: string;
|
||||
documentation: string | vscode.MarkdownString;
|
||||
documentation: string | MarkdownString;
|
||||
sortText: string;
|
||||
filterText: string;
|
||||
insertText: string | SnippetString;
|
||||
|
||||
Reference in New Issue
Block a user