Add the ability to use parentheses when declaring `TypeAlternatives`
See original GitHub issueThe Langium grammar allows to create the rule X
, where the property x
is an array of type alternatives, and it has to be possible to declare the corresponding type XType
, as in the example. We should support parentheses in TypeAlternatives
.
X returns XType:
x+=(ID | NUMBER)*;
interface XType {
x: (number | string)[];
}
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Python Parentheses Cheat Sheet - Edlitera
Master how parentheses work in Python to learn to code faster.
Read more >Do the parentheses after the type name make a difference ...
NO: The object is default-initialized, which, for non-class types, leaves it with an indeterminate value (it effectively isn't initialized). These rules ...
Read more >Parentheses | Effective Writing Practices Tutorial
Parentheses are used to explain the statement or provide explanatory information in the sentence.
Read more >Dashes, Parentheses, Brackets, Ellipses - Swarthmore College
DASHES Use a dash to draw attention to parenthetical information, to prepare ... Brackets are used to enclose words that you add to...
Read more >Typing assistance | ReSharper Documentation - JetBrains
Wrap code blocks with braces and parentheses ... With ReSharper, you can select a code block or an expression, then type an opening...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The ability to have an array of strings will remain after the parentheses are added, also I think it’s a “low hanging fruit”, so I’d suggest to implement it.
I would personally prefer an array of strings over mixed strings and numbers, so yes I think the restriction should be ok. This is related to https://github.com/langium/langium/issues/494#issuecomment-1125811597, where I proposed to disallow multiple assignments with different types to the same property. But maybe I’m too strict here and there could be valid use cases to write explicit alternatives to an assignment.
If it’s a “low hanging fruit”, we could still implement this, independently of how we decide about validation.