-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change cross-reference syntax #200
Comments
Note: We should still allow the old syntax, but mark it with a validation error. This way we can offer a code action to fix it. |
Let use at least warning
I can't recall that we were worried about clashes with Java syntax as the Xtext grammar language was invented |
I understand why that decision was made: it's like the mathematical notation for sets |
A CLI to convert XText to Langium would be so nice 😍 |
If we change the syntax as proposed, we could enable alternative types for cross-references: |
The idea to have alternatives However, I have concerns about
I'd propose to replace it with |
I'd wait for real-world use cases first. |
I just stumbled over this issue. In the spirit of
I vote for switching What do you think? |
A problematic aspect of that is that in Xtext the token name is optional, while in TypeScript the type is optional. We could solve that by making the token name mandatory, but that would increase verbosity. |
Making the token rule name mandatory is not necessary IMO. From the teaching perspective - e.g. in the xtext workshops - the difference in the meaning of While typing I just got the idea of having both optional, i.e. allowing something like |
The similarity to TypeScript is still very confusing to me. |
Right. What about this?
|
If we stay with statemachine example: State:
'state' name=ID
transitions+=Transition*
'end';
Transition:
event=[Event] '=>' state=[State];
Why not be more explicit or more clear and express what we are currently want to know: Property I don't recall it why in Xtext it was important to have |
Image you want allow referencing entities by a different string than it's declared name/id, maybe from a different DSL, because the original name/id syntax would cause a conflict. I advocate a simple and pragmatic notation that is as concise as possible but as verbose as necessary to keep users on the right track. |
I don't really have an opinion on your proposal yet.
or even like
so having everything wrapped by the bracket keeps belonging things together (I never thought about this before). We could also consider adding the target type to the property name (LHS) instead to the RHS, like
I actually don't like the |
@sailingKieler Both suggestions @spoenemann Moving the Type to the LHS in other hand will break a lot as we will need to move |
@sailingKieler being able to put arbitrary white space between tokens applies to all syntaxes. |
This is related to the discussion at #341 (comment). Now I'm inclined to make the cross-reference token mandatory and add a code action that inserts |
We had an internal chat about this and decided to keep the current syntax. Feel free to drop new thoughts here anyway. |
The cross-reference syntax of Xtext is
[Type|TOKEN]
, whereType
is the AST type of the reference andTOKEN
is a terminal rule or datatype rule that shall be parsed here. This syntax is misleading because in the context of TypeScript|
means an alternative.Proposals:
[Type: TOKEN]
,[TOKEN: Type]
Of course omitting the token shall still be possible:
[Type]
(the token defaults toID
)The text was updated successfully, but these errors were encountered: