Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Large EPackage don't have a Literals Class
Large EPackage don't have a Literals Class [message #902377] Fri, 17 August 2012 11:40 Go to next message
Jorge Carballo is currently offline Jorge CarballoFriend
Messages: 7
Registered: July 2010
Junior Member
I have a problem with my generator. I have a grammar that has been growing. I previously used:

MyGrammarPackage.Literals.GRAMMAR_NAME



But now, I've seen that now is not possible to use, because I have references to the Literals type of generated / imported EPackages even though this type does not exists for large EPackages.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=352162

Before:

MyGrammarPackage.Literals.GRAMMAR__NAME


Well, I have changed and now use:

@Inject
MyGrammarPackage myGrammarPackage;

....

myGrammarPackage.getGrammar_Name()



and configure <MyGrammarRuntimeModule.java>:

public Class<? extends MyGrammarPackage> bindMyGrammarPackage() {
       return MyGrammarPackageImpl.class;
}



I get an error when trying to generate my DSL:

...

1) Could not find a suitable constructor in es.fap.simpleled.led.impl.MyGrammarPackageImpl. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
 at es.fap.simpleled.led.impl.MyGrammarPackageImpl.class(MyGrammarPackageImpl.java:37)
 at org.eclipse.xtext.service.MethodBasedModule.configure(MethodBasedModule.java:55)


And do not really know why it can be.

Regards.


Jorge Carballo.
Re: Large EPackage don't have a Literals Class [message #902912 is a reply to message #902377] Tue, 21 August 2012 06:43 Go to previous messageGo to next message
Francisco José Martín Fernández is currently offline Francisco José Martín FernándezFriend
Messages: 1
Registered: August 2012
Junior Member
I have the same problem. My grammar has become very big and now I can not use

MyGrammarPackage.Literals.GRAMMAR_NAME


And when trying to use

@Inject
MyGrammarPackage myGrammarPackage;

....

myGrammarPackage.getGrammar_Name()


I get the same error. Crying or Very Sad

1) Could not find a suitable constructor in es.fap.simpleled.led.impl.MyGrammarPackageImpl. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.


Any help please? Question Question Question

Thanks ...

EDIT: I think one of the problems is that the generated class: MyGrammarPackageImpl has the constructor as private and will not be injected. But that class is generated, and not how to fix it

[Updated on: Tue, 21 August 2012 09:55]

Report message to a moderator

Re: Large EPackage don't have a Literals Class [message #903085 is a reply to message #902377] Tue, 21 August 2012 20:53 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
Hi,

something like


public MyGrammarPackage bindMyGrammarPackage() {
return MyGrammarPackageImpl.eInstance();
}


should do the trick.

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

Am 17.08.12 13:40, schrieb Jorge Carballo:
> I have a problem with my generator. I have a grammar that has been
> growing. I previously used:
>
> MyGrammarPackage.Literals.GRAMMAR_NAME
>
>
> But now, I've seen that now is not possible to use, because I have
> references to the Literals type of generated / imported EPackages even
> though this type does not exists for large EPackages.
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=352162
>
> Before:
>
> MyGrammarPackage.Literals.GRAMMAR__NAME
>
> Well, I have changed and now use:
>
> @Inject
> MyGrammarPackage myGrammarPackage;
>
> ....
>
> myGrammarPackage.getGrammar_Name()
>
>
> and configure <MyGrammarRuntimeModule.java>:
>
> public Class<? extends MyGrammarPackage> bindMyGrammarPackage() {
> return MyGrammarPackageImpl.class;
> }
>
>
> I get an error when trying to generate my DSL:
>
> ...
>
> 1) Could not find a suitable constructor in
> es.fap.simpleled.led.impl.MyGrammarPackageImpl. Classes must have either
> one (and only one) constructor annotated with @Inject or a zero-argument
> constructor that is not private.
> at
> es.fap.simpleled.led.impl.MyGrammarPackageImpl.class(MyGrammarPackageImpl.java:37)
>
> at
> org.eclipse.xtext.service.MethodBasedModule.configure(MethodBasedModule.java:55)
>
>
>
> And do not really know why it can be.
>
> Regards.
Re: Large EPackage don't have a Literals Class [message #903111 is a reply to message #903085] Wed, 22 August 2012 05:08 Go to previous messageGo to next message
Kevin Sun is currently offline Kevin SunFriend
Messages: 32
Registered: August 2010
Location: China
Member

You may try this way. Every time when it is finished to generate the Ecore model from the grammar, generate the Literal manually.
1 open the genmodel
2 select the EPackage and show its properties
3 In the "model" there is a "Literals Interface"
4 change the value to be "true"
5 generate the model code.

Then you will get the Literals class
Re: Large EPackage don't have a Literals Class [message #903139 is a reply to message #903111] Wed, 22 August 2012 07:51 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3108
Registered: July 2009
Senior Member
Hi Kevin,

I'd rather reuse the properly configured genmodel instead of altering it
each and every time I regenerate the grammar.

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

Am 22.08.12 07:08, schrieb Kevin Sun:
> You may try this way. Every time when it is finished to generate the
> Ecore model from the grammar, generate the Literal manually. 1 open the
> genmodel
> 2 select the EPackage and show its properties
> 3 In the "model" there is a "Literals Interface"
> 4 change the value to be "true"
> 5 generate the model code.
>
> Then you will get the Literals class
Re: Large EPackage don't have a Literals Class [message #903140 is a reply to message #903111] Wed, 22 August 2012 07:58 Go to previous message
Jorge Carballo is currently offline Jorge CarballoFriend
Messages: 7
Registered: July 2010
Junior Member
Great!!

Both answers work for me, but I prefer the first one although I must to change all references to Literals. On the other hand, generate the Literal manually is ponderous.

public MyGrammarPackage bindMyGrammarPackage() {
	return MyGrammarPackageImpl.eINSTANCE;
}


Thanks.


Jorge Carballo.
Previous Topic:Couldn't find method ''_featureCall'' for objects JvmVoid
Next Topic:Arithmetics example can't serialize Definition references
Goto Forum:
  


Current Time: Sun Nov 29 00:10:50 GMT 2020

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

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

Back to the top