Skip to content
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

Broken Completion Context Calculation #1570

Open
cdietrich opened this issue Jul 5, 2024 · 0 comments
Open

Broken Completion Context Calculation #1570

cdietrich opened this issue Jul 5, 2024 · 0 comments
Labels
bug Something isn't working completion Completion related issue

Comments

@cdietrich
Copy link
Contributor

we have another case where the completion context calculation is broken

here is the grammar

entry Model:
    (persons+=Person | greetings+=Greeting | structs+=Struct)*;

Struct:
    "struct" name=ID  '{' 
        (data=ID (Fields)*)
    '}';

fragment Fields*:
    "fields" content+=FieldShorthand (',' content+=FieldShorthand)+;

FieldShorthand infers MappedField:
    FieldPartOfMappedField;

fragment FieldPartOfMappedField*:
     field=Expression;
 
Expression:
    DotExpression;

DotExpression infers Expression:
    Primary ({infer DotExpression.base=current} '.' target=DotTarget)*;

Primary infers Expression:
    {infer Parenthesis} '(' expr=Expression ')' |
    RefExpression |
    IdRef;

IdRef:
    {infer IdRef} "id";

RefExpression: ref=[Person:ID];

Person:
    'person' name=ID;

DotTarget: name=ID;

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

hidden terminal WS: /\s+/;
terminal ID: /[_a-zA-Z][\w_]*/;
terminal INT returns number: /[0-9]+/;
terminal STRING: /"(\\.|[^"\\])*"|'(\\.|[^'\\])*'/;

hidden terminal ML_COMMENT: /\/\*[\s\S]*?\*\//;
hidden terminal SL_COMMENT: /\/\/[^\n\r]*/;

and the sample model

person A
person B

struct x {
    xxx
    fields A, |
}

the context is Struct and not MappedField.

pot.workaround

fragment Fields*:
    "fields" content+=FieldShorthand1 ( content+=FieldShorthand2)+;

FieldShorthand1 infers MappedField:
    field=Expression;

FieldShorthand2 infers MappedField:
    ',' field=Expression;
@cdietrich cdietrich added the bug Something isn't working label Jul 5, 2024
@msujew msujew added the completion Completion related issue label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working completion Completion related issue
Projects
None yet
Development

No branches or pull requests

2 participants