Exception when calling workflow on XPand [message #545190] |
Tue, 06 July 2010 21:25 |
Eclipse User |
|
|
|
Originally posted by: m_lehmeier.gmx.de
This is somewhat related to XText, but I assume that the problem is
really in the Xpand part of the system.
I am working on my first XText project.
My first try failed because I have to use two languages and tried to fit
them into the projects generated by Eclipse. Didn't work for several
reasons.
On my second try I created another XText project. I copied the main and
ui projects for the second language and adjusted everything I could
find.
I exported all four projects and it works. Good so far.
Then I renamed the generator project into "common" and intend to use it
as main project for further programming. Sources from models defined by
both languages should be generated here.
So I used the Eclipse-generated workflow and modified it only a little.
I point the modelFile property to my new Xtext model and I add an
outputSlot for the registered Xtext model.
Then I use this model slot in the expand statement. Everything else
stays the same. From what I know, I think that all that project renaming
of the Xtext projects should not affect the Xpand code generation.
But it doesn't work.
I get this exception:
No Definition 'templates::Template::main for visagestructure::Model' found!
My first thought was that he could not read the model or that the slot
wasn't identical. But when I rename that slot in the expand statement, I
get a different exception, so I assume that the model was correctly
read.
I then tried to debug. Eclipse doesn't seem to be able to debug a
workflow, even if I start it as "Debug as ... MWE Workflow".
So I made a Java program that allows me to run that workflow
programmatically. I get exactly the same exception, but now I can debug.
Through debugging I found out in debug mode that the
AbstractResourceLoader manages to find and open the template file, this
is guaranteed.
But I still get the same exception.
The Xpand file itself is almost exactly like Eclipse generated it for
me. I just removed the lines that wouldn't work with my model.
So IMO the line "
|
|
|
|
Re: Exception when calling workflow on XPand [message #545420 is a reply to message #545265] |
Wed, 07 July 2010 17:17 |
Eclipse User |
|
|
|
Originally posted by: m_lehmeier.gmx.de
On 2010-07-07, Christian Dietrich <christian.dietrich@itemis.de> wrote:
> Hello,
>
> do you have a file Template.xpt within the package templates and a definition like
>
><<DEFINE main FOR visagestructure::Model>>
><<ENDDEFINE>>
>
> if so it should work.
> Can you post your complete workflow. Maybe there is a configuration error.
I didn't know that the board doesn't accept that xpand characters.
I corrected them.
Here is the rest of my post:
So IMO the line "<<DEFINE main FOR Model->>" should be valid. Every XText
Metamodel has the Model class defined. So I have no idea why it does not work.
Another Eclipse-generated XText project works, even though I can't see
any difference to this project.
Any ideas?
My Workflow:
<workflow>
<property name="modelFile"
value=" classpath:/com/lm/model/visage/model/structure/models/Visage Structure.visagestruct "/>
<property name="targetDir" value="src-gen"/>
<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup"
platformUri=".."/>
<component class="org.eclipse.emf.mwe.utils.DirectoryCleaner"
directory="${targetDir}"/>
<component class="org.eclipse.xtext.MweReader" uri="${modelFile}">
<register class="com.lm.model.visage.VisageStructureStandaloneSetup"/ >
<outputSlot value="visageStructureModel" />
</component>
<component class="org.eclipse.xpand2.Generator">
<metaModel
class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel "/>
<fileEncoding value="UTF-8"/>
<expand value="templates::Template::main FOR visageStructureModel"/>
<genPath value="${targetDir}"/>
</component>
</workflow>
My starter program:
public static void main(String[] args) {
WorkflowContextDefaultImpl ctx = new WorkflowContextDefaultImpl();
NullProgressMonitor monitor = new NullProgressMonitor();
IssuesImpl issues = new IssuesImpl();
StandaloneSetup standaloneSetup = new
org.eclipse.emf.mwe.utils.StandaloneSetup();
standaloneSetup.setPlatformUri(".");
final MweReader reader = new org.eclipse.xtext.MweReader();
reader.setUri(MODEL_FILE);
VisageStructureStandaloneSetup setup = new
com.lm.model.visage.VisageStructureStandaloneSetup();
reader.setRegister(setup);
reader.setOutputSlot("visageStructureModel");
reader.invoke(ctx, monitor, issues);
EmfRegistryMetaModel metaModel = new
org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel();
final org.eclipse.xpand2.Generator generator = new
org.eclipse.xpand2.Generator();
generator.addMetaModel(metaModel);
generator.setSrcPath(" /media/secret/system/home/dard/workspace/com.lm.model.visage .common ");
generator.setGenPath("src-gen");
generator.setFileEncoding("UTF-8");
generator.setExpand("templates::Template::main FOR visageStructureModel");
generator.invoke(ctx, monitor, issues);
}
My Xpand file:
<<IMPORT visageStructure>>;
<<DEFINE main FOR Model->>
<<FILE "output.txt"->>
<<ENDFILE->>
<<ENDDEFINE>>
BTW: The generator.setSrcPath and .setGenPath are marked as deprecated.
I should use outlets instead.
But how do I use Outlets? I can give an Outlet a path in the
constructor, but how does the system know whether it is the SrcPath or
the GenPath?
I assume i have to use setName, but how do I find out which names?
Thanks!
--
Lehmeier Michael
|
|
|
Re: Exception when calling workflow on XPand [message #545472 is a reply to message #545420] |
Wed, 07 July 2010 21:51 |
|
Hi,
Reading your posts case-sensitive i founf follwing:
Quote: |
No Definition 'templates::Template::main for visagestructure::Model' found!
|
Quote: |
<<IMPORT visageStructure>>;
|
visagestructure != visageStructure
I tried this with a sample dsl and workflow and can reproduce the problem. this is a bug in xpand (generator and/or editor) since you do not get an error marker
This bugs seems to occur only with Xtext / Xpand 0.7.2 and is fixed with Xtext / Xpand 1.0.0
Regards
Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Exception when calling workflow on XPand [message #545473 is a reply to message #545420] |
Wed, 07 July 2010 21:42 |
Eclipse User |
|
|
|
Originally posted by: m_lehmeier.gmx.de
I debugged deep into EMF and have located the problem.
It seems there is no valid Metamodel registered.
There are only
- BuiltinMetaModel
- XtendMetaModel
- XpandTypesMetaModel
- EmfMetaModel
None of these have a definition for "Model".
What I don't understand is why the standard XText project manages to
find the correct metamodel.
It must be the line
<metaModel
class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel "/>
but I have no idea what it does and how it locates the correct MM.
Anyway, since it obviously doesn't work, I now try to register the
correct Metamodel.
In my Java file I added the lines:
EmfMetaModel emfMetaModel = new
org.eclipse.xtend.typesystem.emf.EmfMetaModel();
emfMetaModel.setMetaModelPackage("com.lm.model.visage.visagestructure.VisagestructurePackage ");
And then:
generator.addMetaModel(emfMetaModel);
But that doesn't work yet.
Still, I seem to have a lead and will try more tomorrow.
--
Lehmeier Michael
|
|
|
Re: Exception when calling workflow on XPand [message #545503 is a reply to message #545472] |
Thu, 08 July 2010 05:29 |
Eclipse User |
|
|
|
Originally posted by: m_lehmeier.gmx.de
On 2010-07-07, Christian Dietrich <christian.dietrich@itemis.de> wrote:
> Hi,
>
> Reading your posts case-sensitive i founf follwing:
>
> Quote:
>> No Definition 'templates::Template::main for visagestructure::Model' found!
>
>
> Quote:
>> <<IMPORT visageStructure>>;
>
>
> visagestructure != visageStructure
I see. This was indeed the problem.
It was a leftover from a renaming of the package. I didn't see this.
Thank you!
I am, however, a little confused where EMF knows where to get the
Metamodel. It seems like I overlooked something while debugging.
No matter.
> I tried this with a sample dsl and workflow and can reproduce the problem.
> this is a bug in xpand (generator and/or editor) since you do not get an error marker
> This bugs seems to occur only with Xtext / Xpand 0.7.2 and is fixed with Xtext / Xpand 1.0.0
Good to know
--
Lehmeier Michael
|
|
|
Powered by
FUDForum. Page generated in 0.03346 seconds