Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand/Xtend] Extension problem
[Xpand/Xtend] Extension problem [message #1005544] Sat, 26 January 2013 12:55 Go to next message
Vladimir D is currently offline Vladimir DFriend
Messages: 15
Registered: January 2013
Junior Member
Hi,

I have a problem with extensions in my Xpand project. I want to generate a textual file from my model conforming to the meta-model I made (using Ecore meta-meta-model). I have a following error when I try to run generator.mwe:

...
933  INFO  CompositeComponent - Generator: generating 'template::template::module FOR model' => src-gen
976  ERROR AbstractExpressionsUsingWorkflowComponent - Error in Component  of type org.eclipse.xpand2.Generator: 
	EvaluationException : Couldn't find operation 'getModel()' for metatransform::ModelPackage::Class.
	template::template.xpt[901,10] on line 34 'this.inPattern.inClass.getModel()'                    
	template::template.xpt[673,30] on line 26 'EXPAND rule FOREACH this.rules'                       
	template::template.xpt[146,54] on line 8 'EXPAND transformation(this.name) FOREACH this.elements'
	[23,43] on line 1 'EXPAND template::template::module FOR model'                                  

977  ERROR WorkflowEngine     - Workflow interrupted. Reason: Couldn't find operation 'getModel()' for metatransform::ModelPackage::Class.
977  ERROR WorkflowEngine     - [ERROR]: Couldn't find operation 'getModel()' for metatransform::ModelPackage::Class.(Element: this.inPattern.inClass.getModel(); Reported by: Generator: generating 'template::template::module FOR model' => src-gen)
977  ERROR WorkflowEngine     - [ERROR]: Couldn't find operation 'getModel()' for metatransform::ModelPackage::Class.(Element: this.inPattern.inClass.getModel().name; Reported by: Generator: generating 'template::template::module FOR model' => src-gen)
978  ERROR WorkflowEngine     - [ERROR]: Couldn't find operation 'getModel()' for metatransform::ModelPackage::Class.(Element: EXPRESSION: this.inPattern.inClass.getModel().name; Reported by: Generator: generating 'template::template::module FOR model' => src-gen)
978  ERROR WorkflowEngine     - [ERROR]: Couldn't find operation 'getModel()' for metatransform::ModelPackage::Class.(Element: org.eclipse.internal.xpand2.ast.LetStatement@15ee470d; Reported by: Generator: generating 'template::template::module FOR model' => src-gen)
978  ERROR WorkflowEngine     - [ERROR]: Couldn't find operation 'getModel()' for metatransform::ModelPackage::Class.(Element: rule : TransformationPackage::Rule; Reported by: Generator: generating 'template::template::module FOR model' => src-gen)
978  ERROR WorkflowEngine     - [ERROR]: Couldn't find operation 'getModel()' for metatransform::ModelPackage::Class.(Element: EXPAND rule FOREACH this.rules; Reported by: Generator: generating 'template::template::module FOR model' => src-gen)
978  ERROR WorkflowEngine     - [ERROR]: Couldn't find operation 'getModel()' for metatransform::ModelPackage::Class.(Element: transformation(String moduleName) : MainConceptsPackage::Transformation; Reported by: Generator: generating 'template::template::module FOR model' => src-gen)
979  ERROR WorkflowEngine     - [ERROR]: Couldn't find operation 'getModel()' for metatransform::ModelPackage::Class.(Element: EXPAND transformation(this.name) FOREACH this.elements; Reported by: Generator: generating 'template::template::module FOR model' => src-gen)
979  ERROR WorkflowEngine     - [ERROR]: Couldn't find operation 'getModel()' for metatransform::ModelPackage::Class.(Element: org.eclipse.internal.xpand2.ast.FileStatement@25c3e05a; Reported by: Generator: generating 'template::template::module FOR model' => src-gen)
979  ERROR WorkflowEngine     - [ERROR]: Couldn't find operation 'getModel()' for metatransform::ModelPackage::Class.(Element: module : MainConceptsPackage::Module; Reported by: Generator: generating 'template::template::module FOR model' => src-gen)
979  ERROR WorkflowEngine     - [ERROR]: Couldn't find operation 'getModel()' for metatransform::ModelPackage::Class.(Element: EXPAND template::template::module FOR model; Reported by: Generator: generating 'template::template::module FOR model' => src-gen)


The unusual part is when i write a template file it gives me a contextual help and shows those operations on my modeling concepts (shows them as operations written in extension file). The extension file looks like this:

import metatransform;

MainConceptsPackage::Model getModel(ModelPackage::Class this) :
	this.package.getRootPackage().model;
	
ModelPackage::Package getRootPackage(ModelPackage::Package this) :
	this.superPackage == null ?  this : this.getRootPackage();


I use getModel() extension in template file (inClass is of type ModelPackage::Class and MainConceptsPackage::Model has name attribute):

...
«LET this.inPattern.inClass.name.subString(0,1).toLowerCase() AS in-»
	«in» «this.inPattern.inClass.getModel().name» «this.inPattern.inClass.name»
...


And the generator.mwe file:

<?xml version="1.0"?>
<workflow>
	<property name="model" value="MetaTransformer.xpand/src/metamodel/Module.xmi" />
	<property name="src-gen" value="src-gen" />
	
	<!-- set up EMF for stand alone execution -->
	<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" >
		<platformUri value=".."/>
	</bean>
	
	<!-- instantiate meta model -->
	<bean id="mm_emf" class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>

	<!-- load model and store it in slot 'model' -->
	<component class="org.eclipse.emf.mwe.utils.Reader">
		<uri value="platform:/resource/${model}" />
		<modelSlot value="model" />
	</component>
	
	<!-- check model -->
	<component class="org.eclipse.xtend.check.CheckComponent">
		<metaModel idRef="mm_emf"/>
		<checkFile value="metamodel::Checks" />
		<emfAllChildrenSlot value="model" />
	</component>
	
	<!--  generate code -->
	<component class="org.eclipse.xpand2.Generator">
		<metaModel idRef="mm_emf"/>
		<expand 
			value="template::template::module FOR model" />
		<outlet path="${src-gen}" >
			<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
		</outlet>
	</component>
</workflow>


When I don't use extension methods, generator works just fine and generates exactly what I wanted. The error only occurs when I insert those methods. So I'm wondering is there any additional setup I need to perform in generator.mwe or the error is consequence of something else?

Best regards,
Vladimir
Re: [Xpand/Xtend] Extension problem [message #1005604 is a reply to message #1005544] Sun, 27 January 2013 11:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6483
Registered: July 2009
Senior Member
Hi,

do you import the extension file in the template file?
Re: [Xpand/Xtend] Extension problem [message #1005605 is a reply to message #1005604] Sun, 27 January 2013 11:57 Go to previous messageGo to next message
Vladimir D is currently offline Vladimir DFriend
Messages: 15
Registered: January 2013
Junior Member
Thanks for answering so quickly. Yes I have imported it. I just forgot to write it down in first post. Here is somewhat more detailed preview of template file:

«IMPORT metatransform»

«EXTENSION metamodel::Extensions»

... some defines that are working and don't use extensions

«DEFINE rule FOR TransformationPackage::Rule»
rule «this.name» {
	from
«LET this.inPattern.inClass.name.subString(0,1).toLowerCase() AS in-»
		«in» : «this.inPattern.inClass.getModel().name»!«this.inPattern.inClass.name»
	«IF this.inPattern.checks.size > 0-»
		( 
		«EXPAND check(in) FOREACH this.inPattern.checks-»
		)
	«ENDIF-»
	to
«FOREACH this.outPattern.outClass AS outClass-»
	«LET outClass.name.subString(0,1).toLowerCase() AS out-»		
		«out» : «outClass.getModel().name»!«outClass.name»
		«IF this.outPattern.assignments.size > 0-»
		(
		«EXPAND assignment(out, in, this.outPattern.assignments) FOREACH this.outPattern.assignments-»
		) 
		«ENDIF-»
	«ENDLET»
«ENDFOREACH»
«ENDLET»

... some defines that are working and don't use extensions



I use the same src layout as it came in example project so my Extensions.ext file is in metamodel package.
Re: [Xpand/Xtend] Extension problem [message #1005606 is a reply to message #1005605] Sun, 27 January 2013 12:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6483
Registered: July 2009
Senior Member
this looks good so far,

did you try do use only qualified names in the extension file


MainConceptsPackage::Model getModel(metatransform::ModelPackage::Class this) :
this.package.getRootPackage().model;

ModelPackage::Package getRootPackage(metatransform::ModelPackage::Package this) :
this.superPackage == null ? this : this.getRootPackage();

maybe the use of nested epackages i a bad idea in general? did you search bugzilla for that?
Re: [Xpand/Xtend] Extension problem [message #1005609 is a reply to message #1005606] Sun, 27 January 2013 12:53 Go to previous messageGo to next message
Vladimir D is currently offline Vladimir DFriend
Messages: 15
Registered: January 2013
Junior Member
Christian, thank you very much for these suggestions. First one with only qualified names did not work. I've got the same result as before. Second suggestion regarding EPackages worked like a charm. I pulled up all of my classes to the root package and modified accordingly template and extension files, and all worked well.

Bugzilla has only one entry for Xpand/Xtend regarding nested EPackages with no EClassifiers. As I have at least one EClassifier in each EPackage i thought this wasn't the problem.
Re: [Xpand/Xtend] Extension problem [message #1044810 is a reply to message #1005609] Fri, 19 April 2013 11:20 Go to previous message
serhat gezgin is currently offline serhat gezginFriend
Messages: 240
Registered: January 2013
Location: Izmir
Senior Member
i have same problem too but one difference i use xsd as my metamodel. When i run

project from workflow there is no error but when i decide to run my workflow

programatically fom plug-in project as command i have;

[main] ERROR o.e.emf.mwe.core.WorkflowEngine - Workflow interrupted. Reason: Couldn't find operation 'moduleName(String)' for ir::IModule.

error. And i can't solve this. Anyone can help me ?

Regards
Previous Topic:[Xpand/Xtend] Extension problem
Next Topic: [Xpand/Xtend] Extension problem with xsd metamodel
Goto Forum:
  


Current Time: Sat Nov 22 15:48:26 GMT 2014

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

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