New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

langium-cli

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

langium-cli - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0-next.62c127c

15

lib/generator/ast-generator.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc