Skip to content

Commit

Permalink
Add plugin id to register commands
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Pinkney <joshpinkney@gmail.com>
  • Loading branch information
JPinkney committed Sep 19, 2019
1 parent 286944f commit 46cf5fb
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 100 deletions.
46 changes: 26 additions & 20 deletions packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CompletionResultDto | undefined>;
Expand Down Expand Up @@ -1156,29 +1161,30 @@ export interface LanguagesMain {
$changeLanguage(resource: UriComponents, languageId: string): Promise<void>;
$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 {
Expand Down
42 changes: 22 additions & 20 deletions packages/plugin-ext/src/main/browser/languages-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
WorkspaceEditDto,
ResourceTextEditDto,
ResourceFileEditDto,
LanguagesInfo,
} from '../../common/plugin-api-rpc';
import { injectable, inject } from 'inversify';
import {
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -132,23 +134,23 @@ 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();
disposable.push(monaco.languages.registerDefinitionProvider(languageSelector, definitionProvider));
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();
disposable.push(monaco.languages.registerDeclarationProvider(languageSelector, declarationProvider));
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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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));
Expand All @@ -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();
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 46cf5fb

Please sign in to comment.