theia-spring-boot: preparation for classpath from JDT LS
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { injectable, inject } from 'inversify';
|
||||
import { RequestType } from 'vscode-jsonrpc';
|
||||
import { CommandRegistry } from '@theia/core/lib/common';
|
||||
import { ILanguageClient } from '@theia/languages/lib/common';
|
||||
|
||||
export const ADD_LISTENER_REQUEST_TYPE = new RequestType<ClasspathListenerParams, ClasspathListenerResponse, void, void>("sts/addClasspathListener");
|
||||
export const REMOVE_LISTENER_REQUEST_TYPE = new RequestType<ClasspathListenerParams, ClasspathListenerResponse, void, void>("sts/removeClasspathListener");
|
||||
|
||||
@injectable()
|
||||
export class ClasspathService {
|
||||
|
||||
constructor(
|
||||
@inject(CommandRegistry) protected readonly commands: CommandRegistry
|
||||
) {}
|
||||
|
||||
attach(client: ILanguageClient) {
|
||||
client.onRequest(ADD_LISTENER_REQUEST_TYPE, params => this.addListener(params));
|
||||
client.onRequest(REMOVE_LISTENER_REQUEST_TYPE, params => this.removeListener(params));
|
||||
}
|
||||
|
||||
private async addListener(params: ClasspathListenerParams) {
|
||||
this.commands.executeCommand('sts.java.addClasspathListener', params.callbackCommandId);
|
||||
}
|
||||
|
||||
private async removeListener(params: ClasspathListenerParams) {
|
||||
this.commands.executeCommand('sts.java.removeClasspathListener', params.callbackCommandId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export interface ClasspathListenerParams {
|
||||
callbackCommandId: string
|
||||
}
|
||||
|
||||
export interface ClasspathListenerResponse {
|
||||
}
|
||||
@@ -2,8 +2,9 @@ import { injectable, inject } from 'inversify';
|
||||
import { NotificationType } from 'vscode-jsonrpc';
|
||||
import { TextDocumentIdentifier, Range } from 'vscode-base-languageclient/lib/base';
|
||||
import { EditorDecorationsService, SetDecorationParams, EditorDecorationStyle } from '@theia/editor/lib/browser';
|
||||
import { ILanguageClient } from '@theia/languages/lib/common';
|
||||
|
||||
export const HIGHLIGHTS_NOTIFICATION_TYPE = new NotificationType<HighlightParams,void>("sts/highlight");
|
||||
const HIGHLIGHTS_NOTIFICATION_TYPE = new NotificationType<HighlightParams,void>("sts/highlight");
|
||||
|
||||
const BOOT_LIVE_HINTS = 'Boot-Live-Hints';
|
||||
|
||||
@@ -28,6 +29,10 @@ export class HighlightService {
|
||||
@inject(EditorDecorationsService) protected readonly decorationService: EditorDecorationsService
|
||||
) {}
|
||||
|
||||
attach(client: ILanguageClient) {
|
||||
client.onNotification(HIGHLIGHTS_NOTIFICATION_TYPE, (params) => this.highlight(params));
|
||||
}
|
||||
|
||||
highlight(params: HighlightParams) {
|
||||
const decorationParams: SetDecorationParams = {
|
||||
uri: params.doc.uri,
|
||||
@@ -45,7 +50,6 @@ export class HighlightService {
|
||||
})
|
||||
};
|
||||
this.decorationService.setDecorations(decorationParams);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ import {
|
||||
} from '../common';
|
||||
import { DocumentSelector } from '@theia/languages/lib/common';
|
||||
import { JAVA_LANGUAGE_ID } from '@theia/java/lib/common';
|
||||
import {HIGHLIGHTS_NOTIFICATION_TYPE, HighlightService} from "./highlight-service";
|
||||
import { HighlightService} from "./highlight-service";
|
||||
import {ClasspathService} from "./classpath-service";
|
||||
|
||||
@injectable()
|
||||
export class SpringBootClientContribution extends BaseLanguageClientContribution {
|
||||
@@ -20,12 +21,14 @@ export class SpringBootClientContribution extends BaseLanguageClientContribution
|
||||
@inject(Workspace) protected readonly workspace: Workspace,
|
||||
@inject(Languages) protected readonly languages: Languages,
|
||||
@inject(LanguageClientFactory) protected readonly languageClientFactory: LanguageClientFactory,
|
||||
@inject(HighlightService) protected readonly highlightService: HighlightService
|
||||
@inject(HighlightService) protected readonly highlightService: HighlightService,
|
||||
@inject(ClasspathService) protected readonly classpathService: ClasspathService
|
||||
) {
|
||||
super(workspace, languages, languageClientFactory);
|
||||
this.languageClient.then(client => {
|
||||
client.onNotification(HIGHLIGHTS_NOTIFICATION_TYPE, (params) => this.highlightService.highlight(params))
|
||||
})
|
||||
this.highlightService.attach(client);
|
||||
// this.classpathService.attach(client);
|
||||
});
|
||||
}
|
||||
|
||||
protected get documentSelector(): DocumentSelector | undefined {
|
||||
|
||||
@@ -5,9 +5,11 @@ import { ContainerModule } from 'inversify';
|
||||
import './monaco-yaml-contribution';
|
||||
import './monaco-properties-contribution';
|
||||
import {HighlightService} from "./highlight-service";
|
||||
import {ClasspathService} from "./classpath-service";
|
||||
|
||||
export default new ContainerModule(bind => {
|
||||
// add your contribution bindings here
|
||||
bind(HighlightService).toSelf().inSingletonScope();
|
||||
bind(LanguageClientContribution).to(SpringBootClientContribution).inSingletonScope();
|
||||
bind(HighlightService).toSelf().inSingletonScope();
|
||||
bind(ClasspathService).toSelf().inSingletonScope();
|
||||
});
|
||||
Reference in New Issue
Block a user