Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ImportURI for ecore models and Xbase scoping
ImportURI for ecore models and Xbase scoping [message #1017981] Tue, 12 March 2013 22:40 Go to next message
Steven Derrien is currently offline Steven DerrienFriend
Messages: 50
Registered: July 2009
Member
Dear Xtext users,

I would like to design a small Xbase based DSL to describe adapters working at the
metamodel level. The idea is to describe how to bind EStructuralFeature/EClass of a given EPackage
(the adapted one) to another EPackage (the target).

To achieve this, I would need to import existing ecore files (through importURI) but also
use XBase to describe possible adaptation code when the mapping is not straighforward.

Right now, I am completely lost with Scoping/Linking when dealing with cross-references to
external objects from my Ecore files.

My Xtext grammar looks like this :

grammar fr.irisa.cairn.VisitGen with org.eclipse.xtext.xbase.Xbase

generate visitGen "http://www.irisa.fr/cairn/VisitGen"
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

// JGraphT java subgraph isomoprhism http://code.google.com/p/fasubis/

TopLevel:
(imports+=Import)* adapters+=ModelAdapter+ ;

Import: 'use' importURI=STRING;

ModelAdapter:
'adapt' src=[ecore::EPackage|ID] 'to' target=[ecore::EPackage|ID] '{'
classBinders+=ClassBinder*
'}';


ClassBinder:
'bind' src=[ecore::EClass|ID] 'to' target=[ecore::EClass|ID] '{'
(featureBinders+=FeatureBinder ';')*
'}';

FeatureBinder:
'map' src=[ecore::EStructuralFeature|ID] 'to' target=[ecore::EStructuralFeature|ID]
('as' adapter=XExpression)?;

My Xtext mwe2 workflow (part of):

// scoping and exporting API
fragment = scoping.ImportURIScopingFragment {}
fragment = exporting.SimpleNamesFragment {}

// scoping and exporting API
// fragment = scoping.ImportNamespacesScopingFragment {}
// fragment = exporting.QualifiedNamesFragment {}
fragment = builder.BuilderIntegrationFragment {}

Here are my questions :

I understand the XBase uses its own customized scope/linking mechanism, and that my Ecore object are hence invisible
since they are not jvm objects. After searching around I found the following solution
(http://www.eclipse.org/forums/index.php/mv/msg/379428/918699/) which I tried with no success.

The strang thing is that I get different type of error depending whether I run the editor aftre exporting it in my main
eclipse dropin folder or run-it as a Eclipse application.

In the first case I get observe

org.eclipse.xtext.linking.lazy.LazyLinkingResource - resolution of uriFragment 'xtextLink_::0.1.0.2.0.2.0::0::/3' failed

In the second case I get

Caused by: java.lang.IllegalStateException: No IResourceServiceProvider found in registry for uri
platform:/resource/project/model/Target.ecore at
org.eclipse.xtext.scoping.impl.LoadOnDemandResourceDescriptions.getResourceDescription(LoadOnDemandResourceDescriptions.java:70)
at
org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider.createLazyResourceScope(ImportUriGlobalScopeProvider.java:104)

I must admit that I am a bit lost, can someone give me a few advices on the proper way for handling this ?

Thanks in advance,

Regards,

Steven
Re: ImportURI for ecore models and Xbase scoping [message #1019006 is a reply to message #1017981] Thu, 14 March 2013 22:05 Go to previous message
Steven Derrien is currently offline Steven DerrienFriend
Messages: 50
Registered: July 2009
Member
Hi again,

I spent the last two days trying to understand the problem and solve it without any
success.

Some hint would really be welcome !

Regards,

Steven

Le 12/03/2013 23:40, Steven Derrien a écrit :
> Dear Xtext users,
>
> I would like to design a small Xbase based DSL to describe adapters working at the
> metamodel level. The idea is to describe how to bind EStructuralFeature/EClass of a given EPackage
> (the adapted one) to another EPackage (the target).
>
> To achieve this, I would need to import existing ecore files (through importURI) but also
> use XBase to describe possible adaptation code when the mapping is not straighforward.
>
> Right now, I am completely lost with Scoping/Linking when dealing with cross-references to
> external objects from my Ecore files.
>
> My Xtext grammar looks like this :
>
> grammar fr.irisa.cairn.VisitGen with org.eclipse.xtext.xbase.Xbase
>
> generate visitGen "http://www.irisa.fr/cairn/VisitGen"
> import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types
> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>
> // JGraphT java subgraph isomoprhism http://code.google.com/p/fasubis/
>
> TopLevel:
> (imports+=Import)* adapters+=ModelAdapter+ ;
>
> Import: 'use' importURI=STRING;
>
> ModelAdapter:
> 'adapt' src=[ecore::EPackage|ID] 'to' target=[ecore::EPackage|ID] '{'
> classBinders+=ClassBinder*
> '}';
>
>
> ClassBinder:
> 'bind' src=[ecore::EClass|ID] 'to' target=[ecore::EClass|ID] '{'
> (featureBinders+=FeatureBinder ';')*
> '}';
>
> FeatureBinder:
> 'map' src=[ecore::EStructuralFeature|ID] 'to' target=[ecore::EStructuralFeature|ID]
> ('as' adapter=XExpression)?;
>
> My Xtext mwe2 workflow (part of):
>
> // scoping and exporting API
> fragment = scoping.ImportURIScopingFragment {}
> fragment = exporting.SimpleNamesFragment {}
>
> // scoping and exporting API
> // fragment = scoping.ImportNamespacesScopingFragment {}
> // fragment = exporting.QualifiedNamesFragment {}
> fragment = builder.BuilderIntegrationFragment {}
>
> Here are my questions :
>
> I understand the XBase uses its own customized scope/linking mechanism, and that my Ecore object are hence invisible
> since they are not jvm objects. After searching around I found the following solution
> (http://www.eclipse.org/forums/index.php/mv/msg/379428/918699/) which I tried with no success.
>
> The strang thing is that I get different type of error depending whether I run the editor aftre exporting it in my main
> eclipse dropin folder or run-it as a Eclipse application.
>
> In the first case I get observe
>
> org.eclipse.xtext.linking.lazy.LazyLinkingResource - resolution of uriFragment 'xtextLink_::0.1.0.2.0.2.0::0::/3' failed
>
> In the second case I get
>
> Caused by: java.lang.IllegalStateException: No IResourceServiceProvider found in registry for uri
> platform:/resource/project/model/Target.ecore at
> org.eclipse.xtext.scoping.impl.LoadOnDemandResourceDescriptions.getResourceDescription(LoadOnDemandResourceDescriptions.java:70)
>
> at
> org.eclipse.xtext.scoping.impl.ImportUriGlobalScopeProvider.createLazyResourceScope(ImportUriGlobalScopeProvider.java:104)
>
> I must admit that I am a bit lost, can someone give me a few advices on the proper way for handling this ?
>
> Thanks in advance,
>
> Regards,
>
> Steven
Previous Topic:How obtain EMF element of certain type up in the AST
Next Topic:Changes to UI not being displayed
Goto Forum:
  


Current Time: Thu Apr 25 00:37:39 GMT 2024

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

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

Back to the top