Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cross Referenced Objects not initialized in ProposalProvider
Cross Referenced Objects not initialized in ProposalProvider [message #1839429] Sun, 21 March 2021 09:07 Go to next message
Alfredo Aldundi is currently offline Alfredo AldundiFriend
Messages: 23
Registered: July 2009
Junior Member
I have been trying to restrict content assist as described in:

http://xtextcasts.org/episodes/17-restricting-scope?autoplay=true

It works perfectly fine, if I am in the same file. As soon as I start to place the "byes" into another file the greetings have no properties set (name = null and honest = false).

Grammar
Model:
	greetings+=Greeting*
	byes+=Bye*;
	
Greeting:
	'Hello' name=ID honest?='!'?;
	
Bye:
	'Bye' greeting=[Greeting]
;


ProposalProvider
	public void completeBye_Greeting(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
		lookupCrossReference(model, FooDslPackage.Literals.BYE__GREETING, acceptor, e -> {
			Greeting greeting = (Greeting) e.getEObjectOrProxy();
			// greeting.name is also null, honest always false if placed in another file
			return greeting.isHonest();
		}, getProposalFactory("ID", context));
	}


What am I missing?!

I am using Xtext 2.24.0 and EMF 2.24.
Re: Cross Referenced Objects not initialized in ProposalProvider [message #1839430 is a reply to message #1839429] Sun, 21 March 2021 09:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14026
Registered: July 2009
Senior Member
For the other files you just have the index entries there and thus Proxies
So you have two options
Add more information to the userdata map of the index entries (adapting IDefaultResourceDescriptionStrategy) And then us the userdata to filter in the proposal provider
Or resolve the Proxies in the context of the given context eobjects resource(set) (see ECoreUtil.resolve methods) but this will become terribly slow with bigger models


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Cross Referenced Objects not initialized in ProposalProvider [message #1839434 is a reply to message #1839430] Sun, 21 March 2021 11:15 Go to previous message
Alfredo Aldundi is currently offline Alfredo AldundiFriend
Messages: 23
Registered: July 2009
Junior Member
I see. It does not really make sense to access properties of EObjectOrProxy for any real world DSL. There should be a big warning in the Javadoc regarding this point.

Adding the "honest" flag to the user data in the index solved my issue.

Wouldn't this topic (liberal scoping, using proposalprovider + validator and user data map in the index) deserve a place in the Xtext documentation? I find a single reference to "user data" in the documentation without pointing out why one would want to add additional information to the index.
Previous Topic:Grammar ambiguity
Next Topic:Index User Data
Goto Forum:
  


Current Time: Thu Jul 29 18:07:05 GMT 2021

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

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

Back to the top