<
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="
http://control.ee.ethz.ch/XWeaver/AspectX"
xmlns:src="
http://www.sdml.info/srcML/src"
xsi:schemaLocation="
http://control.ee.ethz.ch/XWeaver/AspectX ../../../../src/xsd/aspectX.xsd"
name="
AddMethodComment">
<
description>
Sample aspect program to modify a method comment. This aspect program defines a text
fragment that can be added to the comment of a target method. The target method is defined by
name and is method <
code>
doAction</
code>
in class <
code>
DC_DummyPunctualAction</
code>
. Related
aspect programs (<
code>
AddClassComment_1</
code>
and <
code>
AddClassComment_2</
code>
) show how the
class comments can be modified. <
author>
A. Pasetti</
author>
<
see>
AddClassComment_1</
see>
<
see>
AddClassComment_2</
see>
</
description>
<
pointcut name="
targetClass"
type="
src:class"
constraint="
src:name='DC_DummyPunctualAction'">
<
description>
Points to the target class whose comment should be modified. </
description>
</
pointcut>
<
pointcut name="
targetMethodDeclaration"
type="
src:function_decl"
constraint="
src:name='doAction'">
<
description>
Points to the declaration of the target methods. This pointcut identifies all the
declaration of methods whose name is "doAction" and then restrits it to the declaration within
the elements identified by pointcut "targetClass".</
description>
<
restriction type="
within">
<
pointcutRef ref="
targetClass"
type="
src:class" />
</
restriction>
</
pointcut>
<
pointcut name="
targetMethodComment"
type="
src:comment">
<
description>
Points to the comment that must be modified. This comment is defined as the comment
that is followed by the <
code>
targetMethodDeclaration</
code>
pointcut. </
description>
<
restriction type="
followedBy">
<
pointcutRef type="
src:function_decl"
ref="
targetMethodDeclaration" />
</
restriction>
</
pointcut>
<
advice name="
addMethodComment"
type="
end">
<
description>
Add a comment at the end of the comment of the target class. The HTML tags in the
comment are expressed using escape sequences. Aspect program <
code>
AddClassComment_2</
code>
shows an alternative way to express the HTML tag.</
description>
<
pointcutRef ref="
targetMethodComment"
type="
src:comment" />
<
codeModifier type="
comment">
<
text>
This comment fragment was automatically inserted by an aspect program.</
text>
<
text>
The name of the aspect program is: <code>AddMethodComment</code>.</
text>
</
codeModifier>
</
advice>
</
aspect>
v