Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

langium-cli

Package Overview
Dependencies
Maintainers
0
Versions
45
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 3.1.0-next.cbc5db3 to 3.1.0

15

lib/generator/ast-generator.js
import { expandToNode, joinToNode, toString } from 'langium/generate';
import { AstUtils, MultiMap, GrammarAST } from 'langium';
import { collectAst, collectTypeHierarchy, findReferenceTypes, isAstType, mergeTypesAndInterfaces } from 'langium/grammar';
import { collectAst, collectTypeHierarchy, findReferenceTypes, isAstType, mergeTypesAndInterfaces, escapeQuotes } from 'langium/grammar';
import { generatedHeader } from './node-util.js';

@@ -44,3 +44,3 @@ import { collectTerminalRegexps } from './langium-util.js';

getAllTypes(): string[] {
return [${typeNames.map(e => `'${e}'`).join(', ')}];
return [${typeNames.join(', ')}];
}

@@ -72,5 +72,5 @@

? expandToNode `
case '${interfaceType.name}': {
case ${interfaceType.name}: {
return {
name: '${interfaceType.name}',
name: ${interfaceType.name},
properties: [

@@ -100,3 +100,3 @@ ${buildPropertyType(props)}

const defaultValue = stringifyDefaultValue(property.defaultValue);
return `{ name: '${property.name}'${defaultValue ? `, defaultValue: ${defaultValue}` : ''} }`;
return `{ name: '${escapeQuotes(property.name, "'")}'${defaultValue ? `, defaultValue: ${defaultValue}` : ''} }`;
}, { separator: ',', appendNewLineIfNotEmpty: true });

@@ -106,3 +106,4 @@ }

if (typeof value === 'string') {
return `"${value}"`;
// Escape all double quotes
return `'${escapeQuotes(value, "'")}'`;
}

@@ -126,3 +127,3 @@ else if (Array.isArray(value)) {

${joinToNode(buckets.entriesGroupedByKey(), ([target, refs]) => expandToNode `
${joinToNode(refs, ref => `case '${ref}':`, { appendNewLineIfNotEmpty: true, skipNewLineAfterLastItem: true })} {
${joinToNode(refs, ref => `case '${escapeQuotes(ref, "'")}':`, { appendNewLineIfNotEmpty: true, skipNewLineAfterLastItem: true })} {
return ${target};

@@ -129,0 +130,0 @@ }

{
"name": "langium-cli",
"version": "3.1.0-next.cbc5db3",
"version": "3.1.0",
"description": "CLI for Langium - the language engineering tool",

@@ -50,4 +50,4 @@ "homepage": "https://langium.org",

"jsonschema": "~1.4.1",
"langium": "3.1.0-next.cbc5db3",
"langium-railroad": "3.1.0-next.cbc5db3",
"langium": "~3.1.0",
"langium-railroad": "~3.1.0",
"lodash": "~4.17.21"

@@ -54,0 +54,0 @@ },

@@ -11,3 +11,3 @@ /******************************************************************************

import { AstUtils, MultiMap, GrammarAST } from 'langium';
import { collectAst, collectTypeHierarchy, findReferenceTypes, isAstType, mergeTypesAndInterfaces } from 'langium/grammar';
import { collectAst, collectTypeHierarchy, findReferenceTypes, isAstType, mergeTypesAndInterfaces, escapeQuotes } from 'langium/grammar';
import { generatedHeader } from './node-util.js';

@@ -58,3 +58,3 @@ import { collectTerminalRegexps } from './langium-util.js';

getAllTypes(): string[] {
return [${typeNames.map(e => `'${e}'`).join(', ')}];
return [${typeNames.join(', ')}];
}

@@ -90,5 +90,5 @@

? expandToNode`
case '${interfaceType.name}': {
case ${interfaceType.name}: {
return {
name: '${interfaceType.name}',
name: ${interfaceType.name},
properties: [

@@ -125,3 +125,3 @@ ${buildPropertyType(props)}

const defaultValue = stringifyDefaultValue(property.defaultValue);
return `{ name: '${property.name}'${defaultValue ? `, defaultValue: ${defaultValue}` : ''} }`;
return `{ name: '${escapeQuotes(property.name, "'")}'${defaultValue ? `, defaultValue: ${defaultValue}` : ''} }`;
},

@@ -134,3 +134,4 @@ { separator: ',', appendNewLineIfNotEmpty: true}

if (typeof value === 'string') {
return `"${value}"`;
// Escape all double quotes
return `'${escapeQuotes(value, "'")}'`;
} else if (Array.isArray(value)) {

@@ -155,3 +156,3 @@ return `[${value.map(e => stringifyDefaultValue(e)).join(', ')}]`;

([target, refs]) => expandToNode`
${joinToNode(refs, ref => `case '${ref}':`, { appendNewLineIfNotEmpty: true, skipNewLineAfterLastItem: true})} {
${joinToNode(refs, ref => `case '${escapeQuotes(ref, "'")}':`, { appendNewLineIfNotEmpty: true, skipNewLineAfterLastItem: true})} {
return ${target};

@@ -158,0 +159,0 @@ }

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