Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [TEXO] Enum documentation
[TEXO] Enum documentation [message #883308] Fri, 08 June 2012 09:03 Go to next message
Gary Godfrey is currently offline Gary GodfreyFriend
Messages: 31
Registered: February 2012
Member
Hi Martin,

How can I ensure documentation is added to the generated Enum please?
Example XSD section:
	<xs:simpleType name="TelephoneType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="TETY1">
				<xs:annotation>
					<xs:documentation>Mobile</xs:documentation>
				</xs:annotation>
			</xs:enumeration>
			<xs:enumeration value="TETY2">
				<xs:annotation>
					<xs:documentation>LandLine</xs:documentation>
				</xs:annotation>
			</xs:enumeration>
		</xs:restriction>
	</xs:simpleType>


The .ecore correctly extracts the required documentation:
  <eClassifiers xsi:type="ecore:EEnum" name="TelephoneType">
    <eAnnotations source="org/eclipse/emf/ecore/util/ExtendedMetaData">
      <details key="name" value="TelephoneType"/>
    </eAnnotations>
    <eLiterals name="TETY1">
      <eAnnotations source="org/emf/2002/GenModel">
        <details key="documentation" value="Mobile"/>
      </eAnnotations>
    </eLiterals>
    <eLiterals name="TETY2" value="1">
      <eAnnotations source="org/emf/2002/GenModel">
        <details key="documentation" value="LandLine"/>
      </eAnnotations>
    </eLiterals>
  </eClassifiers>


In enum.xpt I cannot though determine how to access the value. e.g. Mobile or LandLine

The key section of my enum.xpt is:
«FOREACH eEnum.ELiterals AS e SEPARATOR ","-»
	«LET ((EEnumLiteral)e) AS el-»
	 	/**
	 	 * The enum: «toUpperCase(el.literal)»
	     * <!-- begin-user-doc -->
$$$$
Trying to add Mobile / Landline here
$$$$
	     * <!-- end-user-doc -->
		 * @generated
	 	 */
		«modelController.getJavaAnnotations(el, "field")-»
		 «toUpperCase(el.literal)»
		 
	«ENDLET-»
«ENDFOREACH-»;

Regards,
Gary

[Updated on: Fri, 08 June 2012 09:24]

Report message to a moderator

Re: Enum documentation [message #883359 is a reply to message #883308] Fri, 08 June 2012 11:07 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5339
Registered: July 2009
Senior Member
Hi Gary,
Can you try something like this:

«IF this.documentation != null-»
* <!-- begin-model-doc -->
* «this.documentation»
* <!-- end-model-doc -->
«ENDIF-»

gr. Martin

On 06/08/2012 11:03 AM, Gary Godfrey wrote:
> Hi Martin,
>
> How can I ensure documentation is added to the generated Enum please?
> Example XSD section:
>
> <xs:simpleType name="TelephoneType">
> <xs:restriction base="xs:string">
> <xs:enumeration value="TETY1">
> <xs:annotation>
> <xs:documentation>Mobile</xs:documentation>
> </xs:annotation>
> </xs:enumeration>
> <xs:enumeration value="TETY2">
> <xs:annotation>
> <xs:documentation>LandLine</xs:documentation>
> </xs:annotation>
> </xs:enumeration>
> </xs:restriction>
> </xs:simpleType>
>
>
> The .ecore correctly extracts the required documentation:
>
> <eClassifiers xsi:type="ecore:EEnum" name="TelephoneType">
> <eAnnotations source="org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="TelephoneType"/>
> </eAnnotations>
> <eLiterals name="TETY1">
> <eAnnotations source="org/emf/2002/GenModel">
> <details key="documentation" value="Mobile"/>
> </eAnnotations>
> </eLiterals>
> <eLiterals name="TETY2" value="1">
> <eAnnotations source="org/emf/2002/GenModel">
> <details key="documentation" value="LandLine"/>
> </eAnnotations>
> </eLiterals>
> </eClassifiers>
>
>
> In enum.xpt I cannot though determine how to access the value. e.g. Mobile or LandLine
>
> The key section of my enum.xpt is:
>
> «FOREACH eEnum.ELiterals AS e SEPARATOR ","-»
> «LET ((EEnumLiteral)e) AS el-»
> /**
> * The enum: «toUpperCase(el.literal)»
> * <!-- begin-user-doc -->
> $$$$
> Trying to add Mobile / Landline here
> $$$$
> * <!-- end-user-doc -->
> * @generated
> */
> «modelController.getJavaAnnotations(el, "field")-»
> «toUpperCase(el.literal)»
> «ENDLET-»
> «ENDFOREACH-»;
>
> Regards,
> Gary


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Enum documentation [message #883431 is a reply to message #883359] Fri, 08 June 2012 14:10 Go to previous messageGo to next message
Gary Godfrey is currently offline Gary GodfreyFriend
Messages: 31
Registered: February 2012
Member
Hi Martin,

Tried this but didn't work:

«FOREACH eEnum.ELiterals AS e SEPARATOR ","-»
	«LET ((EEnumLiteral)e) AS el-»
	 	/**
	 	 * The enum: «toUpperCase(el.literal)»
	     * <!-- begin-user-doc -->
	     * <!-- end-user-doc -->
         * <!-- begin-model-doc -->
		 «IF this.documentation != null-»
		 * «this.documentation»
		 * <!-- end-model-doc -->
		«ENDIF-»

		 * @generated
	 	 */
		«modelController.getJavaAnnotations(el, "field")-»
		 «toUpperCase(el.literal)»
		 
	«ENDLET-»
«ENDFOREACH-»;


The corresponding Enum prints:
public enum TelephoneType
{

	/**
	 * The enum: TETY1 <!-- begin-user-doc --> TETY1 <!-- end-user-doc --> <!--
	 * begin-model-doc -->
	 * 
	 * @generated
	 */
	TETY1

	, /**
	 * The enum: TETY2 <!-- begin-user-doc --> TETY2 <!-- end-user-doc -->
	 * <!-- begin-model-doc -->
	 * 
	 * @generated
	 */
	TETY2

	;
Re: Enum documentation [message #883450 is a reply to message #883431] Fri, 08 June 2012 15:02 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5339
Registered: July 2009
Senior Member
Okay, let me test it locally, I will do a new build later today which then also should solve this.

gr. Martin

On 06/08/2012 04:10 PM, Gary Godfrey wrote:
> Hi Martin,
>
> Tried this but didn't work:
>
>
> «FOREACH eEnum.ELiterals AS e SEPARATOR ","-»
> «LET ((EEnumLiteral)e) AS el-»
> /**
> * The enum: «toUpperCase(el.literal)»
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * <!-- begin-model-doc -->
> «IF this.documentation != null-»
> * «this.documentation»
> * <!-- end-model-doc -->
> «ENDIF-»
>
> * @generated
> */
> «modelController.getJavaAnnotations(el, "field")-»
> «toUpperCase(el.literal)»
> «ENDLET-»
> «ENDFOREACH-»;
>
>
> The corresponding Enum prints:
>
> public enum TelephoneType
> {
>
> /**
> * The enum: TETY1 <!-- begin-user-doc --> TETY1 <!-- end-user-doc --> <!--
> * begin-model-doc -->
> * * @generated
> */
> TETY1
>
> , /**
> * The enum: TETY2 <!-- begin-user-doc --> TETY2 <!-- end-user-doc -->
> * <!-- begin-model-doc -->
> * * @generated
> */
> TETY2
>
> ;
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Enum documentation [message #883543 is a reply to message #883431] Fri, 08 June 2012 18:43 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5339
Registered: July 2009
Senior Member
Hi Gary,
I published a new build which should work, to get the documentation you have to do this:
«IF getDocumentation(el) != null-»
* <!-- begin-model-doc -->
* «getDocumentation(el)»
* <!-- end-model-doc -->
«ENDIF-»

gr. Martin


On 06/08/2012 04:10 PM, Gary Godfrey wrote:
> Hi Martin,
>
> Tried this but didn't work:
>
>
> «FOREACH eEnum.ELiterals AS e SEPARATOR ","-»
> «LET ((EEnumLiteral)e) AS el-»
> /**
> * The enum: «toUpperCase(el.literal)»
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * <!-- begin-model-doc -->
> «IF this.documentation != null-»
> * «this.documentation»
> * <!-- end-model-doc -->
> «ENDIF-»
>
> * @generated
> */
> «modelController.getJavaAnnotations(el, "field")-»
> «toUpperCase(el.literal)»
> «ENDLET-»
> «ENDFOREACH-»;
>
>
> The corresponding Enum prints:
>
> public enum TelephoneType
> {
>
> /**
> * The enum: TETY1 <!-- begin-user-doc --> TETY1 <!-- end-user-doc --> <!--
> * begin-model-doc -->
> * * @generated
> */
> TETY1
>
> , /**
> * The enum: TETY2 <!-- begin-user-doc --> TETY2 <!-- end-user-doc -->
> * <!-- begin-model-doc -->
> * * @generated
> */
> TETY2
>
> ;
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Previous Topic:TENEO problems on HOT redeploy
Next Topic:Customizing the palette
Goto Forum:
  


Current Time: Sat Nov 22 02:11:58 GMT 2014

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

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