Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Xcore] problems with "Converting a GenModel to an Xcore Model"
[Xcore] problems with "Converting a GenModel to an Xcore Model" [message #1245520] Thu, 13 February 2014 23:21 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1754
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

I've just started using Xcore and I wanted to create the xcore file from
the genmodel, and I followed the documentation in the wiki page.
However, this operation never terminates successfully (I saw there are
some bugs about that but they all seem to have been solved). I also
tried by starting from the extended library example, but I get the
following exceptions upon creation of the .xcore file. The first one
appears the first time I run the export; the following times (after the
export wizard has added deps to xbase lib and xcore lib) I get a similar
exception (see the second exception). Am I doing anything wrong?

FIRST TIME:

java.lang.RuntimeException: No EObjectDescription could be found in
Scope XAnnotation.source for
XPackage'xcore.lang'.annotationDirectives[0]->XAnnotationDirective'Ecore'
Semantic Object:
XPackage'org.eclipse.emf.examples.extlibrary'.annotations[0]->XAnnotation
at
org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:70)
at
org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.getCrossReferenceNameFromScope(CrossReferenceSerializer.java:146)
at
org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.serializeCrossRef(CrossReferenceSerializer.java:119)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.getToken(SequenceFeeder.java:453)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:220)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:403)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:441)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:239)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:396)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:441)
at
org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:85)
at
org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:108)
at
org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:130)
at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:344)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1430)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:999)
at
org.eclipse.emf.ecore.xcore.exporter.XcoreExporter$3.run(XcoreExporter.java:417)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

SECOND TIME

java.lang.RuntimeException: No EObjectDescription could be found in
Scope XGenericType.type for
GenModel.genPackages[0]->GenPackage.genDataTypes[16]->GenDataType
Semantic Object:
XPackage'org.eclipse.emf.examples.extlibrary'.classifiers[1]->XClass'Library'.members[8]->XAttribute'people'.type->XGenericType
at
org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:70)
at
org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.getCrossReferenceNameFromScope(CrossReferenceSerializer.java:146)
at
org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.serializeCrossRef(CrossReferenceSerializer.java:119)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.getToken(SequenceFeeder.java:453)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:220)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:403)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:441)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:222)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:403)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:441)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:239)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:396)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:441)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
at
org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:239)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:396)
at
org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:441)
at
org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:85)
at
org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:108)
at
org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:130)
at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:344)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1430)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:999)
at
org.eclipse.emf.ecore.xcore.exporter.XcoreExporter$3.run(XcoreExporter.java:417)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
Re: [Xcore] problems with "Converting a GenModel to an Xcore Model" [message #1245680 is a reply to message #1245520] Fri, 14 February 2014 05:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30682
Registered: July 2009
Senior Member
Lorenzo,

I tried this locally using the Luna version of things, and I properly
ended up with:

@Ecore(nsPrefix="extlib",
nsURI="http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0")
@GenModel(modelDirectory="/org.eclipse.emf.examples.library/src",
prefix="EXTLibrary", contentTypeIdentifier="extendedLibrary",
editDirectory="/org.eclipse.emf.examples.library.edit/src",
editorDirectory="/org.eclipse.emf.examples.library.editor/src",
runtimeJar="true", modelName="EXTLibrary",
editPluginClass="org.eclipse.emf.examples.extlibrary.provider.EXTLibraryEditPlugin",
editorPluginClass="org.eclipse.emf.examples.extlibrary.presentation.EXTLibraryEditorPlugin",
nonNLSMarkers="true", booleanFlagsField="eFlags",
booleanFlagsReservedBits="8",
importerID="org.eclipse.emf.importer.ecore", language="en")
package org.eclipse.emf.examples.extlibrary

import org.eclipse.emf.ecore.EFeatureMapEntry

class Book extends CirculatingItem {
String title
int pages = "100"
unsettable BookCategory category
refers Writer[1] author opposite books
}

class Library extends Addressable {
String name
@ExtendedMetaData(group="#people")
contains transient volatile derived Writer[] writers
@ExtendedMetaData(group="#people")
contains transient volatile derived Employee[] employees
@ExtendedMetaData(group="#people")
contains transient volatile derived Borrower[] borrowers
contains unordered Item[] stock
refers unordered transient derived Book[] books
contains resolving Library[] branches opposite parentBranch
container resolving Library parentBranch opposite branches
@ExtendedMetaData(kind="group")
unique EFeatureMapEntry[] people
}

class Writer extends Person {
transient volatile String name
refers Book[] books opposite author
}

enum BookCategory {
Mystery
ScienceFiction = 1
Biography = 2
}

abstract class Item {
java.util.Date publicationDate
}

interface Lendable {
int[1] copies
refers unordered Borrower[] borrowers opposite borrowed
}

abstract class CirculatingItem extends Item , Lendable {
}

abstract class Periodical extends Item {
String title
int[1] issuesPerYear
}

abstract class AudioVisualItem extends CirculatingItem {
String title
int[1] minutesLength
boolean damaged
}

class BookOnTape extends AudioVisualItem {
refers Person reader
refers Writer author
}

class VideoCassette extends AudioVisualItem {
refers Person[] cast
}

class Borrower extends Person {
refers Lendable[] borrowed opposite borrowers
}

class Person extends Addressable {
String[1] firstName
String[1] lastName
}

class Employee extends Person {
refers Employee manager
}

interface Addressable {
String address
}

Were you trying with the latest versions of EMF and Xtext?

On 14/02/2014 12:21 AM, Lorenzo Bettini wrote:
> Hi
>
> I've just started using Xcore and I wanted to create the xcore file from
> the genmodel, and I followed the documentation in the wiki page.
> However, this operation never terminates successfully (I saw there are
> some bugs about that but they all seem to have been solved). I also
> tried by starting from the extended library example, but I get the
> following exceptions upon creation of the .xcore file. The first one
> appears the first time I run the export; the following times (after the
> export wizard has added deps to xbase lib and xcore lib) I get a similar
> exception (see the second exception). Am I doing anything wrong?
>
> FIRST TIME:
>
> java.lang.RuntimeException: No EObjectDescription could be found in
> Scope XAnnotation.source for
> XPackage'xcore.lang'.annotationDirectives[0]->XAnnotationDirective'Ecore'
> Semantic Object:
> XPackage'org.eclipse.emf.examples.extlibrary'.annotations[0]->XAnnotation
> at
> org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:70)
> at
> org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.getCrossReferenceNameFromScope(CrossReferenceSerializer.java:146)
> at
> org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.serializeCrossRef(CrossReferenceSerializer.java:119)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.getToken(SequenceFeeder.java:453)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:220)
> at
> org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:403)
> at
> org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:441)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:239)
> at
> org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:396)
> at
> org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:441)
> at
> org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:85)
> at
> org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:108)
> at
> org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:130)
> at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:344)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1430)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:999)
> at
> org.eclipse.emf.ecore.xcore.exporter.XcoreExporter$3.run(XcoreExporter.java:417)
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
>
> SECOND TIME
>
> java.lang.RuntimeException: No EObjectDescription could be found in
> Scope XGenericType.type for
> GenModel.genPackages[0]->GenPackage.genDataTypes[16]->GenDataType
> Semantic Object:
> XPackage'org.eclipse.emf.examples.extlibrary'.classifiers[1]->XClass'Library'.members[8]->XAttribute'people'.type->XGenericType
> at
> org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:70)
> at
> org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.getCrossReferenceNameFromScope(CrossReferenceSerializer.java:146)
> at
> org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.serializeCrossRef(CrossReferenceSerializer.java:119)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.getToken(SequenceFeeder.java:453)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:220)
> at
> org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:403)
> at
> org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:441)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:222)
> at
> org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:403)
> at
> org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:441)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:239)
> at
> org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:396)
> at
> org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:441)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
> at
> org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:239)
> at
> org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:396)
> at
> org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:441)
> at
> org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:85)
> at
> org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:108)
> at
> org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:130)
> at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:344)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1430)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:999)
> at
> org.eclipse.emf.ecore.xcore.exporter.XcoreExporter$3.run(XcoreExporter.java:417)
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
>
>
Re: [Xcore] problems with "Converting a GenModel to an Xcore Model" [message #1245976 is a reply to message #1245680] Fri, 14 February 2014 14:42 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1754
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 14/02/2014 06:32, Ed Merks wrote:
> Lorenzo,
>
> I tried this locally using the Luna version of things, and I properly
> ended up with:
>

Hi Ed

I'm using the latest versions of both EMF and Xtext (but I'm still using
Kepler).

I tried with a brand new workspace and things worked this time (!), so I
guess there was something wrong in my previous workspace.

Now I'd like to know if anyone has tried to use Xcore for the metamodel
of an Xtext DSL that uses Xbase. Indeed, that's my use case: I switched
to a manually managed ecore (and genmodel) file for this DSL, and then
to Xcore. I managed to export the xcore from the genmodel now, but I
get Java compilation errors in the generated Java EPackage class (for
classes extending an Xbase class).

Should I switch to the Xtext forum?

cheers
Lorenzo


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
Re: [Xcore] problems with "Converting a GenModel to an Xcore Model" [message #1245982 is a reply to message #1245976] Fri, 14 February 2014 14:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30682
Registered: July 2009
Senior Member
Lorenzo,

Comments below.

On 14/02/2014 3:42 PM, Lorenzo Bettini wrote:
> On 14/02/2014 06:32, Ed Merks wrote:
>> Lorenzo,
>>
>> I tried this locally using the Luna version of things, and I properly
>> ended up with:
>>
> Hi Ed
>
> I'm using the latest versions of both EMF and Xtext (but I'm still using
> Kepler).
>
> I tried with a brand new workspace and things worked this time (!), so I
> guess there was something wrong in my previous workspace.
I suppose it's possible that the index had old crap in it...
>
> Now I'd like to know if anyone has tried to use Xcore for the metamodel
> of an Xtext DSL that uses Xbase. Indeed, that's my use case: I switched
> to a manually managed ecore (and genmodel) file for this DSL, and then
> to Xcore. I managed to export the xcore from the genmodel now, but I
> get Java compilation errors in the generated Java EPackage class (for
> classes extending an Xbase class).
Did you delete the *.genmodel? It might confuse the index to have both
a *.genmodel and *.xcore for the same nsURI...

What kind of errors? Ones caused by missing dependencies in the
MANIFEST? Or bad generated results about dependencies on other XyxPackages?
>
> Should I switch to the Xtext forum?
We can continue here for now if it seems like an EMF/Xcore problem...
>
> cheers
> Lorenzo
>
>
Re: [Xcore] problems with "Converting a GenModel to an Xcore Model" [message #1246100 is a reply to message #1245982] Fri, 14 February 2014 18:16 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1754
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 14/02/2014 15:51, Ed Merks wrote:
>> Now I'd like to know if anyone has tried to use Xcore for the metamodel
>> of an Xtext DSL that uses Xbase. Indeed, that's my use case: I switched
>> to a manually managed ecore (and genmodel) file for this DSL, and then
>> to Xcore. I managed to export the xcore from the genmodel now, but I
>> get Java compilation errors in the generated Java EPackage class (for
>> classes extending an Xbase class).
> Did you delete the *.genmodel? It might confuse the index to have both
> a *.genmodel and *.xcore for the same nsURI...
>
> What kind of errors? Ones caused by missing dependencies in the
> MANIFEST? Or bad generated results about dependencies on other XyxPackages?

Hi Ed

I'll get errors due to missing operation count in the base class; I
haven't tried to delete the genmodel (I'll try to do that later).

However, I've just noticed that also the .xcore exported in the Extended
library example generates wrong Java code. In this case I also tried to
delete the genmodel, and rebuild the project but I get several
compilation errors; for instance about the generated enumeration literals:

before xcore in BookCategory you have

MYSTERY_LITERAL(0, "Mystery", "Mystery")

but then you have

int MYSTERY = 0;

and the previous code

private static final BookCategory[] VALUES_ARRAY =
new BookCategory[]
{
MYSTERY_LITERAL,
SCIENCE_FICTION_LITERAL,
BIOGRAPHY_LITERAL,
};

is now

private static final BookCategory[] VALUES_ARRAY =
new BookCategory[]
{
MYSTERY,
SCIENCE_FICTION,
BIOGRAPHY,
};

and Java complains, for instance, that

Cannot make a static reference to the non-static field BIOGRAPHY
BookCategory.java
/org.eclipse.emf.examples.library/src/org/eclipse/emf/examples/extlibrary

this is the xcore that has been generated during the export, and it
looks just the same as yours...

Lorenzo

@Ecore(nsPrefix="extlib",
nsURI="http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0")
@GenModel(modelDirectory="/org.eclipse.emf.examples.library/src",
prefix="EXTLibrary",
contentTypeIdentifier="extendedLibrary",
editDirectory="/org.eclipse.emf.examples.library.edit/src",
editorDirectory="/org.eclipse.emf.examples.library.editor/src",
runtimeJar="true", modelName="EXTLibrary",
editPluginClass="org.eclipse.emf.examples.extlibrary.provider.EXTLibraryEditPlugin",
editorPluginClass="org.eclipse.emf.examples.extlibrary.presentation.EXTLibraryEditorPlugin",
nonNLSMarkers="true", booleanFlagsField="eFlags",
booleanFlagsReservedBits="8",
importerID="org.eclipse.emf.importer.ecore", language="en"
)
package org.eclipse.emf.examples.extlibrary

import org.eclipse.emf.ecore.EFeatureMapEntry

class Book extends CirculatingItem {
String title
int pages = "100"
unsettable BookCategory category
refers Writer[1] author opposite books
}

class Library extends Addressable {
String name
@ExtendedMetaData(group="#people")
contains transient volatile derived Writer[] writers
@ExtendedMetaData(group="#people")
contains transient volatile derived Employee[] employees
@ExtendedMetaData(group="#people")
contains transient volatile derived Borrower[] borrowers
contains unordered Item[] stock
refers unordered transient derived Book[] books
contains resolving Library[] branches opposite parentBranch
container resolving Library parentBranch opposite branches
@ExtendedMetaData(kind="group")
unique EFeatureMapEntry[] people
}

class Writer extends Person {
transient volatile String name
refers Book[] books opposite author
}

enum BookCategory {
Mystery
ScienceFiction = 1
Biography = 2
}

abstract class Item {
java.util.Date publicationDate
}

interface Lendable {
int[1] copies
refers unordered Borrower[] borrowers opposite borrowed
}

abstract class CirculatingItem extends Item , Lendable {
}

abstract class Periodical extends Item {
String title
int[1] issuesPerYear
}

abstract class AudioVisualItem extends CirculatingItem {
String title
int[1] minutesLength
boolean damaged
}

class BookOnTape extends AudioVisualItem {
refers Person reader
refers Writer author
}

class VideoCassette extends AudioVisualItem {
refers Person[] cast
}

class Borrower extends Person {
refers Lendable[] borrowed opposite borrowers
}

class Person extends Addressable {
String[1] firstName
String[1] lastName
}

class Employee extends Person {
refers Employee manager
}

interface Addressable {
String address
}


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
Re: [Xcore] problems with "Converting a GenModel to an Xcore Model" [message #1246208 is a reply to message #1245982] Fri, 14 February 2014 21:00 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1754
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 14/02/2014 15:51, Ed Merks wrote:
>> Now I'd like to know if anyone has tried to use Xcore for the metamodel
>> of an Xtext DSL that uses Xbase. Indeed, that's my use case: I switched
>> to a manually managed ecore (and genmodel) file for this DSL, and then
>> to Xcore. I managed to export the xcore from the genmodel now, but I
>> get Java compilation errors in the generated Java EPackage class (for
>> classes extending an Xbase class).
> Did you delete the *.genmodel? It might confuse the index to have both
> a *.genmodel and *.xcore for the same nsURI...
>
> What kind of errors? Ones caused by missing dependencies in the
> MANIFEST? Or bad generated results about dependencies on other XyxPackages?
>>

So I managed to do some further testing on my DSL using Xbase and I
deleted the .genmodel as you suggested but the problem is still there.
I'll try to sketch the situation, in .xcore I have

class EnvironmentMapping extends XExpression {
contains XExpression key
contains XExpression value
}

the generated EPackage contains

int ENVIRONMENT_MAPPING_OPERATION_COUNT =
XbasePackage.XEXPRESSION_OPERATION_COUNT + 0;

which is not compilable in Java since
XbasePackage.XEXPRESSION_OPERATION_COUNT does not exist

If you want I can try to reproduce it with a smaller DSL.

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
Re: [Xcore] problems with "Converting a GenModel to an Xcore Model" [message #1246741 is a reply to message #1246100] Sat, 15 February 2014 11:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30682
Registered: July 2009
Senior Member
Lorenzo,

Comments below.

On 14/02/2014 7:16 PM, Lorenzo Bettini wrote:
> On 14/02/2014 15:51, Ed Merks wrote:
>>> Now I'd like to know if anyone has tried to use Xcore for the metamodel
>>> of an Xtext DSL that uses Xbase. Indeed, that's my use case: I switched
>>> to a manually managed ecore (and genmodel) file for this DSL, and then
>>> to Xcore. I managed to export the xcore from the genmodel now, but I
>>> get Java compilation errors in the generated Java EPackage class (for
>>> classes extending an Xbase class).
>> Did you delete the *.genmodel? It might confuse the index to have both
>> a *.genmodel and *.xcore for the same nsURI...
>>
>> What kind of errors? Ones caused by missing dependencies in the
>> MANIFEST? Or bad generated results about dependencies on other XyxPackages?
> Hi Ed
>
> I'll get errors due to missing operation count in the base class; I
> haven't tried to delete the genmodel (I'll try to do that later).
This problem arises when the GenModel specifies Reflective Operation
Invocation (the default for Xcore-based models) and the base model
specifies it as false. You can set it to false with an
@GenModel(operationReflection="false") in the *.xcore. Ideally Xbase
would specify it as true for getter client flexibility to support that
in their derived models.
>
> However, I've just noticed that also the .xcore exported in the Extended
> library example generates wrong Java code. In this case I also tried to
> delete the genmodel, and rebuild the project but I get several
> compilation errors; for instance about the generated enumeration literals:
>
> before xcore in BookCategory you have
>
> MYSTERY_LITERAL(0, "Mystery", "Mystery")
>
> but then you have
>
> int MYSTERY = 0;
>
> and the previous code
>
> private static final BookCategory[] VALUES_ARRAY =
> new BookCategory[]
> {
> MYSTERY_LITERAL,
> SCIENCE_FICTION_LITERAL,
> BIOGRAPHY_LITERAL,
> };
>
> is now
>
> private static final BookCategory[] VALUES_ARRAY =
> new BookCategory[]
> {
> MYSTERY,
> SCIENCE_FICTION,
> BIOGRAPHY,
> };
>
> and Java complains, for instance, that
>
> Cannot make a static reference to the non-static field BIOGRAPHY
> BookCategory.java
> /org.eclipse.emf.examples.library/src/org/eclipse/emf/examples/extlibrary
>
> this is the xcore that has been generated during the export, and it
> looks just the same as yours...
You get different results for the enum depending on
@GenModel(typeSafeEnumCompatible="true") on the GenEnum. I haven't
looked closely but this must default differently for Xcore than it does
for an ordinary *.ecore based model.

So in both cases, you can work around the problem with @GenModel
annotations. Nevertheless, please open a bugzilla with a
hopefully-minimized example reproducing the problem and I'll look into
doing a better job generating the annotations automatically.
>
> Lorenzo
>
> @Ecore(nsPrefix="extlib",
> nsURI="http:///org/eclipse/emf/examples/library/extlibrary.ecore/1.0.0")
> @GenModel(modelDirectory="/org.eclipse.emf.examples.library/src",
> prefix="EXTLibrary",
> contentTypeIdentifier="extendedLibrary",
> editDirectory="/org.eclipse.emf.examples.library.edit/src",
> editorDirectory="/org.eclipse.emf.examples.library.editor/src",
> runtimeJar="true", modelName="EXTLibrary",
> editPluginClass="org.eclipse.emf.examples.extlibrary.provider.EXTLibraryEditPlugin",
> editorPluginClass="org.eclipse.emf.examples.extlibrary.presentation.EXTLibraryEditorPlugin",
> nonNLSMarkers="true", booleanFlagsField="eFlags",
> booleanFlagsReservedBits="8",
> importerID="org.eclipse.emf.importer.ecore", language="en"
> )
> package org.eclipse.emf.examples.extlibrary
>
> import org.eclipse.emf.ecore.EFeatureMapEntry
>
> class Book extends CirculatingItem {
> String title
> int pages = "100"
> unsettable BookCategory category
> refers Writer[1] author opposite books
> }
>
> class Library extends Addressable {
> String name
> @ExtendedMetaData(group="#people")
> contains transient volatile derived Writer[] writers
> @ExtendedMetaData(group="#people")
> contains transient volatile derived Employee[] employees
> @ExtendedMetaData(group="#people")
> contains transient volatile derived Borrower[] borrowers
> contains unordered Item[] stock
> refers unordered transient derived Book[] books
> contains resolving Library[] branches opposite parentBranch
> container resolving Library parentBranch opposite branches
> @ExtendedMetaData(kind="group")
> unique EFeatureMapEntry[] people
> }
>
> class Writer extends Person {
> transient volatile String name
> refers Book[] books opposite author
> }
>
> enum BookCategory {
> Mystery
> ScienceFiction = 1
> Biography = 2
> }
>
> abstract class Item {
> java.util.Date publicationDate
> }
>
> interface Lendable {
> int[1] copies
> refers unordered Borrower[] borrowers opposite borrowed
> }
>
> abstract class CirculatingItem extends Item , Lendable {
> }
>
> abstract class Periodical extends Item {
> String title
> int[1] issuesPerYear
> }
>
> abstract class AudioVisualItem extends CirculatingItem {
> String title
> int[1] minutesLength
> boolean damaged
> }
>
> class BookOnTape extends AudioVisualItem {
> refers Person reader
> refers Writer author
> }
>
> class VideoCassette extends AudioVisualItem {
> refers Person[] cast
> }
>
> class Borrower extends Person {
> refers Lendable[] borrowed opposite borrowers
> }
>
> class Person extends Addressable {
> String[1] firstName
> String[1] lastName
> }
>
> class Employee extends Person {
> refers Employee manager
> }
>
> interface Addressable {
> String address
> }
>
>
Re: [Xcore] problems with "Converting a GenModel to an Xcore Model" [message #1250433 is a reply to message #1246741] Wed, 19 February 2014 08:35 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1754
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi Ed

Thanks! Using the @GenModel(operationReflection="false") did the trick
and the Java classes are compiled! I'll try to file a bug with a small
example as soon as possible (currently I'm trying to fix other problems
I'm experiencing when using an Xcore file with Xbase in the mwe2 workflow).

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
Previous Topic:EditingSupport and EditingDomain
Next Topic:[Texo] Modeling a OneToOne relationship
Goto Forum:
  


Current Time: Fri Dec 06 05:47:56 GMT 2019

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

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

Back to the top