Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Content assist and unordered groups(Somehow content assist does not propose half of my grammar depending on context)
Content assist and unordered groups [message #1756147] Mon, 13 March 2017 08:13 Go to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 29
Registered: March 2015
Junior Member
Hey. I've been struggling with this one now for a few days, hopefully somebody can explain Smile

I have this grammar (full grammar here):

LaunchConfig:
	((explicit?='explicit')? // Eclipse, RAP
		& (manual?='manual')? // All
		& (abstract?='abstract')? // All
		& (foreground?='foreground')? // All  
		& (noConsole?='no-console')? // All but Groups
		& (noValidate?='no-validate')? // Eclipse, RAP
		& (swInstallSupport?='sw-install-allowed')? // Eclipse
		& (replaceEnv?='replace-env')? // All but Groups
		& (stopInMain?='stop-in-main')? // Java
	) type=LaunchConfigType 'configuration' name=FQName 
	(':' superConfig=[LaunchConfig|FQName])? BLOCK_BEGIN
		( // things that may appear only once
			(clears=ClearOption)? // Eclipse, RAP (partial)
			& (workspace=Workspace)? // Eclipse, RAP
			& (workingDir=WorkingDir)? // All but Groups
			& (memory=MemoryOption)? // All but Groups
			& (mainProject=MainProject)? // Java
			& (mainType=MainType)? // Java
			& (application=ApplicationExtPoint)? // Eclipse
			& (product=ProductExtPoint)? // Eclipse
			& (favorites=Favorites)? // All
			& (redirect=Redirect)? // All but Groups
			& (execEnv=ExecutionEnvironment)? // All but Groups
			& (configIniTemplate=ConfigIniTemplate)? // Eclipse
			& (javaMainSearch=JavaMainSearch)? // Java
			& (servletConfig=RapServletConfig)? // RAP
			& (contentProviderProduct=ContentProviderProduct)? // Eclipse, RAP
		)
		( // things that may appear multiple times
			plugins+=AddPlugin // Eclipse, RAP
			| features+=AddFeature // Eclipse, RAP
			| ignore+=IgnorePlugin // Eclipse, RAP
			| groupMembers+=GroupMember // Groups 					// TODO: content assist, validation, update on rename
			| vmArgs+=VmArgument // All but Groups
			| progArgs+=ProgramArgument // All but Groups
			| envVars+=EnvironmentVariable // All but Groups
			| traces+=TraceEnablement // Eclipse, RAP
		)*
	BLOCK_END
;


Everything works as expected, EXCEPT content assist Smile If i have an "empty" launch config like this:

eclipse configuration Something {
    // ...press ctrl space here
}


Content assist proposes all keywords from the first group only, but not a single one from the second group. Once i manually complete a single statement from the second group, it works.

I also tried merging the two groups, but that didn't fix it - it made it a little bit better. If i omit the second group and make every single member of it part of the first group like this:

         (':' superConfig=[LaunchConfig|FQName])? BLOCK_BEGIN
		( // things that may appear only once
			(clears=ClearOption)? // Eclipse, RAP (partial)
			& (workspace=Workspace)? // Eclipse, RAP
			& (workingDir=WorkingDir)? // All but Groups
			& (memory=MemoryOption)? // All but Groups
			& (mainProject=MainProject)? // Java
			& (mainType=MainType)? // Java
			& (application=ApplicationExtPoint)? // Eclipse
			& (product=ProductExtPoint)? // Eclipse
			& (favorites=Favorites)? // All
			& (redirect=Redirect)? // All but Groups
			& (execEnv=ExecutionEnvironment)? // All but Groups
			& (configIniTemplate=ConfigIniTemplate)? // Eclipse
			& (javaMainSearch=JavaMainSearch)? // Java
			& (servletConfig=RapServletConfig)? // RAP
			& (contentProviderProduct=ContentProviderProduct)? // Eclipse, RAP
			// things that may appear multiple times
			& (plugins+=AddPlugin)* // Eclipse, RAP
			& (features+=AddFeature)* // Eclipse, RAP
			& (ignore+=IgnorePlugin)* // Eclipse, RAP
			& (groupMembers+=GroupMember)* // Groups 					// TODO: content assist, validation, update on rename
			& (vmArgs+=VmArgument)* // All but Groups
			& (progArgs+=ProgramArgument)* // All but Groups
			& (envVars+=EnvironmentVariable)* // All but Groups
			& (traces+=TraceEnablement)* // Eclipse, RAP
		)
	BLOCK_END


Now I get proper proposal on the first line. But once I put a statement that can occur multiple times (the ones with *), I ONLY get proposal for that exact element until I manually write something else.

If I change all start to ? and convert the group to a look I of course get warnings that things that now appear once only can overwrite itself...

What is the correct solution to solve this with the grammar? Is there a way? Should I rather accept the overwrite warnings and solve the issue through validation?

Thanks!
Markus
Re: Content assist and unordered groups [message #1756148 is a reply to message #1756147] Mon, 13 March 2017 08:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10873
Registered: July 2009
Senior Member
Hi,

can you create a small artifical example that reproduces this more easily.

please note for understanding: Unordered groups are compiled to a grammar like (a | b | c)*


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Content assist and unordered groups [message #1756151 is a reply to message #1756148] Mon, 13 March 2017 08:44 Go to previous messageGo to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 29
Registered: March 2015
Junior Member
sure, for instance this:

manual eclipse configuration Database_Setup_With_Archive : BaseDataSetupConfig {
	application com.wamas.world.datasetup.WorldDatabaseSetupApplication;
	// here everything is proposed
	memory min=128M max=512M;
	// here everything is proposed
	plugin com.wamas.world.datasetup;
	// here only plugin is proposed
	vm-argument '-Dcom.wamas.database.model=WMS';
	// here only vm-argument is proposed.
	
}


Note: this example is with the "updated" grammar, so all in one group. with the prvious solution, plugin/vm-argument were NOT proposed in the first two examples above.

[Updated on: Mon, 13 March 2017 08:46]

Report message to a moderator

Re: Content assist and unordered groups [message #1756152 is a reply to message #1756151] Mon, 13 March 2017 08:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10873
Registered: July 2009
Senior Member
No, i mean i want a small grammar that i simply can copy & paste

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Content assist and unordered groups [message #1756154 is a reply to message #1756152] Mon, 13 March 2017 09:09 Go to previous messageGo to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 29
Registered: March 2015
Junior Member
Ah, take a look at the grammar I linked above: https://github.com/mduft/lcdsl/blob/master/com.wamas.ide.launching/src/com/wamas/ide/launching/LcDsl.xtext - should not make a difference that this is the full grammer, right?
Re: Content assist and unordered groups [message #1756155 is a reply to message #1756152] Mon, 13 March 2017 09:12 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 223
Registered: June 2013
Senior Member
Think the problem lies in the following line of your grammar between group 1 and 2:

) type=LaunchConfigType 'configuration' name=FQName

As long as you have not entered the mandatory text "configuration", you must not enter something from group 2
Re: Content assist and unordered groups [message #1756170 is a reply to message #1756155] Mon, 13 March 2017 12:11 Go to previous messageGo to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 29
Registered: March 2015
Junior Member
Hm, but I do have entered configuration... Just copy paste the small example from above, it has all relevant parts from all groups in it, and still no content assist. On a side note, i just realized that starting a line with one of the modifiers (e.g. 'manual') will result in a content assist that only contains other modifiers (e.g. 'explicit') but NOT the type (e.g. 'eclipse', 'java', ...) which would also be perfectly valid in this position. Am I doing something wrong?
Re: Content assist and unordered groups [message #1756294 is a reply to message #1756170] Wed, 15 March 2017 07:55 Go to previous messageGo to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 29
Registered: March 2015
Junior Member
....ping Smile
Re: Content assist and unordered groups [message #1756295 is a reply to message #1756294] Wed, 15 March 2017 07:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10873
Registered: July 2009
Senior Member
sorry i dont have the time to create a SMALL reproducible example

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Content assist and unordered groups [message #1756390 is a reply to message #1756295] Thu, 16 March 2017 10:28 Go to previous messageGo to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 29
Registered: March 2015
Junior Member
I will do so, if the real one is not good enough. I will come back with a small grammar Smile
Re: Content assist and unordered groups [message #1756414 is a reply to message #1756390] Thu, 16 March 2017 15:22 Go to previous messageGo to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 29
Registered: March 2015
Junior Member
It somehow seems to be related to the size of the unordered group - could this be the case? as soon as I strip down the grammar, it starts working. If i have 8 or more members of an unordered group, behavior gets odd. I will still simplify the grammar and post it in the most minimal version I can come up with.
Re: Content assist and unordered groups [message #1756420 is a reply to message #1756414] Thu, 16 March 2017 16:02 Go to previous messageGo to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 29
Registered: March 2015
Junior Member
This is the most minimal misbehaving grammar I can come up with. There is documentation on what to change to restore good behavior... Is there any way to write the groups differently to achieve the same thing (but working)? Below is also a demo file for the grammar that has the misbehavior documented. The grammar can simple be pasted in the MyDsl example project's .xtext

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

LCModel:
	configurations+=LaunchConfig*
;

LaunchConfig:
	((a?='a')?
		& (b?='b')?
		& (c?='c')?
		& (d?='d')?  
		& (e?='e')? // remove any option from this group and content assist works correctly for LaunchConfigType
		& (f?='f')? // with all 8 in place, content assist will not work /after/ the first member of this group
		& (g?='g')?
		& (h?='h')? 
	) type=LaunchConfigType 'configuration' name=FQName 
	(':' superConfig=[LaunchConfig|FQName])? BLOCK_BEGIN
		( // things that may appear only once
			(a1='a1' ';')?
			& (b1='b1' ';')?
			// things that may appear multiple times
			& (a2+=AddPlugin)*
			& (b2+=AddFeature)*
			& (c2+=IgnorePlugin)* // again, remove any option from this group to restore working content assist.
			& (d2+=GroupMember)*
			& (e2+=VmArgument)*
		)
	BLOCK_END
;

AddPlugin:
	(optional?='optional')? 'plugin' plugin=SomethingWithVersion ';'
;

AddFeature:
	(optional?='optional')? 'feature' feature=SomethingWithVersion ';'
;

IgnorePlugin:
	'ignore' plugin=SomethingWithVersion ';'
;

VmArgument:
	'vm-argument' argument=StringWithVariables ';'
;

SomethingWithVersion:
	name = FQName (version=VERSION)?
;

GroupMember:
	'member' member=[LaunchConfig|FQName] ';'
;

StringWithVariables:
	value=STRING
;

FQName:
	ID ('.' ID)*
;

enum LaunchConfigType:
	JAVA = "java" | ECLIPSE = "eclipse" | RAP = "rap" | GROUP = "group"
;

terminal INT returns ecore::EInt: ('0'..'9')+;
terminal ID: '^'?('a'..'z'|'A'..'Z'|'_') ('.'? ('a'..'z'|'A'..'Z'|'^'|'_'|'-'|'0'..'9'))*;
terminal QUALIFIER: ('a'..'z'|'A'..'Z'|'_'|'-'|'0'..'9')*;
terminal VERSION: INT (('.' INT) (('.' INT) ('.' QUALIFIER)?)?)?;
terminal BLOCK_BEGIN: '{';
terminal BLOCK_END: '}';


here the file

/* correct: all possibilities proposed */ a /* incorrect: no LaunchConfigType proposed */ eclipse configuration Test {
	a1; 
	// correct here: all possibilities proposed
	
	plugin abc;
	// incorrect here, only proposes the same rule as in last line
	
}
Re: Content assist and unordered groups [message #1756428 is a reply to message #1756420] Thu, 16 March 2017 17:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10873
Registered: July 2009
Senior Member
sounds like https://bugs.eclipse.org/bugs/show_bug.cgi?id=384060
can you please comment on this bug.


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Content assist and unordered groups [message #1756431 is a reply to message #1756428] Thu, 16 March 2017 18:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10873
Registered: July 2009
Senior Member
as a workaround you may play around with

parserGenerator = {
antlrParam = "-Xmaxinlinedfastates"
antlrParam = "30"
}


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Content assist and unordered groups [message #1756449 is a reply to message #1756431] Fri, 17 March 2017 06:23 Go to previous messageGo to next message
Markus Duft is currently offline Markus DuftFriend
Messages: 29
Registered: March 2015
Junior Member
OK, Thanks. Where do I have to put this parserGenerator config? in the mwe Workflow toplevel? under component = XtextGenerator?
Re: Content assist and unordered groups [message #1756451 is a reply to message #1756449] Fri, 17 March 2017 06:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10873
Registered: July 2009
Senior Member
no on language level

(content asssist should help you)

		language = StandardLanguage {
			name = "org.xtext.example.mydsl3.MyDsl"
			fileExtensions = "mydsl3"

			serializer = {
				generateStub = false
			}
			validator = {
				// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
			}
			parserGenerator = {
				antlrParam = "-Xmaxinlinedfastates"
				antlrParam = "30"
			}
		}




Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @chrdietrich
Blog : christiandietrich.wordpress.com
Re: Content assist and unordered groups [message #1756466 is a reply to message #1756451] Fri, 17 March 2017 10:38 Go to previous message
Markus Duft is currently offline Markus DuftFriend
Messages: 29
Registered: March 2015
Junior Member
thanks a lot, my problems are gone Smile
Previous Topic:Formatting Expressions
Next Topic:Method not found in enclosing type
Goto Forum:
  


Current Time: Fri Jul 21 21:11:37 GMT 2017

Powered by FUDForum. Page generated in 0.04356 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software