Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 17:41 Go to next message
Romain Bioteau is currently offline Romain Bioteau
Messages: 62
Registered: August 2009
Location: Grenoble
Member
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



R&D Engineer at BonitaSoft
Re: ParserBasedContentAssistContextFactory.StatefulFactory mixing instances of the same grammar [message #1005874 is a reply to message #1005785] Tue, 29 January 2013 07:24 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian Zarnekow
Messages: 2900
Registered: July 2009
Senior Member
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 08:01 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4088
Registered: July 2009
Senior Member
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 08:30 Go to previous messageGo to next message
Romain Bioteau is currently offline Romain Bioteau
Messages: 62
Registered: August 2009
Location: Grenoble
Member
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.


R&D Engineer at BonitaSoft
Re: ParserBasedContentAssistContextFactory.StatefulFactory mixing instances of the same grammar [message #1005919 is a reply to message #1005884] Tue, 29 January 2013 10:02 Go to previous messageGo to next message
Romain Bioteau is currently offline Romain Bioteau
Messages: 62
Registered: August 2009
Location: Grenoble
Member
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 !


R&D Engineer at BonitaSoft
Re: ParserBasedContentAssistContextFactory.StatefulFactory mixing instances of the same grammar [message #1005923 is a reply to message #1005919] Tue, 29 January 2013 10:16 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6382
Registered: July 2009
Senior Member
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: Wed Oct 22 00:10:32 GMT 2014

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

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