Home » Modeling » TMF (Xtext) » mwe2 workflow and EMF stuff
mwe2 workflow and EMF stuff [message #646825] |
Fri, 31 December 2010 15:56 |
|
Hi
in my DSL I let the programmer refer to an ecore with, e.g.,
"./models/FJ.ecore"
or
"http://www.eclipse.org/emf/2002/Ecore"
and I have a LinkingService which correctly loads the corresponding
EPackage.
When I generate code from my DSL source file using mwe2, the workflow
validates the program again, and, during that validation, the
corresponding EPackage cannot be found anymore by my LinkingService,
with an error
LINKER: Cannot load package with URI 'http://example.xtext.org/FJ',
java.lang.RuntimeException: Cannot create a resource for
'http://example.xtext.org/FJ'; a registered resource factory is needed
while during the validation in the editor, the EPackage is loaded
correctly...
thus, when running the mwe2 workflow, the "environment" is not the same?
I mean, all the plugins and emf stuff that are available in the editor
for my DSL are not available when running the workflow?
thanks in advance
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
| | |
Re: mwe2 workflow and EMF stuff [message #646848 is a reply to message #646846] |
Sat, 01 January 2011 12:29 |
|
Workflows run in a Standalone Java Environment, the Editor runs in an Eclipse / OSGi Environment. Registering resource factory is done with Eclipse Means e.g. via Plugin XML. To Affect the same in the Standalone Workflow you have to Execute some extra Stuff that faces the Eclipse / OSGi Stuff. (Workspace / EMF Resource Factories / Register EPackages) e.g.
bean = StandaloneSetup {
platformUri = "${runtimeProject}/.."
}
component = org.eclipse.xtext.mwe.Reader {
......
// this class will be generated by the xtext generator
register = org.xtext.example.mydsl.MyDslStandaloneSetup {}
.....
}
<bean class="org.eclipse.mwe.emf.StandaloneSetup" >
<platformUri value=".."/>
<registerGeneratedEPackage value="test.SomePackage"/>
</bean>
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: mwe2 workflow and EMF stuff [message #646862 is a reply to message #646848] |
Sat, 01 January 2011 17:26 |
|
thanks Christian
I'll try to detail my problem, also because I found other issues.
As I said in my original post in my DSL I refer to an ecore with the
following syntax (that ecore corresponds to the one generated by Xtext,
since I refer to the ecore of another Xtext DSL), for instance
grammar "platform:/resource/myproject/src/model/FJ.ecore"
and I have a linking service implementation which loads the
corresponding EPackage like that (where resourceOrNsURI is the string
specified in the DSL)
private EPackage loadEPackage(String resourceOrNsURI,
ResourceSet resourceSet) {
if (EPackage.Registry.INSTANCE.containsKey(resourceOrNsURI))
return EPackage.Registry.INSTANCE.getEPackage(resourceOrNsURI);
try {
URI uri = URI.createURI(resourceOrNsURI);
if (uri.fragment() == null) {
Resource resource = resourceSet.getResource(uri, true);
EPackage result = (EPackage) resource.getContents().get(0);
return result;
}
return (EPackage) resourceSet.getEObject(uri, true);
} catch (RuntimeException ex) {
System.out.println("LINKER: " + "Cannot load package with URI '"
+ resourceOrNsURI + "', " + ex);
}
return null;
}
if in the new eclipse instance I specify that string for the grammar
keyword, the editor correctly validates the program, and the EPackage is
correctly loaded, but when I run the workflow I get this error from my
LinkingService (when the workflow validates the program):
LINKER: Cannot load package with URI
'platform:/resource/myproject/src/model/FJ.ecore',
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
java.io.IOException: The path '/myproject/src/model/FJ.ecore' is unmapped
if, instead I specify in my DSL program:
grammar "src/model/FJ.ecore"
the editor complains because the LinkingService cannot load the EPackage
with this error
LINKER: Cannot load package with URI 'src/model/FJ.ecore',
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
java.io.FileNotFoundException: src/model/FJ.ecore (No such file or
directory)
but the workflow successfully runs and generates code :)
I suppose that the correct way to specify an URI for an .ecore is the
first one, i.e., "platform:/resource/myproject/src/model/FJ.ecore", am I
right about that?
If that's true, from what I understand, I should execute some extra
stuff in the workflow as you say... so I should load the standalone
setup of the DSL I refer to in my program, but I cannot write it in the
workflow since I don't know that: it's written in the program...
thus is could be
grammar "platform:/resource/myproject/src/model/FJ.ecore"
or
grammar " platform:/resource/anotherproject/src/model/domainmodel.ecor e "
should I invoke the workflow programmatically so that, when I run it, I
know the corresponding standalone setup?
or should I do something else?
For instance, could I implement the LinkingService so that it is able to
load an .ecore when running the workflow even if it's in the platform shape?
Let me specify that I took the code of the LinkingService from the
ecoredsl example in the Xtext sources :)
many thanks in advance
Lorenzo
On 01/01/2011 01:29 PM, Christian Dietrich wrote:
> Workflows run in a Standalone Java Environment, the Editor runs in an
> Eclipse / OSGi Environment. Registering resource factory is done with
> Eclipse Means e.g. via Plugin XML. To Affect the same in the Standalone
> Workflow you have to Execute some extra Stuff that faces the Eclipse /
> OSGi Stuff. (Workspace / EMF Resource Factories / Register EPackages) e.g.
>
>
> bean = StandaloneSetup {
> platformUri = "${runtimeProject}/.."
> }
>
>
>
> component = org.eclipse.xtext.mwe.Reader {
> ......
>
> // this class will be generated by the xtext generator register =
> org.xtext.example.mydsl.MyDslStandaloneSetup {}
> .....
> }
>
>
>
> <bean class="org.eclipse.mwe.emf.StandaloneSetup" >
> <platformUri value=".."/>
> <registerGeneratedEPackage value="test.SomePackage"/>
> </bean>
>
>
>
> ~Christian
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Re: mwe2 workflow and EMF stuff [message #646863 is a reply to message #646862] |
Sat, 01 January 2011 18:18 |
|
Hi,
LINKER: Cannot load package with URI
'platform:/resource/myproject/src/model/FJ.ecore',
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
java.io.IOException: The path '/myproject/src/model/FJ.ecore' is unmapped
means that /myproject/src/model/FJ.ecore cannot be found in the "fake" standalone workspace. the workspace is faked with
bean = StandaloneSetup {
platformUri = "${runtimeProject}/.."
}
or
bean = StandaloneSetup {
platformUri = ".."
}
or something similar.
so it should work if "${runtimeProject}/.." points to the parent directory of myproject.
if you have some special stuctures that wont work with StandaloneSetup have a look into the source code and build a own workflow compoment that does the stuff you need.
the platform:/resource uris should then work even standalone
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Sat, 01 January 2011 18:24] Report message to a moderator
|
|
|
Re: mwe2 workflow and EMF stuff [message #648607 is a reply to message #646863] |
Thu, 13 January 2011 15:47 |
|
On 01/01/2011 07:18 PM, Christian Dietrich wrote:
> Hi,
>
>
> LINKER: Cannot load package with URI
> 'platform:/resource/myproject/src/model/FJ.ecore',
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos
> ticWrappedException:
> java.io.IOException: The path '/myproject/src/model/FJ.ecore' is unmapped
>
>
> means that /myproject/src/model/FJ.ecore cannot be found in the "fake"
> standalone workspace. the workspace is faked with
>
>
> bean = StandaloneSetup {
> platformUri = "${runtimeProject}/.."
> }
>
>
> or
>
>
> bean = StandaloneSetup {
> platformUri = ".."
> }
>
>
> or something similar.
>
> so it should work if "${runtimeProject}/.." points to the parent
> directory of myproject.
>
OK, so now probably I understand a few things, and by setting
platformUri = ".."
it works if the referenced .ecore is in the same project of my program.
But this does not solve completely what I'd like to achieve:
Let me remind that as I said in my original post in my DSL I refer to an
ecore with the following syntax (that ecore corresponds to the one
generated by Xtext, since I refer to the ecore of another Xtext DSL),
for instance
// myfile.mydsl
grammar "platform:/resource/myproject/src/model/myecore.ecore"
Now if this is written in, say, myfile.mydsl and this is in the same
project of myecore.ecore, e.g., in this example, 'myproject' then the
workflow correctly finds everything (with the fakes the workspace).
But if I write
// myfile.mydsl
grammar "platform:/resource/myotherproject/src/model/myecore.ecore"
i.e., I refer to an .ecore in a different project of myfile.mydsl this
does not work anymore (unless ".." is the actual path of
'myotherproject' too, which is not always the case).
Let me stress that the problem comes in the workflow: when editing
myfile.mydsl the myecore.ecore is correctly found and loaded.
Thus, the 'faking' mechanism is not easily extensible to fake a
situation where the workspace contains project spread throughout the
hard disk... probably it does not even aim to, does it?
> if you have some special stuctures that wont work with StandaloneSetup
> have a look into the source code and build a own workflow compoment that
> does the stuff you need.
>
so probably, for what I need to do (i.e., generate code), using a
workflow, which runs in standalone java environment, will not be enough,
will it?
Probably I should implement a sort of context menu (say "Generate
code")? But would this mean reimplement all the workflow stuff?
Or is it possible to run programmatically the same workflow code in an
Eclipse/OSGI environment?
thanks
Lore
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
| | | |
Re: mwe2 workflow and EMF stuff [message #648639 is a reply to message #648624] |
Thu, 13 January 2011 18:23 |
|
On Thu, 13 Jan 2011 18:16:14 +0100, Lorenzo Bettini
<bettini@dsi.unifi.it> wrote:
> you mean here linked workspace resources... though it's not clear
to me
> what is a plain workspace... a workspace where files are in the
same
Sorry, my android auto spelling drives me crazy. With plain workspace
I mean that all projects and resources are physically contained in
the workspace root.
> I don't understand here: did you mean "I.e."? it looks like the
second
I mean if you do not want to use workflows at all just call
XpandFacade from an action
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: mwe2 workflow and EMF stuff [message #648725 is a reply to message #648639] |
Fri, 14 January 2011 09:03 |
|
On 01/13/2011 07:23 PM, Christian Dietrich wrote:
> On Thu, 13 Jan 2011 18:16:14 +0100, Lorenzo Bettini
> <bettini@dsi.unifi.it> wrote:
>> you mean here linked workspace resources... though it's not clear
> to me
>> what is a plain workspace... a workspace where files are in the
> same
> Sorry, my android auto spelling drives me crazy. With plain workspace I
> mean that all projects and resources are physically contained in the
> workspace root.
>
>> I don't understand here: did you mean "I.e."? it looks like the
> second
>
> I mean if you do not want to use workflows at all just call XpandFacade
> from an action
OK, I'll give it a try... I suppose, in such case, i.e., using
XpandFacade directly, would require to manually open the template file,
and mydsl program, and validate it? Am I right? In that case where
could I find 'inspiration' please?
thanks in advance
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
| | |
Goto Forum:
Current Time: Sat Apr 20 02:48:02 GMT 2024
Powered by FUDForum. Page generated in 0.04846 seconds
|