1+ /*---------------------------------------------------------------------------------------------
2+ * Copyright (c) Microsoft Corporation. All rights reserved.
3+ * Licensed under the MIT License. See License.txt in the project root for license information.
4+ *--------------------------------------------------------------------------------------------*/
5+ 'use strict' ;
6+
7+ import URI from 'vs/base/common/uri' ;
8+ import Event , { Emitter } from 'vs/base/common/event' ;
9+ import Severity from 'vs/base/common/severity' ;
10+ import { DefaultFilter } from 'vs/editor/common/modes/modesFilters' ;
11+ import { TPromise } from 'vs/base/common/winjs.base' ;
12+ import { onUnexpectedError } from 'vs/base/common/errors' ;
13+ import { sequence } from 'vs/base/common/async' ;
14+ import { Range as EditorRange } from 'vs/editor/common/core/range' ;
15+ import { IDisposable } from 'vs/base/common/lifecycle' ;
16+ import { IKeybindingService } from 'vs/platform/keybinding/common/keybindingService' ;
17+ import { Remotable , IThreadService } from 'vs/platform/thread/common/thread' ;
18+ import * as vscode from 'vscode' ;
19+ import * as typeConverters from 'vs/workbench/api/common/pluginHostTypeConverters' ;
20+ import * as types from 'vs/workbench/api/common/pluginHostTypes' ;
21+ import { IPosition , IRange , ISingleEditOperation } from 'vs/editor/common/editorCommon' ;
22+ import * as modes from 'vs/editor/common/modes' ;
23+ import { CancellationTokenSource } from 'vs/base/common/cancellation' ;
24+ import { PluginHostModelService } from 'vs/workbench/api/common/pluginHostDocuments' ;
25+ import { IMarkerService , IMarker } from 'vs/platform/markers/common/markers' ;
26+ import { PluginHostCommands , MainThreadCommands } from 'vs/workbench/api/common/pluginHostCommands' ;
27+ import { DeclarationRegistry } from 'vs/editor/contrib/goToDeclaration/common/goToDeclaration' ;
28+ import { ExtraInfoRegistry } from 'vs/editor/contrib/hover/common/hover' ;
29+ import { OccurrencesRegistry } from 'vs/editor/contrib/wordHighlighter/common/wordHighlighter' ;
30+ import { ReferenceRegistry } from 'vs/editor/contrib/referenceSearch/common/referenceSearch' ;
31+ import { QuickFixRegistry } from 'vs/editor/contrib/quickFix/common/quickFix' ;
32+ import { OutlineRegistry , IOutlineEntry , IOutlineSupport } from 'vs/editor/contrib/quickOpen/common/quickOpen' ;
33+ import LanguageFeatureRegistry from 'vs/editor/common/modes/languageFeatureRegistry' ;
34+ import { NavigateTypesSupportRegistry , INavigateTypesSupport , ITypeBearing } from 'vs/workbench/parts/search/common/search'
35+ import { RenameRegistry } from 'vs/editor/contrib/rename/common/rename' ;
36+ import { FormatRegistry , FormatOnTypeRegistry } from 'vs/editor/contrib/format/common/format' ;
37+ import { CodeLensRegistry } from 'vs/editor/contrib/codelens/common/codelens' ;
38+ import { ParameterHintsRegistry } from 'vs/editor/contrib/parameterHints/common/parameterHints' ;
39+ import { SuggestRegistry } from 'vs/editor/contrib/suggest/common/suggest' ;
40+
41+ // vscode.executeWorkspaceSymbolProvider
42+ // vscode.executeDefinitionProvider
43+ // vscode.executeHoverProvider
44+
45+ // vscode.executeDocumentHighlights
46+ // vscode.executeReferenceProvider
47+ // vscode.executeCodeActionProvider
48+ // vscode.executeCodeLensProvider
49+ // vscode.executeDocumentSymbolProvider
50+ // vscode.executeDocumentRenameProvider
51+ // vscode.executeFormatDocumentProvider
52+ // vscode.executeFormatRangeProvider
53+ // vscode.executeFormatOnTypeProvider
54+ // vscode.executeSignatureHelpProvider
55+ // vscode.executeCompletionItemProvider
56+
57+ export class ExtHostLanguageFeatureCommands {
58+
59+ private _commands : PluginHostCommands ;
60+ private _disposables : IDisposable [ ] = [ ] ;
61+
62+ constructor ( commands : PluginHostCommands ) {
63+ this . _commands = commands ;
64+
65+ this . _register ( 'vscode.executeWorkspaceSymbolProvider' , this . _executeWorkspaceSymbolProvider ) ;
66+ this . _register ( 'vscode.executeDefinitionProvider' , this . _executeDefinitionProvider ) ;
67+ this . _register ( 'vscode.executeHoverProvider' , this . _executeHoverProvider ) ;
68+ }
69+
70+ private _register ( id : string , callback : ( ...args : any [ ] ) => any ) : void {
71+ this . _disposables . push ( this . _commands . registerCommand ( id , callback , this ) ) ;
72+ }
73+
74+ // --- command impl
75+
76+ private _executeWorkspaceSymbolProvider ( query : string ) : Thenable < types . SymbolInformation [ ] > {
77+ return this . _commands . executeCommand < ITypeBearing [ ] > ( '_executeWorkspaceSymbolProvider' , { query } ) . then ( value => {
78+ if ( Array . isArray ( value ) ) {
79+ return value . map ( typeConverters . toSymbolInformation ) ;
80+ }
81+ } ) ;
82+ }
83+
84+ private _executeDefinitionProvider ( resource : URI , position : types . Position ) : Thenable < types . Location [ ] > {
85+ const args = {
86+ resource,
87+ position : position && typeConverters . fromPosition ( position )
88+ } ;
89+ return this . _commands . executeCommand < modes . IReference [ ] > ( '_executeDefinitionProvider' , args ) . then ( value => {
90+ if ( Array . isArray ( value ) ) {
91+ return value . map ( typeConverters . toLocation )
92+ }
93+ } ) ;
94+ }
95+
96+ private _executeHoverProvider ( resource : URI , position : types . Position ) : Thenable < types . Hover [ ] > {
97+ const args = {
98+ resource,
99+ position : position && typeConverters . fromPosition ( position )
100+ } ;
101+ return this . _commands . executeCommand < modes . IComputeExtraInfoResult [ ] > ( '_executeHoverProvider' , args ) . then ( value => {
102+ if ( Array . isArray ( value ) ) {
103+ return value . map ( typeConverters . toHover )
104+ }
105+ } ) ;
106+ }
107+ }
0 commit comments