Extract toSymbolInformation
This commit is contained in:
parent
f062556992
commit
be9c791caa
|
@ -53,18 +53,12 @@ class TypeScriptWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvide
|
|||
return [];
|
||||
}
|
||||
|
||||
const result: vscode.SymbolInformation[] = [];
|
||||
for (const item of response.body) {
|
||||
if (!item.containerName && item.kind === 'alias') {
|
||||
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;
|
||||
return response.body
|
||||
.filter(item => item.containerName && item.kind !== 'alias')
|
||||
.map(item => this.toSymbolInformation(item));
|
||||
}
|
||||
|
||||
|
||||
private async toOpenedFiledPath(document: vscode.TextDocument) {
|
||||
if (document.uri.scheme === fileSchemes.git) {
|
||||
try {
|
||||
|
@ -80,6 +74,15 @@ class TypeScriptWorkspaceSymbolProvider implements vscode.WorkspaceSymbolProvide
|
|||
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) {
|
||||
const label = item.name;
|
||||
if (item.kind === 'method' || item.kind === 'function') {
|
||||
|
|
Loading…
Reference in a new issue