Extract toSymbolInformation

This commit is contained in:
Matt Bierner 2020-03-05 13:30:47 -08:00
parent f062556992
commit be9c791caa

View file

@ -53,18 +53,12 @@ class TypeScriptWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvide
return []; return [];
} }
const result: vscode.SymbolInformation[] = []; return response.body
for (const item of response.body) { .filter(item => item.containerName && item.kind !== 'alias')
if (!item.containerName && item.kind === 'alias') { .map(item => this.toSymbolInformation(item));
continue;
}
const label = TypeScriptWorkspaceSymbolProvider.getLabel(item);
result.push(new vscode.SymbolInformation(label, getSymbolKind(item), item.containerName || '',
typeConverters.Location.fromTextSpan(this.client.toResource(item.file), item)));
}
return result;
} }
private async toOpenedFiledPath(document: vscode.TextDocument) { private async toOpenedFiledPath(document: vscode.TextDocument) {
if (document.uri.scheme === fileSchemes.git) { if (document.uri.scheme === fileSchemes.git) {
try { try {
@ -80,6 +74,15 @@ class TypeScriptWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvide
return this.client.toOpenedFilePath(document); return this.client.toOpenedFilePath(document);
} }
private toSymbolInformation(item: Proto.NavtoItem) {
const label = TypeScriptWorkspaceSymbolProvider.getLabel(item);
return new vscode.SymbolInformation(
label,
getSymbolKind(item),
item.containerName || '',
typeConverters.Location.fromTextSpan(this.client.toResource(item.file), item));
}
private static getLabel(item: Proto.NavtoItem) { private static getLabel(item: Proto.NavtoItem) {
const label = item.name; const label = item.name;
if (item.kind === 'method' || item.kind === 'function') { if (item.kind === 'method' || item.kind === 'function') {