diff --git a/packages/plugin-ext/src/common/plugin-api-rpc.ts b/packages/plugin-ext/src/common/plugin-api-rpc.ts index ceccf1a051d8a..22a440a294040 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc.ts @@ -1087,6 +1087,11 @@ export interface ProcessTaskDto extends TaskDto, CommandProperties { windows?: CommandProperties; } +export interface LanguagesInfo { + pluginID: string; + pluginName: string; +} + export interface LanguagesExt { $provideCompletionItems(handle: number, resource: UriComponents, position: Position, context: CompletionContext, token: CancellationToken): Promise; @@ -1156,29 +1161,30 @@ export interface LanguagesMain { $changeLanguage(resource: UriComponents, languageId: string): Promise; $setLanguageConfiguration(handle: number, languageId: string, configuration: SerializedLanguageConfiguration): void; $unregister(handle: number): void; - $registerCompletionSupport(handle: number, selector: SerializedDocumentFilter[], triggerCharacters: string[], supportsResolveDetails: boolean): void; - $registerImplementationProvider(handle: number, selector: SerializedDocumentFilter[]): void; - $registerTypeDefinitionProvider(handle: number, selector: SerializedDocumentFilter[]): void; - $registerDefinitionProvider(handle: number, selector: SerializedDocumentFilter[]): void; - $registerDeclarationProvider(handle: number, selector: SerializedDocumentFilter[]): void; - $registerReferenceProvider(handle: number, selector: SerializedDocumentFilter[]): void; - $registerSignatureHelpProvider(handle: number, selector: SerializedDocumentFilter[], metadata: theia.SignatureHelpProviderMetadata): void; - $registerHoverProvider(handle: number, selector: SerializedDocumentFilter[]): void; - $registerDocumentHighlightProvider(handle: number, selector: SerializedDocumentFilter[]): void; - $registerQuickFixProvider(handle: number, selector: SerializedDocumentFilter[], codeActionKinds?: string[]): void; + $registerCompletionSupport(handle: number, languageInfo: LanguagesInfo, + selector: SerializedDocumentFilter[], triggerCharacters: string[], supportsResolveDetails: boolean): void; + $registerImplementationProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void; + $registerTypeDefinitionProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void; + $registerDefinitionProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void; + $registerDeclarationProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void; + $registerReferenceProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void; + $registerSignatureHelpProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[], metadata: theia.SignatureHelpProviderMetadata): void; + $registerHoverProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void; + $registerDocumentHighlightProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void; + $registerQuickFixProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[], codeActionKinds?: string[]): void; $clearDiagnostics(id: string): void; $changeDiagnostics(id: string, delta: [string, MarkerData[]][]): void; - $registerDocumentFormattingSupport(handle: number, selector: SerializedDocumentFilter[]): void; - $registerRangeFormattingProvider(handle: number, selector: SerializedDocumentFilter[]): void; - $registerOnTypeFormattingProvider(handle: number, selector: SerializedDocumentFilter[], autoFormatTriggerCharacters: string[]): void; - $registerDocumentLinkProvider(handle: number, selector: SerializedDocumentFilter[]): void; - $registerCodeLensSupport(handle: number, selector: SerializedDocumentFilter[], eventHandle?: number): void; + $registerDocumentFormattingSupport(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void; + $registerRangeFormattingProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void; + $registerOnTypeFormattingProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[], autoFormatTriggerCharacters: string[]): void; + $registerDocumentLinkProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void; + $registerCodeLensSupport(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[], eventHandle?: number): void; $emitCodeLensEvent(eventHandle: number, event?: any): void; - $registerOutlineSupport(handle: number, selector: SerializedDocumentFilter[]): void; - $registerWorkspaceSymbolProvider(handle: number): void; - $registerFoldingRangeProvider(handle: number, selector: SerializedDocumentFilter[]): void; - $registerDocumentColorProvider(handle: number, selector: SerializedDocumentFilter[]): void; - $registerRenameProvider(handle: number, selector: SerializedDocumentFilter[], supportsResoveInitialValues: boolean): void; + $registerOutlineSupport(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void; + $registerWorkspaceSymbolProvider(handle: number, languageInfo: LanguagesInfo): void; + $registerFoldingRangeProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void; + $registerDocumentColorProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void; + $registerRenameProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[], supportsResoveInitialValues: boolean): void; } export interface WebviewPanelViewState { diff --git a/packages/plugin-ext/src/main/browser/languages-main.ts b/packages/plugin-ext/src/main/browser/languages-main.ts index d94af4606b558..f9e470d365e4e 100644 --- a/packages/plugin-ext/src/main/browser/languages-main.ts +++ b/packages/plugin-ext/src/main/browser/languages-main.ts @@ -33,6 +33,7 @@ import { WorkspaceEditDto, ResourceTextEditDto, ResourceFileEditDto, + LanguagesInfo, } from '../../common/plugin-api-rpc'; import { injectable, inject } from 'inversify'; import { @@ -103,7 +104,8 @@ export class LanguagesMainImpl implements LanguagesMain { this.disposables.set(handle, monaco.languages.setLanguageConfiguration(languageId, config)); } - $registerCompletionSupport(handle: number, selector: SerializedDocumentFilter[], triggerCharacters: string[], supportsResolveDetails: boolean): void { + $registerCompletionSupport(handle: number, languageInfo: LanguagesInfo, + selector: SerializedDocumentFilter[], triggerCharacters: string[], supportsResolveDetails: boolean): void { this.disposables.set(handle, monaco.modes.CompletionProviderRegistry.register(fromLanguageSelector(selector), { triggerCharacters, provideCompletionItems: (model, position, context, token) => this.provideCompletionItems(handle, model, position, context, token), @@ -132,7 +134,7 @@ export class LanguagesMainImpl implements LanguagesMain { return this.proxy.$resolveCompletionItem(handle, model.uri, position, item, token); } - $registerDefinitionProvider(handle: number, selector: SerializedDocumentFilter[]): void { + $registerDefinitionProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void { const languageSelector = fromLanguageSelector(selector); const definitionProvider = this.createDefinitionProvider(handle); const disposable = new DisposableCollection(); @@ -140,7 +142,7 @@ export class LanguagesMainImpl implements LanguagesMain { this.disposables.set(handle, disposable); } - $registerDeclarationProvider(handle: number, selector: SerializedDocumentFilter[]): void { + $registerDeclarationProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void { const languageSelector = fromLanguageSelector(selector); const declarationProvider = this.createDeclarationProvider(handle); const disposable = new DisposableCollection(); @@ -148,7 +150,7 @@ export class LanguagesMainImpl implements LanguagesMain { this.disposables.set(handle, disposable); } - $registerReferenceProvider(handle: number, selector: SerializedDocumentFilter[]): void { + $registerReferenceProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void { const languageSelector = fromLanguageSelector(selector); const referenceProvider = this.createReferenceProvider(handle); const disposable = new DisposableCollection(); @@ -181,7 +183,7 @@ export class LanguagesMainImpl implements LanguagesMain { }); } - $registerSignatureHelpProvider(handle: number, selector: SerializedDocumentFilter[], metadata: theia.SignatureHelpProviderMetadata): void { + $registerSignatureHelpProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[], metadata: theia.SignatureHelpProviderMetadata): void { const languageSelector = fromLanguageSelector(selector); const signatureHelpProvider = this.createSignatureHelpProvider(handle, metadata); const disposable = new DisposableCollection(); @@ -202,7 +204,7 @@ export class LanguagesMainImpl implements LanguagesMain { } } - $registerImplementationProvider(handle: number, selector: SerializedDocumentFilter[]): void { + $registerImplementationProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void { const languageSelector = fromLanguageSelector(selector); const implementationProvider = this.createImplementationProvider(handle); const disposable = new DisposableCollection(); @@ -240,7 +242,7 @@ export class LanguagesMainImpl implements LanguagesMain { }); } - $registerTypeDefinitionProvider(handle: number, selector: SerializedDocumentFilter[]): void { + $registerTypeDefinitionProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void { const languageSelector = fromLanguageSelector(selector); const typeDefinitionProvider = this.createTypeDefinitionProvider(handle); const disposable = new DisposableCollection(); @@ -278,7 +280,7 @@ export class LanguagesMainImpl implements LanguagesMain { }); } - $registerHoverProvider(handle: number, selector: SerializedDocumentFilter[]): void { + $registerHoverProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void { const languageSelector = fromLanguageSelector(selector); const hoverProvider = this.createHoverProvider(handle); const disposable = new DisposableCollection(); @@ -297,7 +299,7 @@ export class LanguagesMainImpl implements LanguagesMain { return this.proxy.$provideHover(handle, model.uri, position, token); } - $registerDocumentHighlightProvider(handle: number, selector: SerializedDocumentFilter[]): void { + $registerDocumentHighlightProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void { const languageSelector = fromLanguageSelector(selector); const documentHighlightProvider = this.createDocumentHighlightProvider(handle); const disposable = new DisposableCollection(); @@ -334,7 +336,7 @@ export class LanguagesMainImpl implements LanguagesMain { }); } - $registerWorkspaceSymbolProvider(handle: number): void { + $registerWorkspaceSymbolProvider(handle: number, languageInfo: LanguagesInfo): void { const workspaceSymbolProvider = this.createWorkspaceSymbolProvider(handle); const disposable = new DisposableCollection(); disposable.push(this.monacoLanguages.registerWorkspaceSymbolProvider(workspaceSymbolProvider)); @@ -356,7 +358,7 @@ export class LanguagesMainImpl implements LanguagesMain { return this.proxy.$resolveWorkspaceSymbol(handle, symbol, token); } - $registerDocumentLinkProvider(handle: number, selector: SerializedDocumentFilter[]): void { + $registerDocumentLinkProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void { const languageSelector = fromLanguageSelector(selector); const linkProvider = this.createLinkProvider(handle); const disposable = new DisposableCollection(); @@ -398,7 +400,7 @@ export class LanguagesMainImpl implements LanguagesMain { }; } - $registerCodeLensSupport(handle: number, selector: SerializedDocumentFilter[], eventHandle: number): void { + $registerCodeLensSupport(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[], eventHandle: number): void { const languageSelector = fromLanguageSelector(selector); const lensProvider = this.createCodeLensProvider(handle); @@ -447,7 +449,7 @@ export class LanguagesMainImpl implements LanguagesMain { } } - $registerOutlineSupport(handle: number, selector: SerializedDocumentFilter[]): void { + $registerOutlineSupport(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void { const languageSelector = fromLanguageSelector(selector); const symbolProvider = this.createDocumentSymbolProvider(handle); @@ -552,7 +554,7 @@ export class LanguagesMainImpl implements LanguagesMain { }; } - $registerDocumentFormattingSupport(handle: number, selector: SerializedDocumentFilter[]): void { + $registerDocumentFormattingSupport(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void { const languageSelector = fromLanguageSelector(selector); const documentFormattingEditSupport = this.createDocumentFormattingSupport(handle); const disposable = new DisposableCollection(); @@ -571,7 +573,7 @@ export class LanguagesMainImpl implements LanguagesMain { return this.proxy.$provideDocumentFormattingEdits(handle, model.uri, options, token); } - $registerRangeFormattingProvider(handle: number, selector: SerializedDocumentFilter[]): void { + $registerRangeFormattingProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void { const languageSelector = fromLanguageSelector(selector); const rangeFormattingEditProvider = this.createRangeFormattingProvider(handle); const disposable = new DisposableCollection(); @@ -590,7 +592,7 @@ export class LanguagesMainImpl implements LanguagesMain { return this.proxy.$provideDocumentRangeFormattingEdits(handle, model.uri, range, options, token); } - $registerOnTypeFormattingProvider(handle: number, selector: SerializedDocumentFilter[], autoFormatTriggerCharacters: string[]): void { + $registerOnTypeFormattingProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[], autoFormatTriggerCharacters: string[]): void { const languageSelector = fromLanguageSelector(selector); const onTypeFormattingProvider = this.createOnTypeFormattingProvider(handle, autoFormatTriggerCharacters); const disposable = new DisposableCollection(); @@ -613,7 +615,7 @@ export class LanguagesMainImpl implements LanguagesMain { return this.proxy.$provideOnTypeFormattingEdits(handle, model.uri, position, ch, options, token); } - $registerFoldingRangeProvider(handle: number, selector: SerializedDocumentFilter[]): void { + $registerFoldingRangeProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void { const languageSelector = fromLanguageSelector(selector); const provider = this.createFoldingRangeProvider(handle); const disposable = new DisposableCollection(); @@ -632,7 +634,7 @@ export class LanguagesMainImpl implements LanguagesMain { return this.proxy.$provideFoldingRange(handle, model.uri, context, token); } - $registerDocumentColorProvider(handle: number, selector: SerializedDocumentFilter[]): void { + $registerDocumentColorProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[]): void { const languageSelector = fromLanguageSelector(selector); const colorProvider = this.createColorProvider(handle); const disposable = new DisposableCollection(); @@ -680,7 +682,7 @@ export class LanguagesMainImpl implements LanguagesMain { }, token); } - $registerQuickFixProvider(handle: number, selector: SerializedDocumentFilter[], codeActionKinds?: string[]): void { + $registerQuickFixProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[], codeActionKinds?: string[]): void { const languageSelector = fromLanguageSelector(selector); const quickFixProvider = this.createQuickFixProvider(handle, codeActionKinds); const disposable = new DisposableCollection(); @@ -709,7 +711,7 @@ export class LanguagesMainImpl implements LanguagesMain { }; } - $registerRenameProvider(handle: number, selector: SerializedDocumentFilter[], supportsResolveLocation: boolean): void { + $registerRenameProvider(handle: number, languageInfo: LanguagesInfo, selector: SerializedDocumentFilter[], supportsResolveLocation: boolean): void { const languageSelector = fromLanguageSelector(selector); const renameProvider = this.createRenameProvider(handle, supportsResolveLocation); const disposable = new DisposableCollection(); diff --git a/packages/plugin-ext/src/plugin/languages.ts b/packages/plugin-ext/src/plugin/languages.ts index 8719b3cc7217a..25367d13e79c3 100644 --- a/packages/plugin-ext/src/plugin/languages.ts +++ b/packages/plugin-ext/src/plugin/languages.ts @@ -26,6 +26,7 @@ import { Selection, RawColorInfo, WorkspaceEditDto, + LanguagesInfo, } from '../common/plugin-api-rpc'; import { RPCProtocol } from '../common/rpc-protocol'; import * as theia from '@theia/plugin'; @@ -231,9 +232,10 @@ export class LanguagesExtImpl implements LanguagesExt { this.withAdapter(handle, CompletionAdapter, async adapter => adapter.releaseCompletionItems(id)); } - registerCompletionItemProvider(selector: theia.DocumentSelector, provider: theia.CompletionItemProvider, triggerCharacters: string[]): theia.Disposable { + registerCompletionItemProvider(selector: theia.DocumentSelector, provider: theia.CompletionItemProvider, triggerCharacters: string[], + languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new CompletionAdapter(provider, this.documents, this.commands)); - this.proxy.$registerCompletionSupport(callId, this.transformDocumentSelector(selector), triggerCharacters, CompletionAdapter.hasResolveSupport(provider)); + this.proxy.$registerCompletionSupport(callId, languageInfo, this.transformDocumentSelector(selector), triggerCharacters, CompletionAdapter.hasResolveSupport(provider)); return this.createDisposable(callId); } // ### Completion end @@ -243,9 +245,9 @@ export class LanguagesExtImpl implements LanguagesExt { return this.withAdapter(handle, DefinitionAdapter, adapter => adapter.provideDefinition(URI.revive(resource), position, token)); } - registerDefinitionProvider(selector: theia.DocumentSelector, provider: theia.DefinitionProvider): theia.Disposable { + registerDefinitionProvider(selector: theia.DocumentSelector, provider: theia.DefinitionProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new DefinitionAdapter(provider, this.documents)); - this.proxy.$registerDefinitionProvider(callId, this.transformDocumentSelector(selector)); + this.proxy.$registerDefinitionProvider(callId, languageInfo, this.transformDocumentSelector(selector)); return this.createDisposable(callId); } // ### Definition provider end @@ -255,9 +257,9 @@ export class LanguagesExtImpl implements LanguagesExt { return this.withAdapter(handle, DeclarationAdapter, adapter => adapter.provideDeclaration(URI.revive(resource), position, token)); } - registerDeclarationProvider(selector: theia.DocumentSelector, provider: theia.DeclarationProvider): theia.Disposable { + registerDeclarationProvider(selector: theia.DocumentSelector, provider: theia.DeclarationProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new DeclarationAdapter(provider, this.documents)); - this.proxy.$registerDeclarationProvider(callId, this.transformDocumentSelector(selector)); + this.proxy.$registerDeclarationProvider(callId, languageInfo, this.transformDocumentSelector(selector)); return this.createDisposable(callId); } // ### Declaration provider end @@ -273,9 +275,10 @@ export class LanguagesExtImpl implements LanguagesExt { this.withAdapter(handle, SignatureHelpAdapter, async adapter => adapter.releaseSignatureHelp(id)); } - registerSignatureHelpProvider(selector: theia.DocumentSelector, provider: theia.SignatureHelpProvider, metadata: theia.SignatureHelpProviderMetadata): theia.Disposable { + registerSignatureHelpProvider(selector: theia.DocumentSelector, provider: theia.SignatureHelpProvider, metadata: theia.SignatureHelpProviderMetadata, + languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new SignatureHelpAdapter(provider, this.documents)); - this.proxy.$registerSignatureHelpProvider(callId, this.transformDocumentSelector(selector), metadata); + this.proxy.$registerSignatureHelpProvider(callId, languageInfo, this.transformDocumentSelector(selector), metadata); return this.createDisposable(callId); } // ### Signature help end @@ -295,9 +298,9 @@ export class LanguagesExtImpl implements LanguagesExt { return this.withAdapter(handle, ImplementationAdapter, adapter => adapter.provideImplementation(URI.revive(resource), position, token)); } - registerImplementationProvider(selector: theia.DocumentSelector, provider: theia.ImplementationProvider): theia.Disposable { + registerImplementationProvider(selector: theia.DocumentSelector, provider: theia.ImplementationProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new ImplementationAdapter(provider, this.documents)); - this.proxy.$registerImplementationProvider(callId, this.transformDocumentSelector(selector)); + this.proxy.$registerImplementationProvider(callId, languageInfo, this.transformDocumentSelector(selector)); return this.createDisposable(callId); } // ### Implementation provider end @@ -307,17 +310,17 @@ export class LanguagesExtImpl implements LanguagesExt { return this.withAdapter(handle, TypeDefinitionAdapter, adapter => adapter.provideTypeDefinition(URI.revive(resource), position, token)); } - registerTypeDefinitionProvider(selector: theia.DocumentSelector, provider: theia.TypeDefinitionProvider): theia.Disposable { + registerTypeDefinitionProvider(selector: theia.DocumentSelector, provider: theia.TypeDefinitionProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new TypeDefinitionAdapter(provider, this.documents)); - this.proxy.$registerTypeDefinitionProvider(callId, this.transformDocumentSelector(selector)); + this.proxy.$registerTypeDefinitionProvider(callId, languageInfo, this.transformDocumentSelector(selector)); return this.createDisposable(callId); } // ### Type Definition provider end // ### Hover Provider begin - registerHoverProvider(selector: theia.DocumentSelector, provider: theia.HoverProvider): theia.Disposable { + registerHoverProvider(selector: theia.DocumentSelector, provider: theia.HoverProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new HoverAdapter(provider, this.documents)); - this.proxy.$registerHoverProvider(callId, this.transformDocumentSelector(selector)); + this.proxy.$registerHoverProvider(callId, languageInfo, this.transformDocumentSelector(selector)); return this.createDisposable(callId); } @@ -327,9 +330,9 @@ export class LanguagesExtImpl implements LanguagesExt { // ### Hover Provider end // ### Document Highlight Provider begin - registerDocumentHighlightProvider(selector: theia.DocumentSelector, provider: theia.DocumentHighlightProvider): theia.Disposable { + registerDocumentHighlightProvider(selector: theia.DocumentSelector, provider: theia.DocumentHighlightProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new DocumentHighlightAdapter(provider, this.documents)); - this.proxy.$registerDocumentHighlightProvider(callId, this.transformDocumentSelector(selector)); + this.proxy.$registerDocumentHighlightProvider(callId, languageInfo, this.transformDocumentSelector(selector)); return this.createDisposable(callId); } @@ -339,9 +342,9 @@ export class LanguagesExtImpl implements LanguagesExt { // ### Document Highlight Provider end // ### WorkspaceSymbol Provider begin - registerWorkspaceSymbolProvider(provider: theia.WorkspaceSymbolProvider): theia.Disposable { + registerWorkspaceSymbolProvider(provider: theia.WorkspaceSymbolProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new WorkspaceSymbolAdapter(provider)); - this.proxy.$registerWorkspaceSymbolProvider(callId); + this.proxy.$registerWorkspaceSymbolProvider(callId, languageInfo); return this.createDisposable(callId); } @@ -355,9 +358,9 @@ export class LanguagesExtImpl implements LanguagesExt { // ### WorkspaceSymbol Provider end // ### Document Formatting Edit begin - registerDocumentFormattingEditProvider(selector: theia.DocumentSelector, provider: theia.DocumentFormattingEditProvider): theia.Disposable { + registerDocumentFormattingEditProvider(selector: theia.DocumentSelector, provider: theia.DocumentFormattingEditProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new DocumentFormattingAdapter(provider, this.documents)); - this.proxy.$registerDocumentFormattingSupport(callId, this.transformDocumentSelector(selector)); + this.proxy.$registerDocumentFormattingSupport(callId, languageInfo, this.transformDocumentSelector(selector)); return this.createDisposable(callId); } @@ -368,9 +371,10 @@ export class LanguagesExtImpl implements LanguagesExt { // ### Document Formatting Edit end // ### Document Range Formatting Edit begin - registerDocumentRangeFormattingEditProvider(selector: theia.DocumentSelector, provider: theia.DocumentRangeFormattingEditProvider): theia.Disposable { + registerDocumentRangeFormattingEditProvider(selector: theia.DocumentSelector, provider: theia.DocumentRangeFormattingEditProvider, + languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new RangeFormattingAdapter(provider, this.documents)); - this.proxy.$registerRangeFormattingProvider(callId, this.transformDocumentSelector(selector)); + this.proxy.$registerRangeFormattingProvider(callId, languageInfo, this.transformDocumentSelector(selector)); return this.createDisposable(callId); } @@ -384,10 +388,11 @@ export class LanguagesExtImpl implements LanguagesExt { registerOnTypeFormattingEditProvider( selector: theia.DocumentSelector, provider: theia.OnTypeFormattingEditProvider, - triggerCharacters: string[] + triggerCharacters: string[], + languageInfo: LanguagesInfo ): theia.Disposable { const callId = this.addNewAdapter(new OnTypeFormattingAdapter(provider, this.documents)); - this.proxy.$registerOnTypeFormattingProvider(callId, this.transformDocumentSelector(selector), triggerCharacters); + this.proxy.$registerOnTypeFormattingProvider(callId, languageInfo, this.transformDocumentSelector(selector), triggerCharacters); return this.createDisposable(callId); } @@ -406,9 +411,9 @@ export class LanguagesExtImpl implements LanguagesExt { return this.withAdapter(handle, LinkProviderAdapter, adapter => adapter.resolveLink(link, token)); } - registerLinkProvider(selector: theia.DocumentSelector, provider: theia.DocumentLinkProvider): theia.Disposable { + registerLinkProvider(selector: theia.DocumentSelector, provider: theia.DocumentLinkProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new LinkProviderAdapter(provider, this.documents)); - this.proxy.$registerDocumentLinkProvider(callId, this.transformDocumentSelector(selector)); + this.proxy.$registerDocumentLinkProvider(callId, languageInfo, this.transformDocumentSelector(selector)); return this.createDisposable(callId); } // ### Document Link Provider end @@ -418,11 +423,13 @@ export class LanguagesExtImpl implements LanguagesExt { selector: theia.DocumentSelector, provider: theia.CodeActionProvider, pluginModel: PluginModel, + languageInfo: LanguagesInfo, metadata?: theia.CodeActionProviderMetadata ): theia.Disposable { const callId = this.addNewAdapter(new CodeActionAdapter(provider, this.documents, this.diagnostics, pluginModel ? pluginModel.id : '', this.commands)); this.proxy.$registerQuickFixProvider( callId, + languageInfo, this.transformDocumentSelector(selector), metadata && metadata.providedCodeActionKinds ? metadata.providedCodeActionKinds.map(kind => kind.value!) : undefined ); @@ -440,10 +447,10 @@ export class LanguagesExtImpl implements LanguagesExt { // ### Code Actions Provider end // ### Code Lens Provider begin - registerCodeLensProvider(selector: theia.DocumentSelector, provider: theia.CodeLensProvider): theia.Disposable { + registerCodeLensProvider(selector: theia.DocumentSelector, provider: theia.CodeLensProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new CodeLensAdapter(provider, this.documents, this.commands)); const eventHandle = typeof provider.onDidChangeCodeLenses === 'function' ? this.nextCallId() : undefined; - this.proxy.$registerCodeLensSupport(callId, this.transformDocumentSelector(selector), eventHandle); + this.proxy.$registerCodeLensSupport(callId, languageInfo, this.transformDocumentSelector(selector), eventHandle); let result = this.createDisposable(callId); if (eventHandle !== undefined && provider.onDidChangeCodeLenses) { @@ -468,17 +475,17 @@ export class LanguagesExtImpl implements LanguagesExt { return this.withAdapter(handle, ReferenceAdapter, adapter => adapter.provideReferences(URI.revive(resource), position, context, token)); } - registerReferenceProvider(selector: theia.DocumentSelector, provider: theia.ReferenceProvider): theia.Disposable { + registerReferenceProvider(selector: theia.DocumentSelector, provider: theia.ReferenceProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new ReferenceAdapter(provider, this.documents)); - this.proxy.$registerReferenceProvider(callId, this.transformDocumentSelector(selector)); + this.proxy.$registerReferenceProvider(callId, languageInfo, this.transformDocumentSelector(selector)); return this.createDisposable(callId); } // ### Code Reference Provider end // ### Document Symbol Provider begin - registerDocumentSymbolProvider(selector: theia.DocumentSelector, provider: theia.DocumentSymbolProvider): theia.Disposable { + registerDocumentSymbolProvider(selector: theia.DocumentSelector, provider: theia.DocumentSymbolProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new OutlineAdapter(this.documents, provider)); - this.proxy.$registerOutlineSupport(callId, this.transformDocumentSelector(selector)); + this.proxy.$registerOutlineSupport(callId, languageInfo, this.transformDocumentSelector(selector)); return this.createDisposable(callId); } @@ -488,9 +495,9 @@ export class LanguagesExtImpl implements LanguagesExt { // ### Document Symbol Provider end // ### Color Provider begin - registerColorProvider(selector: theia.DocumentSelector, provider: theia.DocumentColorProvider): theia.Disposable { + registerColorProvider(selector: theia.DocumentSelector, provider: theia.DocumentColorProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new ColorProviderAdapter(this.documents, provider)); - this.proxy.$registerDocumentColorProvider(callId, this.transformDocumentSelector(selector)); + this.proxy.$registerDocumentColorProvider(callId, languageInfo, this.transformDocumentSelector(selector)); return this.createDisposable(callId); } @@ -504,9 +511,9 @@ export class LanguagesExtImpl implements LanguagesExt { // ### Color Provider end // ### Folding Range Provider begin - registerFoldingRangeProvider(selector: theia.DocumentSelector, provider: theia.FoldingRangeProvider): theia.Disposable { + registerFoldingRangeProvider(selector: theia.DocumentSelector, provider: theia.FoldingRangeProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new FoldingProviderAdapter(provider, this.documents)); - this.proxy.$registerFoldingRangeProvider(callId, this.transformDocumentSelector(selector)); + this.proxy.$registerFoldingRangeProvider(callId, languageInfo, this.transformDocumentSelector(selector)); return this.createDisposable(callId); } @@ -521,9 +528,9 @@ export class LanguagesExtImpl implements LanguagesExt { // ### Folging Range Provider end // ### Rename Provider begin - registerRenameProvider(selector: theia.DocumentSelector, provider: theia.RenameProvider): theia.Disposable { + registerRenameProvider(selector: theia.DocumentSelector, provider: theia.RenameProvider, languageInfo: LanguagesInfo): theia.Disposable { const callId = this.addNewAdapter(new RenameAdapter(provider, this.documents)); - this.proxy.$registerRenameProvider(callId, this.transformDocumentSelector(selector), RenameAdapter.supportsResolving(provider)); + this.proxy.$registerRenameProvider(callId, languageInfo, this.transformDocumentSelector(selector), RenameAdapter.supportsResolving(provider)); return this.createDisposable(callId); } diff --git a/packages/plugin-ext/src/plugin/plugin-context.ts b/packages/plugin-ext/src/plugin/plugin-context.ts index fb7d461b269ba..ba8c7e46787d8 100644 --- a/packages/plugin-ext/src/plugin/plugin-context.ts +++ b/packages/plugin-ext/src/plugin/plugin-context.ts @@ -122,7 +122,7 @@ import { PreferenceRegistryExtImpl } from './preference-registry'; import { OutputChannelRegistryExt } from './output-channel-registry'; import { TerminalServiceExtImpl, TerminalExtImpl } from './terminal-ext'; import { LanguagesExtImpl, score } from './languages'; -import { fromDocumentSelector } from './type-converters'; +import { fromDocumentSelector, pluginToLanguageInfo } from './type-converters'; import { DialogsExtImpl } from './dialogs'; import { NotificationExtImpl } from './notification'; import { CancellationToken } from '@theia/core/lib/common/cancellation'; @@ -545,13 +545,13 @@ export function createAPIFactory( return languagesExt.setLanguageConfiguration(language, configuration); }, registerCompletionItemProvider(selector: theia.DocumentSelector, provider: theia.CompletionItemProvider, ...triggerCharacters: string[]): theia.Disposable { - return languagesExt.registerCompletionItemProvider(selector, provider, triggerCharacters); + return languagesExt.registerCompletionItemProvider(selector, provider, triggerCharacters, pluginToLanguageInfo(plugin)); }, registerDefinitionProvider(selector: theia.DocumentSelector, provider: theia.DefinitionProvider): theia.Disposable { - return languagesExt.registerDefinitionProvider(selector, provider); + return languagesExt.registerDefinitionProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerDeclarationProvider(selector: theia.DocumentSelector, provider: theia.DeclarationProvider): theia.Disposable { - return languagesExt.registerDeclarationProvider(selector, provider); + return languagesExt.registerDeclarationProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerSignatureHelpProvider( selector: theia.DocumentSelector, provider: theia.SignatureHelpProvider, first?: string | theia.SignatureHelpProviderMetadata, ...remaining: string[] @@ -566,28 +566,28 @@ export function createAPIFactory( triggerCharacters.push(first, ...remaining); } } - return languagesExt.registerSignatureHelpProvider(selector, provider, metadata); + return languagesExt.registerSignatureHelpProvider(selector, provider, metadata, pluginToLanguageInfo(plugin)); }, registerTypeDefinitionProvider(selector: theia.DocumentSelector, provider: theia.TypeDefinitionProvider): theia.Disposable { - return languagesExt.registerTypeDefinitionProvider(selector, provider); + return languagesExt.registerTypeDefinitionProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerImplementationProvider(selector: theia.DocumentSelector, provider: theia.ImplementationProvider): theia.Disposable { - return languagesExt.registerImplementationProvider(selector, provider); + return languagesExt.registerImplementationProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerHoverProvider(selector: theia.DocumentSelector, provider: theia.HoverProvider): theia.Disposable { - return languagesExt.registerHoverProvider(selector, provider); + return languagesExt.registerHoverProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerDocumentHighlightProvider(selector: theia.DocumentSelector, provider: theia.DocumentHighlightProvider): theia.Disposable { - return languagesExt.registerDocumentHighlightProvider(selector, provider); + return languagesExt.registerDocumentHighlightProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerWorkspaceSymbolProvider(provider: theia.WorkspaceSymbolProvider): theia.Disposable { - return languagesExt.registerWorkspaceSymbolProvider(provider); + return languagesExt.registerWorkspaceSymbolProvider(provider, pluginToLanguageInfo(plugin)); }, registerDocumentFormattingEditProvider(selector: theia.DocumentSelector, provider: theia.DocumentFormattingEditProvider): theia.Disposable { - return languagesExt.registerDocumentFormattingEditProvider(selector, provider); + return languagesExt.registerDocumentFormattingEditProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerDocumentRangeFormattingEditProvider(selector: theia.DocumentSelector, provider: theia.DocumentRangeFormattingEditProvider): theia.Disposable { - return languagesExt.registerDocumentRangeFormattingEditProvider(selector, provider); + return languagesExt.registerDocumentRangeFormattingEditProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerOnTypeFormattingEditProvider( selector: theia.DocumentSelector, @@ -595,31 +595,31 @@ export function createAPIFactory( firstTriggerCharacter: string, ...moreTriggerCharacters: string[] ): theia.Disposable { - return languagesExt.registerOnTypeFormattingEditProvider(selector, provider, [firstTriggerCharacter].concat(moreTriggerCharacters)); + return languagesExt.registerOnTypeFormattingEditProvider(selector, provider, [firstTriggerCharacter].concat(moreTriggerCharacters), pluginToLanguageInfo(plugin)); }, registerDocumentLinkProvider(selector: theia.DocumentSelector, provider: theia.DocumentLinkProvider): theia.Disposable { - return languagesExt.registerLinkProvider(selector, provider); + return languagesExt.registerLinkProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerCodeActionsProvider(selector: theia.DocumentSelector, provider: theia.CodeActionProvider, metadata?: theia.CodeActionProviderMetadata): theia.Disposable { - return languagesExt.registerCodeActionsProvider(selector, provider, plugin.model, metadata); + return languagesExt.registerCodeActionsProvider(selector, provider, plugin.model, pluginToLanguageInfo(plugin), metadata); }, registerCodeLensProvider(selector: theia.DocumentSelector, provider: theia.CodeLensProvider): theia.Disposable { - return languagesExt.registerCodeLensProvider(selector, provider); + return languagesExt.registerCodeLensProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerReferenceProvider(selector: theia.DocumentSelector, provider: theia.ReferenceProvider): theia.Disposable { - return languagesExt.registerReferenceProvider(selector, provider); + return languagesExt.registerReferenceProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerDocumentSymbolProvider(selector: theia.DocumentSelector, provider: theia.DocumentSymbolProvider): theia.Disposable { - return languagesExt.registerDocumentSymbolProvider(selector, provider); + return languagesExt.registerDocumentSymbolProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerColorProvider(selector: theia.DocumentSelector, provider: theia.DocumentColorProvider): theia.Disposable { - return languagesExt.registerColorProvider(selector, provider); + return languagesExt.registerColorProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerFoldingRangeProvider(selector: theia.DocumentSelector, provider: theia.FoldingRangeProvider): theia.Disposable { - return languagesExt.registerFoldingRangeProvider(selector, provider); + return languagesExt.registerFoldingRangeProvider(selector, provider, pluginToLanguageInfo(plugin)); }, registerRenameProvider(selector: theia.DocumentSelector, provider: theia.RenameProvider): theia.Disposable { - return languagesExt.registerRenameProvider(selector, provider); + return languagesExt.registerRenameProvider(selector, provider, pluginToLanguageInfo(plugin)); }, }; diff --git a/packages/plugin-ext/src/plugin/type-converters.ts b/packages/plugin-ext/src/plugin/type-converters.ts index bb0227dc41413..265a46288e0a2 100644 --- a/packages/plugin-ext/src/plugin/type-converters.ts +++ b/packages/plugin-ext/src/plugin/type-converters.ts @@ -24,7 +24,8 @@ import { ResourceFileEditDto, TaskDto, ProcessTaskDto, - PickOpenItem + PickOpenItem, + Plugin } from '../common/plugin-api-rpc'; import * as rpc from '../common/plugin-api-rpc'; import * as model from '../common/plugin-api-rpc-model'; @@ -1077,3 +1078,10 @@ export function pathOrURIToURI(value: string | URI): URI { return value; } } + +export function pluginToLanguageInfo(plugin: Plugin): rpc.LanguagesInfo { + return { + pluginID: plugin.model.id, + pluginName: plugin.model.name + }; +}