mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 04:09:28 +00:00
Extract toSymbolInformation
This commit is contained in:
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user