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 #1005545] Sat, 26 January 2013 13:00 Go to next message
Vladimir D is currently offline Vladimir D
Messages: 13
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 #1044797 is a reply to message #1005545] Fri, 19 April 2013 11:02 Go to previous messageGo to next message
serhat gezgin is currently offline serhat gezgin
Messages: 240
Registered: January 2013
Location: Izmir
Senior Member
Hi Vladimir,

I saw same problem on my project too. U find any soloution about this ?

Regards
Re: [Xpand/Xtend] Extension problem [message #1044802 is a reply to message #1044797] Fri, 19 April 2013 11:07 Go to previous message
Vladimir D is currently offline Vladimir D
Messages: 13
Registered: January 2013
Junior Member
Hi Serhat,

this is the right topic for this question: http://www.eclipse.org/forums/index.php/t/452143/. I hope you can find your answer there.

Best regards.
Previous Topic:EcoreXMI to OMG standard xmi conversion
Next Topic:[Xpand/Xtend] Extension problem
Goto Forum:
  


Current Time: Fri Oct 24 15:45:31 GMT 2014

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

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