This commit is contained in:
Johannes Rieken
2018-09-10 17:27:52 +02:00
parent 74b096b6be
commit 01d594a82d
6 changed files with 62 additions and 17 deletions

View File

@@ -112,7 +112,7 @@ export class ExtHostApiCommands {
args: [
{ name: 'uri', description: 'Uri of a text document', constraint: URI }
],
returns: 'A promise that resolves to an array of SymbolInformation-instances.'
returns: 'A promise that resolves to an array of SymbolInformation and DocumentSymbol instances.'
});
this._register('vscode.executeCompletionItemProvider', this._executeCompletionItemProvider, {
description: 'Execute completion item provider.',
@@ -420,16 +420,27 @@ export class ExtHostApiCommands {
if (isFalsyOrEmpty(value)) {
return undefined;
}
let result: vscode.SymbolInformation[] = [];
for (const symbol of value) {
result.push(new types.SymbolInformation(
symbol.name,
typeConverters.SymbolKind.to(symbol.kind),
symbol.containerName,
new types.Location(resource, typeConverters.Range.to(symbol.range))
));
class MergedInfo extends types.SymbolInformation implements vscode.DocumentSymbol {
static to(symbol: modes.DocumentSymbol): MergedInfo {
let res = new MergedInfo(
symbol.name,
typeConverters.SymbolKind.to(symbol.kind),
symbol.containerName,
new types.Location(resource, typeConverters.Range.to(symbol.range))
);
res.detail = symbol.detail;
res.range = res.location.range;
res.selectionRange = typeConverters.Range.to(symbol.selectionRange);
res.children = symbol.children && symbol.children.map(MergedInfo.to);
return res;
}
detail: string;
range: vscode.Range;
selectionRange: vscode.Range;
children: vscode.DocumentSymbol[];
}
return result;
return value.map(MergedInfo.to);
});
}