langium-cli
Advanced tools
Comparing version 3.1.0-next.cbc5db3 to 3.1.0
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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 5 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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 5 instances in 1 package
243652
3864
0
+ Addedlangium@3.1.3(transitive)
+ Addedlangium-railroad@3.1.0(transitive)
- Removedlangium@3.1.0-next.cbc5db3(transitive)
- Removedlangium-railroad@3.1.0-next.cbc5db3(transitive)
Updatedlangium@~3.1.0
Updatedlangium-railroad@~3.1.0