eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
665 stars 61 forks source link

getTypeMetaData does not consider returned types #1371

Closed cdietrich closed 4 months ago

cdietrich commented 5 months ago

Given the grammar

interface IAmArray {
   elements: ArrayContent[];
}
interface DeclaredArray extends IAmArray{ }

DeclaredArray returns DeclaredArray:
     'declared' (elements+=ArrayContent)* ';';

ArrayContent:
    name=ID;

AstReflection.getTypeMetaData wont flag the elements of DeclaredArray as array and thus it wont have a default value

cdietrich commented 5 months ago

alternatively: assignMandatoryAstProperties should also check return types.

msujew commented 5 months ago

The issue is that the generated ast reflection currently only considers properties of the current interface, not of the whole interface chain:

https://github.com/eclipse-langium/langium/blob/1f5d1246692aafb70672fb6ce695fefc4e54767c/packages/langium-cli/src/generator/ast-generator.ts#L84

cdietrich commented 4 months ago

nice. thx for the fix. works now as expected