import * as vscode from 'vscode' ; import { DefaultClient , GetSymbolInfoRequest , WorkspaceSymbolParams , LocalizeSymbolInformation , SymbolScope } from '../client' ; import * as util from '../../common' ; export class WorkspaceSymbolProvider implements vscode . WorkspaceSymbolProvider { private client : DefaultClient ; constructor ( client ) { this . client = client ; } public async provideWorkspaceSymbols ( query , token ) { const params = { query : query } ; const symbols = await this . client . languageClient . sendRequest ( GetSymbolInfoRequest , params ) ; const resultSymbols = [ ] ; symbols . forEach ( ( symbol ) => { let suffix = util . getLocalizedString ( symbol . suffix ) ; let name = symbol . name ; if ( suffix . length ) { if ( symbol . scope === SymbolScope . Private ) { suffix = util . getLocalizedSymbolScope ( "private" , suffix ) ; } else if ( symbol . scope === SymbolScope . Protected ) { suffix = util . getLocalizedSymbolScope ( "protected" , suffix ) ; } name = name + ' (' + suffix + ')' ; } else { if ( symbol . scope === SymbolScope . Private ) { name = name + " (private)" ; } else if ( symbol . scope === SymbolScope . Protected ) { name = name + " (protected)" ; } } const range = new vscode . Range ( symbol . location . range . start . line , symbol . location . range . start . character , symbol . location . range . end . line , symbol . location . range . end . character ) ; const uri = vscode . Uri . parse ( symbol . location . uri . toString ( ) ) ; const vscodeSymbol = new vscode . SymbolInformation ( name , symbol . kind , symbol . containerName , new vscode . Location ( uri , range ) ) ; resultSymbols . push ( vscodeSymbol ) ; } ) ; return resultSymbols ; } }