diff --git a/packages/json/src/browser/json-frontend-module.ts b/packages/json/src/browser/json-frontend-module.ts index cb621de82e9df..74419b567a8d4 100644 --- a/packages/json/src/browser/json-frontend-module.ts +++ b/packages/json/src/browser/json-frontend-module.ts @@ -17,13 +17,10 @@ import { ContainerModule } from 'inversify'; import { LanguageClientContribution } from '@theia/languages/lib/browser'; import { JsonClientContribution } from './json-client-contribution'; -import { JsonGrammarContribution } from './json-grammar-contribution'; -import { LanguageGrammarDefinitionContribution } from '@theia/monaco/lib/browser/textmate'; import { bindJsonPreferences } from './json-preferences'; export default new ContainerModule(bind => { bindJsonPreferences(bind); bind(LanguageClientContribution).to(JsonClientContribution).inSingletonScope(); - bind(LanguageGrammarDefinitionContribution).to(JsonGrammarContribution).inSingletonScope(); }); diff --git a/packages/json/data/json.tmLanguage.json b/packages/textmate-grammars/data/json.tmLanguage.json similarity index 100% rename from packages/json/data/json.tmLanguage.json rename to packages/textmate-grammars/data/json.tmLanguage.json diff --git a/packages/json/data/jsonc.tmLanguage.json b/packages/textmate-grammars/data/jsonc.tmLanguage.json similarity index 100% rename from packages/json/data/jsonc.tmLanguage.json rename to packages/textmate-grammars/data/jsonc.tmLanguage.json diff --git a/packages/json/src/browser/json-grammar-contribution.ts b/packages/textmate-grammars/src/browser/json.ts similarity index 85% rename from packages/json/src/browser/json-grammar-contribution.ts rename to packages/textmate-grammars/src/browser/json.ts index ff973af6909b8..989f4c52d2a6f 100644 --- a/packages/json/src/browser/json-grammar-contribution.ts +++ b/packages/textmate-grammars/src/browser/json.ts @@ -16,10 +16,11 @@ import { LanguageGrammarDefinitionContribution, TextmateRegistry, GrammarDefinition } from '@theia/monaco/lib/browser/textmate'; import { injectable } from 'inversify'; -import { JSON_LANGUAGE_ID, JSONC_LANGUAGE_ID } from '../common'; @injectable() -export class JsonGrammarContribution implements LanguageGrammarDefinitionContribution { +export class JsonContribution implements LanguageGrammarDefinitionContribution { + readonly JSON_LANGUAGE_ID = 'json'; + readonly JSONC_LANGUAGE_ID = 'jsonc'; readonly config: monaco.languages.LanguageConfiguration = { 'comments': { @@ -43,7 +44,7 @@ export class JsonGrammarContribution implements LanguageGrammarDefinitionContrib registerTextmateLanguage(registry: TextmateRegistry): void { monaco.languages.register({ - id: JSON_LANGUAGE_ID, + id: this.JSON_LANGUAGE_ID, 'aliases': [ 'JSON', 'json' @@ -69,7 +70,7 @@ export class JsonGrammarContribution implements LanguageGrammarDefinitionContrib ] }); - monaco.languages.setLanguageConfiguration(JSON_LANGUAGE_ID, this.config); + monaco.languages.setLanguageConfiguration(this.JSON_LANGUAGE_ID, this.config); const jsonGrammar = require('../../data/json.tmLanguage.json'); registry.registerTextmateGrammarScope('source.json', { @@ -81,11 +82,11 @@ export class JsonGrammarContribution implements LanguageGrammarDefinitionContrib } }); - registry.mapLanguageIdToTextmateGrammar(JSON_LANGUAGE_ID, 'source.json'); + registry.mapLanguageIdToTextmateGrammar(this.JSON_LANGUAGE_ID, 'source.json'); // jsonc monaco.languages.register({ - id: JSONC_LANGUAGE_ID, + id: this.JSONC_LANGUAGE_ID, 'aliases': [ 'JSON with Comments' ], @@ -94,7 +95,7 @@ export class JsonGrammarContribution implements LanguageGrammarDefinitionContrib ] }); - monaco.languages.setLanguageConfiguration(JSONC_LANGUAGE_ID, this.config); + monaco.languages.setLanguageConfiguration(this.JSONC_LANGUAGE_ID, this.config); const jsoncGrammar = require('../../data/jsonc.tmLanguage.json'); registry.registerTextmateGrammarScope('source.json.comments', { @@ -105,6 +106,6 @@ export class JsonGrammarContribution implements LanguageGrammarDefinitionContrib }; } }); - registry.mapLanguageIdToTextmateGrammar(JSONC_LANGUAGE_ID, 'source.json.comments'); + registry.mapLanguageIdToTextmateGrammar(this.JSONC_LANGUAGE_ID, 'source.json.comments'); } } 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 6eac2213b4754..5e548699b524e 100644 --- a/packages/textmate-grammars/src/browser/textmate-grammars-frontend-module.ts +++ b/packages/textmate-grammars/src/browser/textmate-grammars-frontend-module.ts @@ -56,6 +56,7 @@ import { GoContribution } from './go'; import { RustContribution } from './rust'; import { PhpGrammarContribution } from './php'; import { CppContribution } from './cpp'; +import { JsonContribution } from './json'; export default new ContainerModule(bind => { bind(BatContribution).toSelf().inSingletonScope(); @@ -177,4 +178,7 @@ export default new ContainerModule(bind => { bind(CppContribution).toSelf().inSingletonScope(); bind(LanguageGrammarDefinitionContribution).toService(CppContribution); + + bind(JsonContribution).toSelf().inSingletonScope(); + bind(LanguageGrammarDefinitionContribution).toService(JsonContribution); });