Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [xtext] question on scoping / content assist
[xtext] question on scoping / content assist [message #718555] Wed, 24 August 2011 16:47 Go to next message
m kranz is currently offline m kranz
Messages: 69
Registered: January 2010
Member
hi all

first a snippet of my grammar...

BehaviorNodeRule:
	(component = [uml::Component] | componentLiteral = STRING)
	node = Node
	("/" relation += Relation)*
;

Node:
...
	
;

Relation:
...
;


...and of the corresponding method within the scope provider...

	// returns a scope that contains all components contained in the model
	public IScope scope_BehaviorNodeRule_component(BehaviorNodeRule bnr, EReference ref){
		return scopeWithAllComponents();
	}


i created an editor from that grammar (for use within papyrus), and while the editor is working fine, the content assist is not really doing what i expected it to do. i guess it has something to do with either the scope provider or the way the grammar is constructed.

the problem i have is that, if you open the editor and "Ctrl+SPACE" without any input, only "componentLiteral - STRING" is shown as an option, but no components (the scoping method is not called).
i first have to type at least one letter that matches an existing component in order to trigger a call to the scoping method when i open the content assist.
so what i'm looking for is a way to 'force' the content assist to show all possibilities right from the start.

i guess there's an easy solution to this, so it would be very appreciated if someone could point me the way.

cheers

marco
Re: [xtext] question on scoping / content assist [message #718562 is a reply to message #718555] Wed, 24 August 2011 16:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6315
Registered: July 2009
Senior Member
Hi, using contentassist it may happen that the context (first Parameter of the scope method) is Not a behaviournoderule but One of its parents (due lazy instantiation) so add an additional scope method with the parent as context too

l
public IScope scope_BehaviorNodeRule_component(youparent p, EReference ref){
Re: [xtext] question on scoping / content assist [message #719216 is a reply to message #718562] Fri, 26 August 2011 12:49 Go to previous messageGo to next message
m kranz is currently offline m kranz
Messages: 69
Registered: January 2010
Member
ok thank you, that makes sense.
but what's the parent in case the BehaviorNodeRule is the first rule?
Re: [xtext] question on scoping / content assist [message #719225 is a reply to message #719216] Fri, 26 August 2011 13:07 Go to previous message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1156
Registered: July 2009
Senior Member
Hi,

debug whether the context object is null. You may also try to use an unassigned action in order to instantiate a model element immediately

BehaviorNodeRule: {BehaviorNodeRule} (component ...


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Previous Topic:(no subject)
Next Topic:Initialize editor settings
Goto Forum:
  


Current Time: Wed Sep 24 04:28:10 GMT 2014

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

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