Cross Referenced Objects not initialized in ProposalProvider [message #1839429] |
Sun, 21 March 2021 05:07  |
Eclipse User |
|
|
|
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 #1839434 is a reply to message #1839430] |
Sun, 21 March 2021 07:15  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.05283 seconds