umlcode-generationxtendacceleoxpand

Type field of Property not filled in for UML PrimitiveType in Xpand


I have an XPT template that generates text from a UML model. This is the excerpt I use on the attributes of a class

«FOREACH attribute AS a»
    Id: «a.name»
    Type: «a.type.name»
«ENDFOREACH»

All works well as long as the type is a class from the model itself. But if it is a primitive type, then all of the fields, including the name, is set to null. If I change «a.type.name» to «a.type», then the response is something like this:

org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl@6e315086 (eProxyURI:
     pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String)

The debugger shows that only the eStorage private field is set on the object that is why the toString() produces the output above.

Interestingly the same expression in Acceleo is evaluated correctly:

[query public getType(t : Type) : String = t.name /]

Question: how can I get the type field of attributes be filled in for primitive uml types in Xtend?

EDIT: Issue narrowed down to this question: EProxy URI does not resolve in ecore model


Solution

  • The code generated by Acceleo can resolve the unusual pathmap:// eProxyURIs. By default, a simple Xpand template or Xtend code can't resolve them. See this question for more details and the solution.