Skip to content

Commit

Permalink
Fix command conversions for code lens
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Mäder <tmader@redhat.com>
  • Loading branch information
tsmaeder committed Feb 15, 2019
1 parent 4b0b09d commit 891a4e3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions packages/plugin-ext/src/plugin/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ import { TypeDefinitionAdapter } from './languages/type-definition';
import { CodeActionAdapter } from './languages/code-action';
import { LinkProviderAdapter } from './languages/link-provider';
import { CodeLensAdapter } from './languages/lens';
import { CommandRegistryImpl } from './command-registry';
import { OutlineAdapter } from './languages/outline';
import { ReferenceAdapter } from './languages/reference';
import { WorkspaceSymbolAdapter } from './languages/workspace-symbol';
Expand Down Expand Up @@ -109,7 +108,7 @@ export class LanguagesExtImpl implements LanguagesExt {
private callId = 0;
private adaptersMap = new Map<number, Adapter>();

constructor(rpc: RPCProtocol, private readonly documents: DocumentsExtImpl, private readonly commands: CommandRegistryImpl) {
constructor(rpc: RPCProtocol, private readonly documents: DocumentsExtImpl) {
this.proxy = rpc.getProxy(PLUGIN_RPC_CONTEXT.LANGUAGES_MAIN);
this.diagnostics = new Diagnostics(rpc);
}
Expand Down Expand Up @@ -401,7 +400,7 @@ export class LanguagesExtImpl implements LanguagesExt {

// ### Code Lens Provider begin
registerCodeLensProvider(selector: theia.DocumentSelector, provider: theia.CodeLensProvider): theia.Disposable {
const callId = this.addNewAdapter(new CodeLensAdapter(provider, this.documents, this.commands.getConverter()));
const callId = this.addNewAdapter(new CodeLensAdapter(provider, this.documents));
const eventHandle = typeof provider.onDidChangeCodeLenses === 'function' ? this.nextCallId() : undefined;
this.proxy.$registerCodeLensSupport(callId, this.transformDocumentSelector(selector), eventHandle);
let result = this.createDisposable(callId);
Expand Down
7 changes: 3 additions & 4 deletions packages/plugin-ext/src/plugin/languages/lens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { CodeLensSymbol } from '../../api/model';
import * as Converter from '../type-converters';
import { ObjectIdentifier } from '../../common/object-identifier';
import { createToken } from '../token-provider';
import { CommandsConverter } from '../command-registry';

/** Adapts the calls from main to extension thread for providing/resolving the code lenses. */
export class CodeLensAdapter {
Expand All @@ -34,7 +33,6 @@ export class CodeLensAdapter {
constructor(
private readonly provider: theia.CodeLensProvider,
private readonly documents: DocumentsExtImpl,
private readonly commands: CommandsConverter
) { }

provideCodeLenses(resource: URI): Promise<CodeLensSymbol[] | undefined> {
Expand All @@ -49,9 +47,10 @@ export class CodeLensAdapter {
if (Array.isArray(lenses)) {
return lenses.map(lens => {
const id = this.cacheId++;
console.log(lens);
const lensSymbol = ObjectIdentifier.mixin({
range: Converter.fromRange(lens.range)!,
command: this.commands.toInternal(lens.command)
command: lens.command ? Converter.toInternalCommand(lens.command) : undefined
}, id);
this.cache.set(id, lens);
return lensSymbol;
Expand All @@ -76,7 +75,7 @@ export class CodeLensAdapter {

return resolve.then(newLens => {
newLens = newLens || lens;
symbol.command = this.commands.toInternal(newLens.command || CodeLensAdapter.BAD_CMD);
symbol.command = Converter.toInternalCommand(newLens.command ? newLens.command : CodeLensAdapter.BAD_CMD);
return symbol;
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export function createAPIFactory(
const statusBarMessageRegistryExt = new StatusBarMessageRegistryExt(rpc);
const terminalExt = rpc.set(MAIN_RPC_CONTEXT.TERMINAL_EXT, new TerminalServiceExtImpl(rpc));
const outputChannelRegistryExt = new OutputChannelRegistryExt(rpc);
const languagesExt = rpc.set(MAIN_RPC_CONTEXT.LANGUAGES_EXT, new LanguagesExtImpl(rpc, documents, commandRegistry));
const languagesExt = rpc.set(MAIN_RPC_CONTEXT.LANGUAGES_EXT, new LanguagesExtImpl(rpc, documents));
const treeViewsExt = rpc.set(MAIN_RPC_CONTEXT.TREE_VIEWS_EXT, new TreeViewsExtImpl(rpc, commandRegistry));
const webviewExt = rpc.set(MAIN_RPC_CONTEXT.WEBVIEWS_EXT, new WebviewsExtImpl(rpc));
const tasksExt = rpc.set(MAIN_RPC_CONTEXT.TASKS_EXT, new TasksExtImpl(rpc));
Expand Down

0 comments on commit 891a4e3

Please sign in to comment.