Skip to content

Commit

Permalink
Enable semantic highlighting support for the C++ language client
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Ridge <[email protected]>
  • Loading branch information
HighCommander4 committed Aug 21, 2019
1 parent d059f9e commit ef355d1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/cpp/src/browser/cpp-language-client-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
********************************************************************************/

import { inject, injectable, postConstruct } from 'inversify';
import { MessageConnection } from 'vscode-jsonrpc';
import {
BaseLanguageClientContribution, LanguageClientFactory,
LanguageClientOptions,
ILanguageClient
} from '@theia/languages/lib/browser';
import { Languages, Workspace } from '@theia/languages/lib/browser';
import { SemanticHighlightingService } from '@theia/editor/lib/browser/semantic-highlight/semantic-highlighting-service';
import { ILogger } from '@theia/core/lib/common/logger';
import { WindowService } from '@theia/core/lib/browser/window/window-service';
import { CPP_LANGUAGE_ID, CPP_LANGUAGE_NAME, HEADER_AND_SOURCE_FILE_EXTENSIONS, CppStartParameters } from '../common';
Expand Down Expand Up @@ -72,6 +74,7 @@ export class CppLanguageClientContribution extends BaseLanguageClientContributio
@inject(Workspace) protected readonly workspace: Workspace,
@inject(Languages) protected readonly languages: Languages,
@inject(LanguageClientFactory) protected readonly languageClientFactory: LanguageClientFactory,
@inject(SemanticHighlightingService) protected readonly semanticHighlightingService: SemanticHighlightingService,
) {
super(workspace, languages, languageClientFactory);
}
Expand Down Expand Up @@ -121,6 +124,12 @@ export class CppLanguageClientContribution extends BaseLanguageClientContributio
return databaseMap;
}

protected createLanguageClient(connection: MessageConnection): ILanguageClient {
const client: ILanguageClient & Readonly<{ languageId: string }> = Object.assign(super.createLanguageClient(connection), { languageId: this.id });
client.registerFeature(SemanticHighlightingService.createNewFeature(this.semanticHighlightingService, client));
return client;
}

private async updateInitializationOptions(): Promise<void> {
const clangdParams: ClangdConfigurationParamsChange = {};
const experimentalCompilationDatabaseMap = this.cppPreferences['cpp.experimentalCompilationDatabaseMap'];
Expand Down

0 comments on commit ef355d1

Please sign in to comment.