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

Problem with content assist and grammar fragments #2600

Open
meysholdt opened this issue May 18, 2017 · 4 comments
Open

Problem with content assist and grammar fragments #2600

meysholdt opened this issue May 18, 2017 · 4 comments
Assignees

Comments

@meysholdt
Copy link
Contributor

For grammar

Model:
	foo+=(Works | Broken)*;

Works:
	"works" name=ID (ids+=ID ("." ids+=ID)* ";")* (refs+=[Works|ID] ("." refs+=[Works|ID])* "X" ";")*;

Broken:
	"broken" name=ID Fragment (refs+=[Broken|ID] ("." refs+=[Broken|ID])* "X" ";")*;

fragment Fragment *:
	(ids+=ID ("." ids+=ID)* ";")*;

with document

 works n x.x; n.n X;
 broken n x.x; n.n X;

The following problem occurs:
When triggering content assist at n.|n, I expect n to be proposed. This works fine for the first n.n, but for the second nothing is proposed.

The expectation is fulfilled when setting the parameter strict to false in ContentAssistContextFactory.java:213

@cdietrich
Copy link
Member

similar grammar with problems

Model:
	DEFINE STREAM name=ID 		
;

fragment STREAM: ('stream');
fragment DEFINE: ('define' );

@szarnekow szarnekow self-assigned this Jul 20, 2017
@szarnekow
Copy link
Contributor

@cdietrich Your example grammar appears to be broken. The fragments should be defined as whildcards. Looks like a validation is missing for the grammar lang.

@cdietrich
Copy link
Member

hi, what do you mean by

"defined as wildcards"

@szarnekow
Copy link
Contributor

fragment STREAM: ('stream');
fragment DEFINE: ('define' );

is equivalent to

fragment STREAM returns EString: ('stream');
fragment DEFINE returns EString: ('define' );

thus these fragments are data type rules and we do not propose anything for DT rules.

fragment STREAM returns Model: ('stream'); // typed fragments can be used by rules where the 'current' is of type Model
fragment DEFINE returns Model: ('define' );

or

fragment STREAM *: ('stream'); // wildcard fragment can be used everywhere
fragment DEFINE *: ('define' );

turns those two rules into proper parser rule fragments.

@szarnekow szarnekow transferred this issue from eclipse/xtext-core Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants