From 5f0c0c692e74ff914f364d611b86dd52992617f3 Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Fri, 26 Jul 2019 12:03:27 +0300 Subject: [PATCH] Move cpp grammars to @theia/textmate-grammars extension Signed-off-by: Anatoliy Bazko --- .../cpp/src/browser/cpp-frontend-module.ts | 3 --- .../data/c.tmLanguage.json | 0 .../data/cpp.tmLanguage.json | 0 .../data/platform.tmLanguage.json | 0 .../src/browser/cpp.ts} | 19 +++++++++++-------- .../textmate-grammars-frontend-module.ts | 4 ++++ 6 files changed, 15 insertions(+), 11 deletions(-) rename packages/{cpp => textmate-grammars}/data/c.tmLanguage.json (100%) rename packages/{cpp => textmate-grammars}/data/cpp.tmLanguage.json (100%) rename packages/{cpp => textmate-grammars}/data/platform.tmLanguage.json (100%) rename packages/{cpp/src/browser/cpp-grammar-contribution.ts => textmate-grammars/src/browser/cpp.ts} (84%) diff --git a/packages/cpp/src/browser/cpp-frontend-module.ts b/packages/cpp/src/browser/cpp-frontend-module.ts index 96a61c2db33b6..2abc44f5e917f 100644 --- a/packages/cpp/src/browser/cpp-frontend-module.ts +++ b/packages/cpp/src/browser/cpp-frontend-module.ts @@ -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'; @@ -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(); diff --git a/packages/cpp/data/c.tmLanguage.json b/packages/textmate-grammars/data/c.tmLanguage.json similarity index 100% rename from packages/cpp/data/c.tmLanguage.json rename to packages/textmate-grammars/data/c.tmLanguage.json diff --git a/packages/cpp/data/cpp.tmLanguage.json b/packages/textmate-grammars/data/cpp.tmLanguage.json similarity index 100% rename from packages/cpp/data/cpp.tmLanguage.json rename to packages/textmate-grammars/data/cpp.tmLanguage.json diff --git a/packages/cpp/data/platform.tmLanguage.json b/packages/textmate-grammars/data/platform.tmLanguage.json similarity index 100% rename from packages/cpp/data/platform.tmLanguage.json rename to packages/textmate-grammars/data/platform.tmLanguage.json diff --git a/packages/cpp/src/browser/cpp-grammar-contribution.ts b/packages/textmate-grammars/src/browser/cpp.ts similarity index 84% rename from packages/cpp/src/browser/cpp-grammar-contribution.ts rename to packages/textmate-grammars/src/browser/cpp.ts index adfb06ea47aec..985cdbb4badce 100644 --- a/packages/cpp/src/browser/cpp-grammar-contribution.ts +++ b/packages/textmate-grammars/src/browser/cpp.ts @@ -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: { @@ -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', { @@ -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', { @@ -102,6 +105,6 @@ export class CppGrammarContribution implements LanguageGrammarDefinitionContribu }; } }); - registry.mapLanguageIdToTextmateGrammar(CPP_LANGUAGE_ID, 'source.cpp'); + registry.mapLanguageIdToTextmateGrammar(this.CPP_LANGUAGE_ID, 'source.cpp'); } } diff --git a/packages/textmate-grammars/src/browser/textmate-grammars-frontend-module.ts b/packages/textmate-grammars/src/browser/textmate-grammars-frontend-module.ts index 2639207b69ec6..6eac2213b4754 100644 --- a/packages/textmate-grammars/src/browser/textmate-grammars-frontend-module.ts +++ b/packages/textmate-grammars/src/browser/textmate-grammars-frontend-module.ts @@ -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(); @@ -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); });