@@ -625,124 +625,17 @@ export class MainThreadCompletions extends AbstractMainThreadFeature<modes.ISugg
625625 }
626626}
627627
628- // --- workspace symbols
629-
630- export class ExtensionHostWorkspaceSymbols {
631-
632- private _provider : vscode . WorkspaceSymbolProvider [ ] = [ ] ;
633- private _proxy : MainThreadWorkspaceSymbols ;
634- private _threadService : IThreadService ;
635- private _commands : PluginHostCommands ;
636-
637- constructor ( @IThreadService threadService : IThreadService ) {
638- this . _threadService = threadService ;
639- this . _commands = threadService . getRemotable ( PluginHostCommands ) ;
640- this . _proxy = threadService . getRemotable ( MainThreadWorkspaceSymbols ) ;
641- this . _commands . registerCommand ( MainThreadWorkspaceSymbols . CommandId , this . _runAsCommand , this ) ;
642- }
643-
644- register ( provider : vscode . WorkspaceSymbolProvider ) : vscode . Disposable {
645-
646- this . _provider . push ( provider ) ;
647-
648- // is first, register commands, do stuff
649- if ( this . _provider . length === 1 ) {
650- this . _proxy . _enable ( true ) ;
651- }
652-
653- return new Disposable ( ( ) => {
654- let idx = this . _provider . indexOf ( provider ) ;
655- if ( idx >= 0 ) {
656- this . _provider . splice ( idx , 1 ) ;
657- if ( this . _provider . length === 0 ) {
658- this . _proxy . _enable ( false ) ;
659- }
660- }
661- } ) ;
662- }
663-
664- private _runAsCommand ( query : string ) : TPromise < ITypeBearing [ ] > {
665-
666- if ( typeof query !== 'string' ) {
667- return TPromise . wrapError ( 'query is not string' ) ;
668- }
669-
670- let symbols : vscode . SymbolInformation [ ] = [ ] ;
671- let promises = this . _provider . map ( provider => {
672- return asWinJsPromise ( token => {
673- return provider . provideWorkspaceSymbols ( query , token )
674- } ) . then ( value => {
675- if ( Array . isArray ( value ) ) {
676- symbols . push ( ...value ) ;
677- }
678- } , err => {
679- console . error ( err ) ;
680- } ) ;
681- } ) ;
682-
683- return TPromise . join ( promises ) . then ( ( ) => {
684- return symbols . map ( ExtensionHostWorkspaceSymbols . _fromSymbolInformation ) ;
685- } ) ;
686- }
687-
688- private static _fromSymbolInformation ( info : vscode . SymbolInformation ) : ITypeBearing {
689- return < ITypeBearing > {
690- name : info . name ,
691- type : SymbolKind [ info . kind || SymbolKind . Property ] . toLowerCase ( ) ,
692- range : TypeConverters . fromRange ( info . location . range ) ,
693- resourceUri : info . location . uri ,
694- containerName : info . containerName ,
695- parameters : '' ,
696- } ;
697- }
698- }
699-
700- @Remotable . MainContext ( 'MainThreadWorkspaceSymbols' )
701- export class MainThreadWorkspaceSymbols implements INavigateTypesSupport {
702-
703- static CommandId = 'vscode.executeWorkspaceSymbolProvider' ;
704-
705- private _commands : PluginHostCommands ;
706- private _disposable : IDisposable ;
707-
708- constructor ( @IThreadService threadService : IThreadService ) {
709- this . _commands = threadService . getRemotable ( PluginHostCommands ) ;
710- }
711-
712- _enable ( value : boolean ) : void {
713- if ( value ) {
714- this . _disposable = NavigateTypesSupportRegistry . register ( this ) ;
715- } else if ( this . _disposable ) {
716- this . _disposable . dispose ( ) ;
717- this . _disposable = undefined ;
718- }
719- }
720-
721- getNavigateToItems ( search : string ) : TPromise < ITypeBearing [ ] > {
722- let value = this . _commands . executeCommand < ITypeBearing [ ] > ( MainThreadWorkspaceSymbols . CommandId , search ) ;
723- return TPromise . as ( < any > value ) ;
724- }
725- }
726-
727628export namespace LanguageFeatures {
728629
729630 export function createMainThreadInstances ( threadService : IThreadService ) : void {
730- threadService . getRemotable ( MainThreadWorkspaceSymbols ) ;
731631 threadService . getRemotable ( MainThreadRename ) ;
732- threadService . getRemotable ( MainThreadFormatDocument ) ;
733- threadService . getRemotable ( MainThreadFormatRange ) ;
734- threadService . getRemotable ( MainThreadFormatOnType ) ;
735632 threadService . getRemotable ( MainThreadSignatureHelp ) ;
736633 threadService . getRemotable ( MainThreadCompletions ) ;
737634 }
738635
739636 export function createExtensionHostInstances ( threadService : IThreadService ) {
740637 return {
741- workspaceSymbols : new ExtensionHostWorkspaceSymbols ( threadService ) ,
742638 rename : new ExtensionHostRename ( threadService ) ,
743- formatDocument : new ExtHostFormatDocument ( threadService ) ,
744- formatRange : new ExtHostFormatRange ( threadService ) ,
745- formatOnType : new ExtHostFormatOnType ( threadService ) ,
746639 signatureHelp : new ExtHostSignatureHelp ( threadService ) ,
747640 completions : threadService . getRemotable ( ExtHostCompletions )
748641 } ;
0 commit comments