Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 312561

Summary: Xpand cannot access structural features of EEnumLiteral for ecore metamodel inputs
Product: [Modeling] M2T Reporter: Dennis Hendriks <dh_tue>
Component: XpandAssignee: Project Inbox <m2t.xpand-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: christian.dietrich.opensource, dh_tue
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
The example Xpand template to illustrate the problem. none

Description Dennis Hendriks CLA 2010-05-12 05:41:05 EDT
Build Identifier: Build id: 20100218-1602 (Galileo SR2)

For Xpand templates that have as input instances of the ecore metamodel, (that is, they have an Ecore as input), the structural features of EEnumLiterals cannot be accessed.

For instance, using the Xpand template from the attachement (test.xpt), executing the workflow gives:

[code]
844  ERROR AbstractExpressionsUsingWorkflowComponent - Error in Component  of type org.eclipse.xpand2.Generator: 
	EvaluationException : Couldn't find property 'name' for type cif::ActionDirections
	template::test.xpt[514,8] on line 24 'lit.name'                                                    
	template::test.xpt[392,35] on line 18 'EXPAND expELiterals FOR (EEnum)this'                        
	template::test.xpt[201,61] on line 12 'EXPAND expEClassifier FOREACH eClassifiers.sortBy(c|c.name)'
	template::test.xpt[111,27] on line 7 'EXPAND expEPackage FOR this'                                 
	[23,37] on line 1 'EXPAND template::test::main FOR model'                                          

846  ERROR WorkflowRunner     - Workflow interrupted. Reason: Couldn't find property 'name' for type cif::ActionDirections
(...)
[/code]

Statically everything is OK, but at runtime the errors pop up.

The input model is cif.ecore, which contains an enumeration called 'ActionDirections', but the problem shows up for any ecore with an enumeration in it. For some reason variable 'lit' seems to be the enumeration type defined in cif.ecore instead of an instance of EEnumLiteral, or at least that's what the printed representation indicates. «EEnumLiteral.isInstance(lit)» evaluates to true, so 'lit' does seem to be an EEnumLiteral, but structural features like 'name', 'literal', 'instance', 'eAnnotations', etc cannot be accessed. About the only thing that can be done, is to call toString() on it...


Reproducible: Always

Steps to Reproduce:
1. Put the attachment (test.xpt) in an Xpand project.
2. Create a workflow which calls test.xpt for any Ecore with an enumeration defined in it.
3. Observe the errors.
Comment 1 Dennis Hendriks CLA 2010-05-12 05:41:48 EDT
Created attachment 168105 [details]
The example Xpand template to illustrate the problem.
Comment 2 Karsten Thoms CLA 2020-04-30 13:55:07 EDT
This is a batch close of open M2T Xpand bugs. It is not planned work on this component in the foreseeable future. If you think this issue needs to be solved and you plan to contribute a fix then feel free to reopen it.