Default Value for Language Feature #352
Answered
by
msujew
ballcoach12
asked this question in
Q&A
-
I need a way to set default values for language features that are optional in a grammar. In Xtext, you could use a PostProcessor to do this. Is there a way to do this in Langium? I could imagine that it might be accomplished in the grammar definition itself, maybe like this:
|
Beta Was this translation helpful? Give feedback.
Answered by
msujew
Jan 11, 2022
Replies: 1 comment 8 replies
-
Hi @ballcoach12, Interesting proposal, currently there's no built-in way to accomplish this. However, before processing your AST content you could simply run: streamAllContents(rootElement).forEach(e => {
if (isGreeting(e.node) && e.node.name === undefined) {
e.node.name = 'Charlie';
}
}) This should accomplish the same thing for now. |
Beta Was this translation helpful? Give feedback.
8 replies
Answer selected by
ballcoach12
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @ballcoach12,
Interesting proposal, currently there's no built-in way to accomplish this.
However, before processing your AST content you could simply run:
This should accomplish the same thing for now.