From e9f0b2d03b8929a363d69f93621eac1899677974 Mon Sep 17 00:00:00 2001 From: Mark Sujew Date: Tue, 20 Jul 2021 11:32:32 +0200 Subject: [PATCH] Rename `extensions` to `fileExtensions` --- CHANGELOG.md | 7 +++++++ examples/arithmetics/package.json | 2 +- .../arithmetics/src/language-server/generated/module.ts | 4 ++-- examples/domainmodel/package.json | 2 +- .../domainmodel/src/language-server/generated/module.ts | 4 ++-- examples/statemachine/package.json | 2 +- .../statemachine/src/language-server/generated/module.ts | 4 ++-- packages/generator-langium/langium-template/package.json | 2 +- packages/langium-cli/src/generator/module-generator.ts | 6 +++--- packages/langium-cli/src/generator/textmate-generator.ts | 2 +- packages/langium-cli/src/package.ts | 2 +- packages/langium/package.json | 2 +- packages/langium/src/grammar/generated/module.ts | 4 ++-- 13 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..58e5aa52e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Change Log + +## v0.2.0 + +[Breaking Changes:](#breaking_changes_0.2.0) + +- [langium-cli] The `extensions` field in langium configs was renamed to `fileExtensions`. [#173](https://github.com/langium/langium/pull/173) diff --git a/examples/arithmetics/package.json b/examples/arithmetics/package.json index 1bb33e5d0..b0b0ab462 100644 --- a/examples/arithmetics/package.json +++ b/examples/arithmetics/package.json @@ -37,7 +37,7 @@ "langium": { "languageId": "arithmetics", "grammar": "src/language-server/arithmetics.langium", - "extensions": [".calc"], + "fileExtensions": [".calc"], "out": "src/language-server/generated", "textMate": { "out": "syntaxes/arithmetics.tmLanguage.json" diff --git a/examples/arithmetics/src/language-server/generated/module.ts b/examples/arithmetics/src/language-server/generated/module.ts index d3fb07bca..98e4233ed 100644 --- a/examples/arithmetics/src/language-server/generated/module.ts +++ b/examples/arithmetics/src/language-server/generated/module.ts @@ -8,7 +8,7 @@ import { ArithmeticsAstReflection } from './ast'; import { ArithmeticsGrammarAccess } from './grammar-access'; import { Parser } from './parser'; -const metaData = { +export const languageMetaData = { languageId: 'arithmetics', fileExtensions: ['.calc'] }; @@ -19,5 +19,5 @@ export const ArithmeticsGeneratedModule: Module new ArithmeticsGrammarAccess(), AstReflection: () => new ArithmeticsAstReflection(), - LanguageMetaData: () => metaData + LanguageMetaData: () => languageMetaData }; diff --git a/examples/domainmodel/package.json b/examples/domainmodel/package.json index 1b4dda7b7..63366d72a 100644 --- a/examples/domainmodel/package.json +++ b/examples/domainmodel/package.json @@ -30,7 +30,7 @@ "langium": { "languageId": "domain-model", "grammar": "src/language-server/domain-model.langium", - "extensions": [".dmodel"], + "fileExtensions": [".dmodel"], "out": "src/language-server/generated", "textMate": { "out": "syntaxes/domain-model.tmLanguage.json" diff --git a/examples/domainmodel/src/language-server/generated/module.ts b/examples/domainmodel/src/language-server/generated/module.ts index db012dde6..deafa705f 100644 --- a/examples/domainmodel/src/language-server/generated/module.ts +++ b/examples/domainmodel/src/language-server/generated/module.ts @@ -8,7 +8,7 @@ import { DomainModelAstReflection } from './ast'; import { DomainModelGrammarAccess } from './grammar-access'; import { Parser } from './parser'; -const metaData = { +export const languageMetaData = { languageId: 'domain-model', fileExtensions: ['.dmodel'] }; @@ -19,5 +19,5 @@ export const DomainModelGeneratedModule: Module new DomainModelGrammarAccess(), AstReflection: () => new DomainModelAstReflection(), - LanguageMetaData: () => metaData + LanguageMetaData: () => languageMetaData }; diff --git a/examples/statemachine/package.json b/examples/statemachine/package.json index 1778d24fb..01515509c 100644 --- a/examples/statemachine/package.json +++ b/examples/statemachine/package.json @@ -29,7 +29,7 @@ "langium": { "languageId": "statemachine", "grammar": "src/language-server/statemachine.langium", - "extensions": [".statemachine"], + "fileExtensions": [".statemachine"], "out": "src/language-server/generated", "textMate": { "out": "./syntaxes/statemachine.tmLanguage.json" diff --git a/examples/statemachine/src/language-server/generated/module.ts b/examples/statemachine/src/language-server/generated/module.ts index 861eb4d84..d8f88ea35 100644 --- a/examples/statemachine/src/language-server/generated/module.ts +++ b/examples/statemachine/src/language-server/generated/module.ts @@ -8,7 +8,7 @@ import { StatemachineAstReflection } from './ast'; import { StatemachineGrammarAccess } from './grammar-access'; import { Parser } from './parser'; -const metaData = { +export const languageMetaData = { languageId: 'statemachine', fileExtensions: ['.statemachine'] }; @@ -19,5 +19,5 @@ export const StatemachineGeneratedModule: Module new StatemachineGrammarAccess(), AstReflection: () => new StatemachineAstReflection(), - LanguageMetaData: () => metaData + LanguageMetaData: () => languageMetaData }; diff --git a/packages/generator-langium/langium-template/package.json b/packages/generator-langium/langium-template/package.json index 465f07e4b..9b22b87a8 100644 --- a/packages/generator-langium/langium-template/package.json +++ b/packages/generator-langium/langium-template/package.json @@ -29,7 +29,7 @@ "langium": { "languageId": "<%= language-id %>", "grammar": "src/language-server/<%= language-id %>.langium", - "extensions": <%= file-extension %>, + "fileExtensions": <%= file-extension %>, "out": "src/language-server/generated", "textMate": { "out": "syntaxes/<%= language-id %>.tmLanguage.json" diff --git a/packages/langium-cli/src/generator/module-generator.ts b/packages/langium-cli/src/generator/module-generator.ts index 3c66de065..8801caee3 100644 --- a/packages/langium-cli/src/generator/module-generator.ts +++ b/packages/langium-cli/src/generator/module-generator.ts @@ -24,10 +24,10 @@ export function generateModule(grammar: langium.Grammar, config: LangiumConfig): "import { Parser } from './parser';", NL, NL ); - node.append('const metaData = {', NL); + node.append('export const languageMetaData = {', NL); node.indent(metaData => { metaData.append(`languageId: '${config.languageId}',`, NL); - metaData.append(`fileExtensions: [${config.extensions && config.extensions.map(e => appendQuotesAndDot(e)).join(', ')}]`, NL); + metaData.append(`fileExtensions: [${config.fileExtensions && config.fileExtensions.map(e => appendQuotesAndDot(e)).join(', ')}]`, NL); }); node.append('};', NL, NL); @@ -41,7 +41,7 @@ export function generateModule(grammar: langium.Grammar, config: LangiumConfig): '},', NL, 'GrammarAccess: () => new ', grammar.name, 'GrammarAccess(),', NL, 'AstReflection: () => new ', grammar.name, 'AstReflection(),', NL, - 'LanguageMetaData: () => metaData', NL + 'LanguageMetaData: () => languageMetaData', NL ); }); node.append('};', NL); diff --git a/packages/langium-cli/src/generator/textmate-generator.ts b/packages/langium-cli/src/generator/textmate-generator.ts index e0636f0f1..ce0c9096b 100644 --- a/packages/langium-cli/src/generator/textmate-generator.ts +++ b/packages/langium-cli/src/generator/textmate-generator.ts @@ -49,7 +49,7 @@ export function generateTextMate(grammar: langium.Grammar, config: LangiumConfig const json: TextMateGrammar = { name: config.languageId, scopeName: `source.${config.languageId}`, - fileTypes: config.extensions ?? [], + fileTypes: config.fileExtensions ?? [], patterns: getPatterns(grammar, config), repository: getRepository(grammar, config) }; diff --git a/packages/langium-cli/src/package.ts b/packages/langium-cli/src/package.ts index 34439792f..95b8d5bc1 100644 --- a/packages/langium-cli/src/package.ts +++ b/packages/langium-cli/src/package.ts @@ -16,7 +16,7 @@ export interface LangiumConfig { /** Path to the grammar file */ grammar?: string /** File extensions with leading `.` */ - extensions?: string[] + fileExtensions?: string[] /** Main output directory for TypeScript code */ out?: string /** Enable generating a TextMate syntax highlighting file */ diff --git a/packages/langium/package.json b/packages/langium/package.json index d15ad9757..fd5152dc3 100644 --- a/packages/langium/package.json +++ b/packages/langium/package.json @@ -31,7 +31,7 @@ "langium": { "languageId": "langium", "grammar": "src/grammar/langium-grammar.langium", - "extensions": [ + "fileExtensions": [ "langium" ], "out": "src/grammar/generated", diff --git a/packages/langium/src/grammar/generated/module.ts b/packages/langium/src/grammar/generated/module.ts index b005387cf..3c4a3bbb3 100644 --- a/packages/langium/src/grammar/generated/module.ts +++ b/packages/langium/src/grammar/generated/module.ts @@ -9,7 +9,7 @@ import { LangiumGrammarAstReflection } from './ast'; import { LangiumGrammarGrammarAccess } from './grammar-access'; import { Parser } from './parser'; -const metaData = { +export const languageMetaData = { languageId: 'langium', fileExtensions: ['.langium'] }; @@ -20,5 +20,5 @@ export const LangiumGrammarGeneratedModule: Module new LangiumGrammarGrammarAccess(), AstReflection: () => new LangiumGrammarAstReflection(), - LanguageMetaData: () => metaData + LanguageMetaData: () => languageMetaData };