Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [Xtext] Problems with imported grammars and ecore models
[Xtext] Problems with imported grammars and ecore models [message #691196] Thu, 30 June 2011 22:52 Go to next message
Eclipse UserFriend
Originally posted by:

Hi,

I'm trying to transition from generated to imported model (because I
need to tweak the model) and experience problems with package URIs, I think.

In the grammar I extend Xbase and then import my own model, as follows:

grammar org.hal.ecoretypes.Test1 with org.eclipse.xtext.xbase.Xbase

import "platform:/plugin/no.hal.ecoretypes.core/model/process.ecore"

In process.ecore, I refer to EClasses defined in both Xbase and
JavaTypes, and use the http://.../ URIs for referencing the
corresponding packages.

In the model, I have rules like the following:

Rule : outPort = [Port] ':=' expression = XExpression ('when' guard =
XExpression)?
;

I get an error marker stating that "Cannot find compatible feature
expression in sealed EClass Rule from imported package
platform:/plugin/no.hal.ecoretypes.core/model/process.ecore. The
existing reference 'expression' has an incompatible type 'XExpression'."

I get the feeling there are two XEpression classes, one referenced by
process.ecore and one accessible through the extended grammar
org.eclipse.xtext.xbase.Xbase. Hence, they seem incompatible although
they should be the same. I notice that in the generated package (before
migrating to importing it), references to Xbase used a relative URI with
lots of leading ../ segments. But I've always avoided using such in my
own models, prefering the "official" http-schemed URI.

So, what should I do?

Hallvard
Re: [Xtext] Problems with imported grammars and ecore models [message #691379 is a reply to message #691196] Fri, 01 July 2011 10:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by:

Hi,

Now I've managed to satisfy the xtext editor, so it no longer gives the
error marker for the XExpression type. Here's the relevant part of the
grammar:

grammar no.hal.ecoretypes.Process with org.eclipse.xtext.xbase.Xbase

import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types

import "platform:/resource/no.hal.ecoretypes.xtext/model/process.ecore"

Rule: {Rule}
outPort = [Port] ':=' expression = XExpression ('when' guard =
XExpression)? ';'
;

(it seems to work whether or not I import xbase and javavmtypes)

However, now I get the following error when running the mwe2 file:
Caused by: java.lang.IllegalStateException: Problem parsing
'classpath:/no/hal/ecoretypes/Process.xtext':[TransformationDiagnostic:
null:29 Cannot find type for ' XExpression'. (ErrorCode:
NoSuchTypeAvailable), TransformationDiagnostic: null:29 Cannot find type
for ' XExpression'. (ErrorCode: NoSuchTypeAvailable),
TransformationDiagnostic: null:33 Cannot find type for '
JvmParameterizedTypeReference'. (ErrorCode: NoSuchTypeAvailable),
TransformationDiagnostic: null:37 Cannot find type for '
JvmParameterizedTypeReference'. (ErrorCode: NoSuchTypeAvailable),
TransformationDiagnostic: null:43 Cannot find type for '
JvmTypeReference'. (ErrorCode: NoSuchTypeAvailable),
TransformationDiagnostic: null:50 Cannot find type for '
JvmTypeReference'. (ErrorCode: NoSuchTypeAvailable),
TransformationDiagnostic: null:53 Cannot find type for '
JvmTypeReference'. (ErrorCode: NoSuchTypeAvailable)]
at
org.eclipse.xtext.generator.LanguageConfig.setUri(LanguageConfig.java:131)
... 43 more

It looks as though mwe2 parses the xtext file without XExpression in its
classpath? But I have the following in the mwe2 file:

bean = StandaloneSetup {
platformUri = "${runtimeProject}/.."
registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
registerGeneratedEPackage = "org.eclipse.xtext.common.types.TypesPackage"
registerGeneratedEPackage = "no.hal.ecoretypes.process.ProcessPackage"
}

Hallvard

On 01.07.11 00.52, Hallvard Trætteberg wrote:
> Hi,
>
> I'm trying to transition from generated to imported model (because I
> need to tweak the model) and experience problems with package URIs, I
> think.
>
> In the grammar I extend Xbase and then import my own model, as follows:
>
> grammar org.hal.ecoretypes.Test1 with org.eclipse.xtext.xbase.Xbase
>
> import "platform:/plugin/no.hal.ecoretypes.core/model/process.ecore"
>
> In process.ecore, I refer to EClasses defined in both Xbase and
> JavaTypes, and use the http://.../ URIs for referencing the
> corresponding packages.
>
> In the model, I have rules like the following:
>
> Rule : outPort = [Port] ':=' expression = XExpression ('when' guard =
> XExpression)?
> ;
>
> I get an error marker stating that "Cannot find compatible feature
> expression in sealed EClass Rule from imported package
> platform:/plugin/no.hal.ecoretypes.core/model/process.ecore. The
> existing reference 'expression' has an incompatible type 'XExpression'."
>
> I get the feeling there are two XEpression classes, one referenced by
> process.ecore and one accessible through the extended grammar
> org.eclipse.xtext.xbase.Xbase. Hence, they seem incompatible although
> they should be the same. I notice that in the generated package (before
> migrating to importing it), references to Xbase used a relative URI with
> lots of leading ../ segments. But I've always avoided using such in my
> own models, prefering the "official" http-schemed URI.
>
> So, what should I do?
>
> Hallvard
Re: [Xtext] Problems with imported grammars and ecore models [message #691406 is a reply to message #691379] Fri, 01 July 2011 11:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by:

The following mwe2 fragment worked:

bean = StandaloneSetup {
scanClassPath = true
platformUri = "${runtimeProject}/.."
// registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
// registerGeneratedEPackage =
"org.eclipse.xtext.common.types.TypesPackage"
// registerGeneratedEPackage = "no.hal.ecoretypes.process.ProcessPackage"
registerGenModelFile =
"platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
registerGenModelFile =
"platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel"
}

I.e. I load the genmodels instead of the packages. I'm sure this is
related to how I use URIs to refer to the xbase and jvmtypes packages,
but I don't understand why?

An explanation would be great!

Hallvard

On 01.07.11 12.46, Hallvard Trætteberg wrote:
> Hi,
>
> Now I've managed to satisfy the xtext editor, so it no longer gives the
> error marker for the XExpression type. Here's the relevant part of the
> grammar:
>
> grammar no.hal.ecoretypes.Process with org.eclipse.xtext.xbase.Xbase
>
> import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase
> import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types
>
> import "platform:/resource/no.hal.ecoretypes.xtext/model/process.ecore"
>
> Rule: {Rule}
> outPort = [Port] ':=' expression = XExpression ('when' guard =
> XExpression)? ';'
> ;
>
> (it seems to work whether or not I import xbase and javavmtypes)
>
> However, now I get the following error when running the mwe2 file:
> Caused by: java.lang.IllegalStateException: Problem parsing
> 'classpath:/no/hal/ecoretypes/Process.xtext':[TransformationDiagnostic:
> null:29 Cannot find type for ' XExpression'. (ErrorCode:
> NoSuchTypeAvailable), TransformationDiagnostic: null:29 Cannot find type
> for ' XExpression'. (ErrorCode: NoSuchTypeAvailable),
> TransformationDiagnostic: null:33 Cannot find type for '
> JvmParameterizedTypeReference'. (ErrorCode: NoSuchTypeAvailable),
> TransformationDiagnostic: null:37 Cannot find type for '
> JvmParameterizedTypeReference'. (ErrorCode: NoSuchTypeAvailable),
> TransformationDiagnostic: null:43 Cannot find type for '
> JvmTypeReference'. (ErrorCode: NoSuchTypeAvailable),
> TransformationDiagnostic: null:50 Cannot find type for '
> JvmTypeReference'. (ErrorCode: NoSuchTypeAvailable),
> TransformationDiagnostic: null:53 Cannot find type for '
> JvmTypeReference'. (ErrorCode: NoSuchTypeAvailable)]
> at
> org.eclipse.xtext.generator.LanguageConfig.setUri(LanguageConfig.java:131)
> ... 43 more
>
> It looks as though mwe2 parses the xtext file without XExpression in its
> classpath? But I have the following in the mwe2 file:
>
> bean = StandaloneSetup {
> platformUri = "${runtimeProject}/.."
> registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
> registerGeneratedEPackage = "org.eclipse.xtext.common.types.TypesPackage"
> registerGeneratedEPackage = "no.hal.ecoretypes.process.ProcessPackage"
> }
>
> Hallvard
>
> On 01.07.11 00.52, Hallvard Trætteberg wrote:
>> Hi,
>>
>> I'm trying to transition from generated to imported model (because I
>> need to tweak the model) and experience problems with package URIs, I
>> think.
>>
>> In the grammar I extend Xbase and then import my own model, as follows:
>>
>> grammar org.hal.ecoretypes.Test1 with org.eclipse.xtext.xbase.Xbase
>>
>> import "platform:/plugin/no.hal.ecoretypes.core/model/process.ecore"
>>
>> In process.ecore, I refer to EClasses defined in both Xbase and
>> JavaTypes, and use the http://.../ URIs for referencing the
>> corresponding packages.
>>
>> In the model, I have rules like the following:
>>
>> Rule : outPort = [Port] ':=' expression = XExpression ('when' guard =
>> XExpression)?
>> ;
>>
>> I get an error marker stating that "Cannot find compatible feature
>> expression in sealed EClass Rule from imported package
>> platform:/plugin/no.hal.ecoretypes.core/model/process.ecore. The
>> existing reference 'expression' has an incompatible type 'XExpression'."
>>
>> I get the feeling there are two XEpression classes, one referenced by
>> process.ecore and one accessible through the extended grammar
>> org.eclipse.xtext.xbase.Xbase. Hence, they seem incompatible although
>> they should be the same. I notice that in the generated package (before
>> migrating to importing it), references to Xbase used a relative URI with
>> lots of leading ../ segments. But I've always avoided using such in my
>> own models, prefering the "official" http-schemed URI.
>>
>> So, what should I do?
>>
>> Hallvard
>
Re: [Xtext] Problems with imported grammars and ecore models [message #692612 is a reply to message #691406] Mon, 04 July 2011 20:46 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Hallvard,

the information from the GenModel is required for the code generation.
The Java code will contain references to the Eclasses that were
generated from the referenced packages. The GenModel provides exactly
the information that is necessary to get this right. It's essentially a
mapping model from EClassifier to a java class name.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 01.07.11 13:51, Hallvard Trætteberg wrote:
> The following mwe2 fragment worked:
>
> bean = StandaloneSetup {
> scanClassPath = true
> platformUri = "${runtimeProject}/.."
> // registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
> // registerGeneratedEPackage =
> "org.eclipse.xtext.common.types.TypesPackage"
> // registerGeneratedEPackage = "no.hal.ecoretypes.process.ProcessPackage"
> registerGenModelFile =
> "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
> registerGenModelFile =
> "platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel"
>
> }
>
> I.e. I load the genmodels instead of the packages. I'm sure this is
> related to how I use URIs to refer to the xbase and jvmtypes packages,
> but I don't understand why?
>
> An explanation would be great!
>
> Hallvard
>
> On 01.07.11 12.46, Hallvard Trætteberg wrote:
>> Hi,
>>
>> Now I've managed to satisfy the xtext editor, so it no longer gives the
>> error marker for the XExpression type. Here's the relevant part of the
>> grammar:
>>
>> grammar no.hal.ecoretypes.Process with org.eclipse.xtext.xbase.Xbase
>>
>> import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase
>> import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types
>>
>> import "platform:/resource/no.hal.ecoretypes.xtext/model/process.ecore"
>>
>> Rule: {Rule}
>> outPort = [Port] ':=' expression = XExpression ('when' guard =
>> XExpression)? ';'
>> ;
>>
>> (it seems to work whether or not I import xbase and javavmtypes)
>>
>> However, now I get the following error when running the mwe2 file:
>> Caused by: java.lang.IllegalStateException: Problem parsing
>> 'classpath:/no/hal/ecoretypes/Process.xtext':[TransformationDiagnostic:
>> null:29 Cannot find type for ' XExpression'. (ErrorCode:
>> NoSuchTypeAvailable), TransformationDiagnostic: null:29 Cannot find type
>> for ' XExpression'. (ErrorCode: NoSuchTypeAvailable),
>> TransformationDiagnostic: null:33 Cannot find type for '
>> JvmParameterizedTypeReference'. (ErrorCode: NoSuchTypeAvailable),
>> TransformationDiagnostic: null:37 Cannot find type for '
>> JvmParameterizedTypeReference'. (ErrorCode: NoSuchTypeAvailable),
>> TransformationDiagnostic: null:43 Cannot find type for '
>> JvmTypeReference'. (ErrorCode: NoSuchTypeAvailable),
>> TransformationDiagnostic: null:50 Cannot find type for '
>> JvmTypeReference'. (ErrorCode: NoSuchTypeAvailable),
>> TransformationDiagnostic: null:53 Cannot find type for '
>> JvmTypeReference'. (ErrorCode: NoSuchTypeAvailable)]
>> at
>> org.eclipse.xtext.generator.LanguageConfig.setUri(LanguageConfig.java:131)
>>
>> ... 43 more
>>
>> It looks as though mwe2 parses the xtext file without XExpression in its
>> classpath? But I have the following in the mwe2 file:
>>
>> bean = StandaloneSetup {
>> platformUri = "${runtimeProject}/.."
>> registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
>> registerGeneratedEPackage = "org.eclipse.xtext.common.types.TypesPackage"
>> registerGeneratedEPackage = "no.hal.ecoretypes.process.ProcessPackage"
>> }
>>
>> Hallvard
>>
>> On 01.07.11 00.52, Hallvard Trætteberg wrote:
>>> Hi,
>>>
>>> I'm trying to transition from generated to imported model (because I
>>> need to tweak the model) and experience problems with package URIs, I
>>> think.
>>>
>>> In the grammar I extend Xbase and then import my own model, as follows:
>>>
>>> grammar org.hal.ecoretypes.Test1 with org.eclipse.xtext.xbase.Xbase
>>>
>>> import "platform:/plugin/no.hal.ecoretypes.core/model/process.ecore"
>>>
>>> In process.ecore, I refer to EClasses defined in both Xbase and
>>> JavaTypes, and use the http://.../ URIs for referencing the
>>> corresponding packages.
>>>
>>> In the model, I have rules like the following:
>>>
>>> Rule : outPort = [Port] ':=' expression = XExpression ('when' guard =
>>> XExpression)?
>>> ;
>>>
>>> I get an error marker stating that "Cannot find compatible feature
>>> expression in sealed EClass Rule from imported package
>>> platform:/plugin/no.hal.ecoretypes.core/model/process.ecore. The
>>> existing reference 'expression' has an incompatible type 'XExpression'."
>>>
>>> I get the feeling there are two XEpression classes, one referenced by
>>> process.ecore and one accessible through the extended grammar
>>> org.eclipse.xtext.xbase.Xbase. Hence, they seem incompatible although
>>> they should be the same. I notice that in the generated package (before
>>> migrating to importing it), references to Xbase used a relative URI with
>>> lots of leading ../ segments. But I've always avoided using such in my
>>> own models, prefering the "official" http-schemed URI.
>>>
>>> So, what should I do?
>>>
>>> Hallvard
>>
>
Previous Topic:Xpand - surplus white space
Next Topic:Xtext index and referenced JARs
Goto Forum:
  


Current Time: Thu Apr 25 11:54:45 GMT 2024

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

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

Back to the top