eclipse-xtext / eclipse-xtext/xtext

Identifier rule with > 2 alternatives for a cross reference breaks content assist

Open
#2,473 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

In this simple DSL, the content assist fails to offer anything for the eval assignment in Model:

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

Model:
	definitions+=VariableDefinition*
	eval=Expression;

VariableDefinition:
	name=Identifier ('(' parameter=Identifier ')')? '=' value=Expression;

Expression:
	FeatureCall | Literal;

Literal:
	literal=Boolean;

FeatureCall:
	target=[ecore::EObject|Identifier] ('(' argument=Identifier ')')?;

Boolean returns ecore::EString:
	'true' | 'false';

Identifier:
	ID | 'whatever' | 'another';

The problem occurs when the Identifier rule has at least three alternatives. The keywords don't have to otherwise be used anywhere else in the grammar, it's enough that there are > 2 alternatives in the rule to trigger the issue. However, all four uses of Identifier in the grammar above are required to trigger the problem. Otherwise the issue disappears even if there are the > 2 alternatives in the Identifier rule.

It's also strange that true and false are not offered as alternatives, even though they are valid expressions. These seem to be missing from content assist regardless of whether the Identifier-related issue is triggered or not.

Here is an example project with a bug test MyDslCrossReferenceProposalTest that reflects my expectations for what are the minimal correct content assist proposals in this case.

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

Start with the linked example project and its MyDslCrossReferenceProposalTest, then reproduce content assist for the eval assignment in Model. Compare the observed proposals with the test's expected minimal proposals; done means the Identifier alternatives no longer suppress valid proposals and true/false are offered where expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.