langium-cli
Advanced tools
Comparing version 0.5.0 to 0.6.0-next.62c127c
@@ -38,12 +38,19 @@ "use strict"; | ||
function generateAstReflection(config, astTypes) { | ||
const typeNames = astTypes.interfaces.map(t => `'${t.name}'`) | ||
.concat(astTypes.unions.map(t => `'${t.name}'`)) | ||
const typeNames = astTypes.interfaces.map(t => t.name) | ||
.concat(astTypes.unions.map(t => t.name)) | ||
.sort(); | ||
const crossReferenceTypes = buildCrossReferenceTypes(astTypes); | ||
const reflectionNode = new langium_1.CompositeGeneratorNode(); | ||
reflectionNode.append(`export type ${config.projectName}AstType = ${typeNames.join(' | ')};`, langium_1.NL, langium_1.NL, `export class ${config.projectName}AstReflection implements AstReflection {`, langium_1.NL, langium_1.NL); | ||
reflectionNode.append(`export interface ${config.projectName}AstType {`, langium_1.NL); | ||
reflectionNode.indent(astTypeBody => { | ||
for (const type of typeNames) { | ||
astTypeBody.append(type, ': ', type, langium_1.NL); | ||
} | ||
}); | ||
reflectionNode.append('}', langium_1.NL, langium_1.NL); | ||
reflectionNode.append(`export class ${config.projectName}AstReflection implements AstReflection {`, langium_1.NL, langium_1.NL); | ||
reflectionNode.indent(classBody => { | ||
classBody.append('getAllTypes(): string[] {', langium_1.NL); | ||
classBody.indent(allTypes => { | ||
allTypes.append(`return [${typeNames.join(', ')}];`, langium_1.NL); | ||
allTypes.append(`return [${typeNames.map(e => `'${e}'`).join(', ')}];`, langium_1.NL); | ||
}); | ||
@@ -50,0 +57,0 @@ classBody.append('}', langium_1.NL, langium_1.NL, 'isInstance(node: unknown, type: string): boolean {', langium_1.NL); |
{ | ||
"name": "langium-cli", | ||
"version": "0.5.0", | ||
"version": "0.6.0-next.62c127c", | ||
"description": "CLI for Langium - the language engineering tool", | ||
@@ -41,3 +41,3 @@ "homepage": "https://langium.org", | ||
"jsonschema": "^1.4.0", | ||
"langium": "~0.5.0", | ||
"langium": "0.6.0-next.62c127c", | ||
"lodash": "^4.17.21" | ||
@@ -44,0 +44,0 @@ }, |
@@ -50,4 +50,4 @@ /****************************************************************************** | ||
function generateAstReflection(config: LangiumConfig, astTypes: AstTypes): GeneratorNode { | ||
const typeNames: string[] = astTypes.interfaces.map(t => `'${t.name}'`) | ||
.concat(astTypes.unions.map(t => `'${t.name}'`)) | ||
const typeNames: string[] = astTypes.interfaces.map(t => t.name) | ||
.concat(astTypes.unions.map(t => t.name)) | ||
.sort(); | ||
@@ -57,4 +57,11 @@ const crossReferenceTypes = buildCrossReferenceTypes(astTypes); | ||
reflectionNode.append(`export interface ${config.projectName}AstType {`, NL); | ||
reflectionNode.indent(astTypeBody => { | ||
for (const type of typeNames) { | ||
astTypeBody.append(type, ': ', type, NL); | ||
} | ||
}); | ||
reflectionNode.append('}', NL, NL); | ||
reflectionNode.append( | ||
`export type ${config.projectName}AstType = ${typeNames.join(' | ')};`, NL, NL, | ||
`export class ${config.projectName}AstReflection implements AstReflection {`, NL, NL | ||
@@ -66,3 +73,3 @@ ); | ||
classBody.indent(allTypes => { | ||
allTypes.append(`return [${typeNames.join(', ')}];`, NL); | ||
allTypes.append(`return [${typeNames.map(e => `'${e}'`).join(', ')}];`, NL); | ||
}); | ||
@@ -69,0 +76,0 @@ classBody.append('}', NL, NL, 'isInstance(node: unknown, type: string): boolean {', NL); |
Sorry, the diff of this file is not supported yet
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
200693
3214
+ Added@chevrotain/cst-dts-gen@10.4.210.5.0(transitive)
+ Added@chevrotain/gast@10.4.210.5.0(transitive)
+ Added@chevrotain/types@10.4.210.5.0(transitive)
+ Added@chevrotain/utils@10.4.210.5.0(transitive)
+ Addedchevrotain@10.4.210.5.0(transitive)
+ Addedchevrotain-allstar@0.1.7(transitive)
+ Addedlangium@0.6.0-next.62c127c(transitive)
- Removed@chevrotain/types@9.1.0(transitive)
- Removed@chevrotain/utils@9.1.0(transitive)
- Removedchevrotain@9.1.0(transitive)
- Removedlangium@0.5.0(transitive)
Updatedlangium@0.6.0-next.62c127c