eclipse-xtext / eclipse-xtext/xtext

parsing issue affecting content assist

Open
#2,529 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

confirmed
Dominant language
Java
Stars
831
Forks
330
Avg merge
3d 7h
Merged PRs (30d)
12

Description

Given the following grammar definition

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals hidden(SL_COMMENT, WS)

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

World:
    {World}
    fooBars+=FooBar*
    ;

FooBar:
    Foo|Bar
;

Foo:
    "Foo" name=ID '{'
      fooDef=FooDef
    '}'
;

FooDef:
    "FooDef" name=ID '{'
    "barRef" '=' barRef=[Bar|ID] ';'
    '}';

Bar:
    "Bar" name=ID '{'
    '}';

The following code works just fine:

Bar bar1{}

Foo foo1
{
	FooDef fd
	{
		barRef=bar1;
	}
}

Reversing the definitions of bar1 and foo1 only seems like working fine (it validates):

Foo foo1
{
	FooDef fd
	{
		barRef=bar1;
	}
}

Bar bar1{}

but actually, if you try to use the content assist after bar Ref= you will see it doesn't work.

The internal parser (antlr?) is confused because of the closing curly bracket of foo1 so everything after the foo1 definition is not parsed anymore.

The workaround is:

FooDef:
    "FooDef" name=ID '{'
    	x=X
    '}';
    
X:
	"barRef" '=' barRef=[Bar|ID] ';'
;   

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the supplied grammar and document order as the reproducer, then inspect Xtext's parser and content-assist handling for the cross-reference after FooDef. Verify the case where Foo appears before Bar and content assist is invoked after barRef=; done means bar1 is offered and the later Bar definition remains parsed correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.