Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions examples/arithmetics/src/language-server/generated/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ export class ArithmeticsAstReflection extends langium.AbstractAstReflection {
properties: {
args: {
name: Definition.args,
defaultValue: []
defaultValue: [],
optional: true
},
expr: {
name: Definition.expr
Expand Down Expand Up @@ -260,7 +261,8 @@ export class ArithmeticsAstReflection extends langium.AbstractAstReflection {
properties: {
args: {
name: FunctionCall.args,
defaultValue: []
defaultValue: [],
optional: true
},
func: {
name: FunctionCall.func,
Expand All @@ -277,7 +279,8 @@ export class ArithmeticsAstReflection extends langium.AbstractAstReflection {
},
statements: {
name: Module.statements,
defaultValue: []
defaultValue: [],
optional: true
}
},
superTypes: []
Expand Down
15 changes: 10 additions & 5 deletions examples/domainmodel/src/language-server/generated/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ export class DomainModelAstReflection extends langium.AbstractAstReflection {
properties: {
elements: {
name: Domainmodel.elements,
defaultValue: []
defaultValue: [],
optional: true
}
},
superTypes: []
Expand All @@ -180,14 +181,16 @@ export class DomainModelAstReflection extends langium.AbstractAstReflection {
properties: {
features: {
name: Entity.features,
defaultValue: []
defaultValue: [],
optional: true
},
name: {
name: Entity.name
},
superType: {
name: Entity.superType,
referenceType: Entity.$type
referenceType: Entity.$type,
optional: true
}
},
superTypes: [Type.$type]
Expand All @@ -197,7 +200,8 @@ export class DomainModelAstReflection extends langium.AbstractAstReflection {
properties: {
many: {
name: Feature.many,
defaultValue: false
defaultValue: false,
optional: true
},
name: {
name: Feature.name
Expand All @@ -214,7 +218,8 @@ export class DomainModelAstReflection extends langium.AbstractAstReflection {
properties: {
elements: {
name: PackageDeclaration.elements,
defaultValue: []
defaultValue: [],
optional: true
},
name: {
name: PackageDeclaration.name
Expand Down
24 changes: 16 additions & 8 deletions examples/requirements/src/language-server/generated/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ export class RequirementsAndTestsAstReflection extends langium.AbstractAstReflec
environments: {
name: Requirement.environments,
defaultValue: [],
referenceType: Environment.$type
referenceType: Environment.$type,
optional: true
},
name: {
name: Requirement.name
Expand All @@ -245,15 +246,18 @@ export class RequirementsAndTestsAstReflection extends langium.AbstractAstReflec
name: RequirementModel.$type,
properties: {
contact: {
name: RequirementModel.contact
name: RequirementModel.contact,
optional: true
},
environments: {
name: RequirementModel.environments,
defaultValue: []
defaultValue: [],
optional: true
},
requirements: {
name: RequirementModel.requirements,
defaultValue: []
defaultValue: [],
optional: true
}
},
superTypes: []
Expand All @@ -264,7 +268,8 @@ export class RequirementsAndTestsAstReflection extends langium.AbstractAstReflec
environments: {
name: Test.environments,
defaultValue: [],
referenceType: Environment.$type
referenceType: Environment.$type,
optional: true
},
name: {
name: Test.name
Expand All @@ -275,7 +280,8 @@ export class RequirementsAndTestsAstReflection extends langium.AbstractAstReflec
referenceType: Requirement.$type
},
testFile: {
name: Test.testFile
name: Test.testFile,
optional: true
}
},
superTypes: []
Expand All @@ -284,11 +290,13 @@ export class RequirementsAndTestsAstReflection extends langium.AbstractAstReflec
name: TestModel.$type,
properties: {
contact: {
name: TestModel.contact
name: TestModel.contact,
optional: true
},
tests: {
name: TestModel.tests,
defaultValue: []
defaultValue: [],
optional: true
}
},
superTypes: []
Expand Down
15 changes: 10 additions & 5 deletions examples/statemachine/src/language-server/generated/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,16 @@ export class StatemachineAstReflection extends langium.AbstractAstReflection {
actions: {
name: State.actions,
defaultValue: [],
referenceType: Command.$type
referenceType: Command.$type,
optional: true
},
name: {
name: State.name
},
transitions: {
name: State.transitions,
defaultValue: []
defaultValue: [],
optional: true
}
},
superTypes: []
Expand All @@ -179,11 +181,13 @@ export class StatemachineAstReflection extends langium.AbstractAstReflection {
properties: {
commands: {
name: Statemachine.commands,
defaultValue: []
defaultValue: [],
optional: true
},
events: {
name: Statemachine.events,
defaultValue: []
defaultValue: [],
optional: true
},
init: {
name: Statemachine.init,
Expand All @@ -194,7 +198,8 @@ export class StatemachineAstReflection extends langium.AbstractAstReflection {
},
states: {
name: Statemachine.states,
defaultValue: []
defaultValue: [],
optional: true
}
},
superTypes: []
Expand Down
3 changes: 3 additions & 0 deletions packages/langium-cli/src/generator/ast-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ function buildPropertyMetaData(props: Property[], ownerTypeName: string): Genera
if (refType) {
attributes.push(`referenceType: ${refType}.$type`);
}
if (property.optional) {
attributes.push('optional: true');
}

return expandToNode`
${property.name}: {
Expand Down
3 changes: 2 additions & 1 deletion packages/langium/src/grammar/ast-reflection-interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ function buildPropertyMetaData(props: Property[]): { [name: string]: PropertyMet
for (const property of all) {
properties[property.name] = {
name: property.name,
defaultValue: property.defaultValue
defaultValue: property.defaultValue,
...(property.optional ? { optional: true } : {})
};
}
return properties;
Expand Down
Loading
Loading