Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move cpp grammars to textmate-grammars extension #5803

Merged
merged 1 commit into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/cpp/src/browser/cpp-frontend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import { CppKeybindingContribution, CppKeybindingContext } from './cpp-keybindin
import { bindCppPreferences } from './cpp-preferences';
import { CppBuildConfigurationsContributions, CppBuildConfigurationChanger } from './cpp-build-configurations-ui';
import { CppBuildConfigurationManager, CppBuildConfigurationManagerImpl } from './cpp-build-configurations';
import { LanguageGrammarDefinitionContribution } from '@theia/monaco/lib/browser/textmate';
import { CppGrammarContribution } from './cpp-grammar-contribution';
import { CppBuildConfigurationsStatusBarElement } from './cpp-build-configurations-statusbar-element';
import { CppTaskProvider } from './cpp-task-provider';
import { TaskContribution } from '@theia/task/lib/browser/task-contribution';
Expand All @@ -47,7 +45,6 @@ export default new ContainerModule(bind => {

bind(TaskContribution).toService(CppTaskProvider);
bind(CommandContribution).toService(CppBuildConfigurationsContributions);
bind(LanguageGrammarDefinitionContribution).to(CppGrammarContribution).inSingletonScope();

bind(CppBuildConfigurationsStatusBarElement).toSelf().inSingletonScope();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@

import { LanguageGrammarDefinitionContribution, TextmateRegistry } from '@theia/monaco/lib/browser/textmate';
import { injectable } from 'inversify';
import { C_LANGUAGE_ID, CPP_LANGUAGE_ID } from '../common';

@injectable()
export class CppGrammarContribution implements LanguageGrammarDefinitionContribution {
export class CppContribution implements LanguageGrammarDefinitionContribution {

readonly C_LANGUAGE_ID = 'c';
readonly CPP_LANGUAGE_ID = 'cpp';
readonly CPP_LANGUAGE_NAME = 'C/C++';

readonly config: monaco.languages.LanguageConfiguration = {
comments: {
Expand Down Expand Up @@ -56,12 +59,12 @@ export class CppGrammarContribution implements LanguageGrammarDefinitionContribu

registerTextmateLanguage(registry: TextmateRegistry) {
monaco.languages.register({
id: C_LANGUAGE_ID,
id: this.C_LANGUAGE_ID,
extensions: ['.c'],
aliases: ['C', 'c']
});

monaco.languages.setLanguageConfiguration(C_LANGUAGE_ID, this.config);
monaco.languages.setLanguageConfiguration(this.C_LANGUAGE_ID, this.config);

const platformGrammar = require('../../data/platform.tmLanguage.json');
registry.registerTextmateGrammarScope('source.c.platform', {
Expand All @@ -82,16 +85,16 @@ export class CppGrammarContribution implements LanguageGrammarDefinitionContribu
};
}
});
registry.mapLanguageIdToTextmateGrammar(C_LANGUAGE_ID, 'source.c');
registry.mapLanguageIdToTextmateGrammar(this.C_LANGUAGE_ID, 'source.c');

// cpp
monaco.languages.register({
id: CPP_LANGUAGE_ID,
id: this.CPP_LANGUAGE_ID,
extensions: ['.cpp', '.cc', '.cxx', '.hpp', '.hh', '.hxx', '.h', '.ino', '.inl', '.ipp', 'cl'],
aliases: ['C++', 'Cpp', 'cpp'],
});

monaco.languages.setLanguageConfiguration(CPP_LANGUAGE_ID, this.config);
monaco.languages.setLanguageConfiguration(this.CPP_LANGUAGE_ID, this.config);

const cppGrammar = require('../../data/cpp.tmLanguage.json');
registry.registerTextmateGrammarScope('source.cpp', {
Expand All @@ -102,6 +105,6 @@ export class CppGrammarContribution implements LanguageGrammarDefinitionContribu
};
}
});
registry.mapLanguageIdToTextmateGrammar(CPP_LANGUAGE_ID, 'source.cpp');
registry.mapLanguageIdToTextmateGrammar(this.CPP_LANGUAGE_ID, 'source.cpp');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { PythonContribution } from './python';
import { GoContribution } from './go';
import { RustContribution } from './rust';
import { PhpGrammarContribution } from './php';
import { CppContribution } from './cpp';

export default new ContainerModule(bind => {
bind(BatContribution).toSelf().inSingletonScope();
Expand Down Expand Up @@ -173,4 +174,7 @@ export default new ContainerModule(bind => {

bind(PhpGrammarContribution).toSelf().inSingletonScope();
bind(LanguageGrammarDefinitionContribution).toService(PhpGrammarContribution);

bind(CppContribution).toSelf().inSingletonScope();
bind(LanguageGrammarDefinitionContribution).toService(CppContribution);
});