<
ax:
aspect xmlns:cpp="
http://www.sdml.info/srcML/cpp"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
xmlns:ax="
http://control.ee.ethz.ch/XWeaver/AspectX"
xmlns:util="
http://www.pnp-software.com/util"
xmlns:src="
http://www.sdml.info/srcML/src"
xmlns:java="
http://www.sdml.info/srcML/java"
xsi:schemaLocation="
http://control.ee.ethz.ch/XWeaver/AspectX ../../../../src/xsd/aspectX.xsd"
name="
CleanupComments">
<
ax:
description>
<
p>
Adds a javadoc like comment to all undocumented method declarations.
The generated comment has the following form: </
p>
<
pre>
/**
* @author: XWeaver
*
* @param type
* ...
* @return type
*/</
pre>
<
p>
Printing the @param tags is done by iterating (xsl:for-each) the predefined $paramNames variable.
Return comments are only printed if the return type is not 'void'</
p>
</
ax:
description>
<
ax:
pointcut constraint="
not(preceding-sibling::*[position() = 1 and self::src:comment[@type='block']])"
name="
UndocumentedMethods"
type="
src:function_decl">
<
ax:
description>
Points to all undocumented methods. The XPath constraint checks if
the immediate preceding-sibling of a function_decl element is a
src:comment element with the attribute type set to 'block'.
</
ax:
description>
</
ax:
pointcut>
<
ax:
pointcut constraint="
not(*[position() = 1 and self::src:comment[@type='block']])"
name="
UndocumentedFiles"
type="
src:unit">
<
ax:
description>
Points to all undocumented files. The XPath constraint checks if
the first child of unit element is a src:comment element with the
attribute type set to 'block'.
</
ax:
description>
</
ax:
pointcut>
<
ax:
advice name="
AddMethodComment"
type="
add">
<
ax:
description>
Adds a block comment. For more information see aspect documentation above</
ax:
description>
<
ax:
pointcutRef ref="
UndocumentedMethods"
type="
src:function_decl" />
<
ax:
codeModifier type="
comment">
<
ax:
xsl>
<
xsl:
text>
/**</
xsl:
text>
<
xsl:
text>
* @author XWeaver</
xsl:
text>
<
xsl:
text>
*</
xsl:
text>
<
xsl:
for-each select="
$paramNames">
<
xsl:
text>
* @param </
xsl:
text>
<
xsl:
value-of select="
preceding-sibling::src:type" />
<
xsl:
value-of select="
concat( ' ', . )" />
</
xsl:
for-each>
<
xsl:
if test="
src:type/src:name != 'void'">
<
xsl:
text>
* @return </
xsl:
text>
<
xsl:
value-of select="
src:type/src:name" />
</
xsl:
if>
<
xsl:
text>
*/</
xsl:
text>
</
ax:
xsl>
</
ax:
codeModifier>
</
ax:
advice>
<
ax:
advice name="
AddFileComment"
type="
add">
<
ax:
description>
Adds a block comment. For more information see aspect documentation above</
ax:
description>
<
ax:
pointcutRef ref="
UndocumentedFiles"
type="
src:unit" />
<
ax:
codeModifier type="
comment">
<
ax:
text>
/*</
ax:
text>
<
ax:
text>
* Copyright P&P - Software 2005</
ax:
text>
<
ax:
text>
*/</
ax:
text>
<
ax:
text />
</
ax:
codeModifier>
</
ax:
advice>
</
ax:
aspect>
v