Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Parser rule used as type for cross-reference is marked as "unused" #1309

Open
JohannesMeierSE opened this issue Nov 30, 2023 · 4 comments · May be fixed by #1391
Open

Parser rule used as type for cross-reference is marked as "unused" #1309

JohannesMeierSE opened this issue Nov 30, 2023 · 4 comments · May be fixed by #1391
Labels
bug Something isn't working

Comments

@JohannesMeierSE
Copy link
Contributor

The following grammar uses the (unassigned) parser rule Person as type in the cross-reference of Greeting in order to link to Neighbors or Friends:

grammar HelloWorld

entry Model:
    (persons+=Neighbor | friends+=Friend | greetings+=Greeting)*;

Neighbor:
    'neighbor' name=ID;
Friend:
    'friend' name=ID;

Person: Neighbor | Friend;

Greeting:
    'Hello' person=[Person:ID] '!';

hidden terminal WS: /\s+/;
terminal ID: /[_a-zA-Z][\w_]*/;

The current behavior

Nevertheless, the parser rule Person is marked as "unused", e.g. in the Playground:

Screenshot 2023-11-30 at 10 54 04

The expected behavior

I would expect, that Person is not marked as "unused", since it is used as type in the cross-reference.

@JohannesMeierSE JohannesMeierSE added the bug Something isn't working label Nov 30, 2023
@JohannesMeierSE
Copy link
Contributor Author

I am willing to work on this issue.

@msujew
Copy link
Member

msujew commented Nov 30, 2023

This is working as intended. The parser rule is indeed unused. You're supposed to use a type union instead.

@JohannesMeierSE
Copy link
Contributor Author

This is working as intended. The parser rule is indeed unused. You're supposed to use a type union instead.

I see, that makes sense.

What do you think about showing a corresponding hint with a quick-fix to replace the parser rule by the following union type?

grammar HelloWorld

entry Model:
    (persons+=Neighbor | friends+=Friend | greetings+=Greeting)*;

Neighbor:
    'neighbor' name=ID;
Friend:
    'friend' name=ID;

type Person = Neighbor | Friend;

Greeting:
    'Hello' person=[Person:ID] '!';

hidden terminal WS: /\s+/;
terminal ID: /[_a-zA-Z][\w_]*/;

@msujew
Copy link
Member

msujew commented Nov 30, 2023

Sure, I think that's good 👍

JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Dec 12, 2023
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Dec 12, 2023
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Jan 12, 2024
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Feb 16, 2024
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Feb 16, 2024
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Feb 16, 2024
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Feb 29, 2024
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Feb 29, 2024
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Feb 29, 2024
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Oct 8, 2024
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Oct 8, 2024
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Oct 8, 2024
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Feb 17, 2025
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Feb 17, 2025
JohannesMeierSE added a commit to JohannesMeierSE/langium that referenced this issue Feb 17, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
2 participants