Skip to main content



      Home
Home » Modeling » TMF (Xtext) » ParserBasedContentAssistContextFactory.StatefulFactory mixing instances of the same grammar
ParserBasedContentAssistContextFactory.StatefulFactory mixing instances of the same grammar [message #1005785] Mon, 28 January 2013 12:41 Go to next message
Eclipse UserFriend
Hello,
I have an issue with the content assist failing to lookup for cross references when I use an EmbeddedEditor. It works well in a classic editor part.

After some hours of debugging it seems to be an issue with the ParserBasedContentAssistContextFactory.StatefulFactory.

The parser is dealing with EObject of my grammar but from two different instances of my grammar model which lead to parsing issue and failed to create a proper ContentAssistContext ( with a non null current model).

To be more precise when the doCreateContexts(
INode lastCompleteNode, INode currentNode,
String prefix, EObject previousModel,
Collection<FollowElement> followElements) is called :

the followElements are contained in a Grammar with instance id @1919ef, but the currentNode.getGrammarElement() is contained in a Grammar with another instance id. Thus, during the parsing, when doing all the switches with eobject comparaisons it fails.

This is happening with the content assist of the embedded editor only !

As I'm not friendly at all with injection stuff, I'm not able to understand how I can end up with this strange behavior.

Does someone can help me with this ?

Best regards
Romain

Re: ParserBasedContentAssistContextFactory.StatefulFactory mixing instances of the same grammar [message #1005874 is a reply to message #1005785] Tue, 29 January 2013 02:24 Go to previous messageGo to next message
Eclipse UserFriend
Hi Romain,

please make sure that you do not (and never) use the STandalone setup of
your language within Eclipse.

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 28.01.13 18:41, schrieb Romain Bioteau:
> Hello,
> I have an issue with the content assist failing to lookup for cross
> references when I use an EmbeddedEditor. It works well in a classic
> editor part.
>
> After some hours of debugging it seems to be an issue with the
> ParserBasedContentAssistContextFactory.StatefulFactory.
> The parser is dealing with EObject of my grammar but from two different
> instances of my grammar model which lead to parsing issue and failed to
> create a proper ContentAssistContext ( with a non null current model).
>
> To be more precise when the doCreateContexts(
> INode lastCompleteNode, INode currentNode,
> String prefix, EObject previousModel,
> Collection<FollowElement> followElements) is called :
>
> the followElements are contained in a Grammar with instance id @1919ef,
> but the currentNode.getGrammarElement() is contained in a Grammar with
> another instance id. Thus, during the parsing, when doing all the
> switches with eobject comparaisons it fails.
>
> This is happening with the content assist of the embedded editor only !
>
> As I'm not friendly at all with injection stuff, I'm not able to
> understand how I can end up with this strange behavior.
> Does someone can help me with this ?
>
> Best regards
> Romain
>
>
Re: ParserBasedContentAssistContextFactory.StatefulFactory mixing instances of the same grammar [message #1005877 is a reply to message #1005874] Tue, 29 January 2013 03:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi Sebastian

I am just one of many Xtext users guilty of this terrible crime.

Since it is so terrible, why is there no EcorePlugin.IS_ECLIPSE_RUNNING
guard and an IllegalStateException in the generated doSetup()?

I suggested this in a Bugzilla, but nothing happened.

Regards

Ed


On 29/01/2013 07:24, Sebastian Zarnekow wrote:
> Hi Romain,
>
> please make sure that you do not (and never) use the STandalone setup
> of your language within Eclipse.
>
> Regards,
> Sebastian
Re: ParserBasedContentAssistContextFactory.StatefulFactory mixing instances of the same grammar [message #1005884 is a reply to message #1005877] Tue, 29 January 2013 03:30 Go to previous messageGo to next message
Eclipse UserFriend
It solves the problem !
But it's really disturbing since the few doc I found on how to use the Embbed editor suggest to call the doSetup in the IEditedResourceProvider.

Thanks Sebastian, you save my day. But Ed is right, there should a protection or at least a bold line in documentation about this.

By the way, how can I access the injected fields such as the XTextResourceSetProvider ? I was directly calling the injector.getInstance(XTextResourceSetProvider.class) but it seems not to be the correct way.

Regards.
Re: ParserBasedContentAssistContextFactory.StatefulFactory mixing instances of the same grammar [message #1005919 is a reply to message #1005884] Tue, 29 January 2013 05:02 Go to previous messageGo to next message
Eclipse UserFriend
To answer my own question you have to use the activator to access the injector like this : MyDSLActivator.getInstance().getInjector(MyDSLActivator.MYDSL_ID);

Thanks again !
Re: ParserBasedContentAssistContextFactory.StatefulFactory mixing instances of the same grammar [message #1005923 is a reply to message #1005919] Tue, 29 January 2013 05:16 Go to previous message
Eclipse UserFriend
Hi you may have a look at
http://koehnlein.blogspot.de/2012/11/xtext-tip-how-do-i-get-guice-injec
tor.html?m=1

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de
Previous Topic:Removing hidden nodes via API
Next Topic:[Xbase] Auto-extensions
Goto Forum:
  


Current Time: Sun Jul 06 23:06:57 EDT 2025

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

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

Back to the top