Skip to content

Optional rule content breaks completion #1955

@AresEkb

Description

@AresEkb

Langium version: 3.5.0
Package name: langium

Steps To Reproduce

Use the following grammar:

grammar Test

entry Document:
    Annotation
    'document' name=ID;

fragment Annotation:
    ('@annotation' annotation=STRING)?;

terminal ID: /[_a-zA-Z][\w_]*/;
terminal STRING: /'(\\.|[^'])*'/; 

hidden terminal WS: /\s+/;

Run completion for an empty document

The current behavior

It will show only one proposal: @annotation

The expected behavior

But two proposals are expected: @annotation and document

Additional information

If you replace fragment by the embedded rule, then completion works as expected:

grammar Test

entry Document:
    ('@annotation' annotation=STRING)?
    'document' name=ID;

terminal ID: /[_a-zA-Z][\w_]*/;
terminal STRING: /'(\\.|[^'])*'/; 

hidden terminal WS: /\s+/;

Metadata

Metadata

Assignees

No one assigned

    Labels

    completionCompletion related issue

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions