Skip to content

Use of the generated isTYPE() function #617

Answered by msujew
goto40 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @goto40,

I'm a bit confused, since I couldn't reproduce the problem that you experience with your repository. In general, the langium-cli will generate code (the AstReflection) that allows to perform Class-like inheritance checking based on the $type attribute and nothing else.

I've used a small test script:

const ast = require('./language-server/generated/ast');
const isScalar = ast.isMsgScalarAttribute({ $type: 'MsgScalarAttribute' });
const isArray = ast.isMsgScalarAttribute({ $type: 'MsgArrayAttribute' });
console.log('scalar: ' + isScalar);
console.log('array: ' + isArray);

However, it prints that MsgArrayAttribute isn't a MsgScalarAttribute as expected. Can you provide me with a…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@goto40
Comment options

@msujew
Comment options

Answer selected by goto40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants