Skip to content

Commit

Permalink
Move json grammar to textmate-grammars package
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoliy Bazko <abazko@redhat.com>
  • Loading branch information
tolusha committed Nov 25, 2019
1 parent b8c5e18 commit 797d03b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
3 changes: 0 additions & 3 deletions packages/json/src/browser/json-frontend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand All @@ -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'
Expand All @@ -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', {
Expand All @@ -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'
],
Expand All @@ -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', {
Expand All @@ -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');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
});

0 comments on commit 797d03b

Please sign in to comment.