Open GoogleCodeExporter opened 8 years ago
I made myself a little method support.
Note 1:
I have to admit that I rather do not understand ArgoUML consept of Operations
(supports arguments and return type) and Methods (created inside Operations and
support body), due that fact I made it so that you have to write inside
Operation ->
Documentation -> See the code you want to add.
Note 2:
For every method body you have to add atleast pass. (I just did want to get it
working and XSL is unfamiliar to me, so I made quict dirty improvement.)
To get method support working you have to add to line file
xmi2djmodels_generic.xsl
line 147:
<xsl:apply-templates select="UML:Classifier.feature/UML:Operation" />
And to the end, before "</xsl:stylesheet>" tag:
<!-- ========================== -->
<!-- METHOD TEMPLATE -->
<!-- ========================== -->
<xsl:template match="UML:Classifier.feature/UML:Operation">
<!-- get method name -->
<xsl:variable name="methodName" select="@name" />
<xsl:variable name="methodNameDj"><xsl:call-template
name="getDjIdentifierL"><xsl:with-param name="name"
select="$methodName"/></xsl:call-template></xsl:variable>
def <xsl:value-of select="$methodNameDj" /><xsl:text> ( </xsl:text>
<!-- get method args -->
<xsl:for-each select="UML:BehavioralFeature.parameter/UML:Parameter">
<xsl:variable name="paramName" select="@name" />
<xsl:variable name="paramType"
select="UML:Parameter.type/UML:DataType/@xmi.idref" />
<xsl:variable name="paramDefValue"
select="UML:Parameter.defaultValue/UML:Expression/@body" />
<xsl:choose>
<xsl:when test="$paramName='return'">
<xsl:variable name="methodReturn"
select="$paramType" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$paramName" />
<xsl:if test="$paramDefValue"> =
<xsl:value-of select="$paramDefValue" />, </xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:text>):</xsl:text>
<!-- get method body -->
<xsl:for-each select="UML:ModelElement.taggedValue/UML:TaggedValue">
<xsl:variable name="dataValue"
select="UML:TaggedValue.dataValue" />
<xsl:variable name="dataType"
select="UML:TaggedValue.type/UML:TagDefinition/@xmi.idref" />
<!-- if its method body -->
<xsl:if test="$dataType =
'127-0-1-1-45f85888:126c2a04675:-8000:000000000000109E'" >
<xsl:text>
</xsl:text>
<xsl:value-of select="$dataValue" />
</xsl:if>
</xsl:for-each>
</xsl:template>
Hope, it helps someone.
Br,
Original comment by mar...@tione.eu
on 13 Feb 2010 at 11:28
[deleted comment]
I have changed a bit xsl file, so code generated from XMI will have following
difference:
- Fixed problem if argument had no default value (no comma was in the end added)
- Fixed problem that if you had **dict = {} as argument it was added to code as:
"**dict = {}, " witch caused problem, because you can't have there default
value,
also comma in the end cause error.
Original comment by mar...@tione.eu
on 25 Feb 2010 at 8:16
Attachments:
Original issue reported on code.google.com by
mar...@tione.eu
on 9 Feb 2010 at 11:32