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 json grammar to textmate-grammars package #6622

Merged
merged 1 commit into from
Nov 25, 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/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();
});
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);
});