Skip to content

Commit

Permalink
Move cpp grammars to @theia/textmate-grammars extension
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoliy Bazko <abazko@redhat.com>
  • Loading branch information
tolusha committed Jul 26, 2019
1 parent 2befdf4 commit f5161db
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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);
});

0 comments on commit f5161db

Please sign in to comment.