AddMethodComment Aspect
[Basic Group]

This aspect is defined in file: ../../AspectXLib/base/Base/aspects/AddMethodComment.ax ../../AspectXLib/car/Car/aspects/CleanupComments.ax ../../AspectXLib/java/ShoppingCart/aspects/CleanupComments.ax

Aspect 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 doAction in class DC_DummyPunctualAction. Related aspect programs (AddClassComment_1 and AddClassComment_2) show how the class comments can be modified.

Adds a javadoc like comment to all undocumented method declarations. The generated comment has the following form:

/**
* @author: XWeaver
*
* @param type
* ...
* @return type
*/

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'

Adds a Javadoc comment to all undocumented methods. The generated comments have the following form:

/**
* @author: XWeaver
*
* @param type
* ...
* @return type
*/

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'

This aspect is an adapted aspect of the CleanupComments aspect used in the C++ Car example. The only thing which had to be changed was to replace the pointcut type src:function_decl to src:function because Java does not no such a thing as a function declaration.

Author:
A. Pasetti
See also:
AddClassComment_1
AddClassComment_2

Pointcuts

classtargetClass
 Points to the target class whose comment should be modified
function_decltargetMethodDeclaration
 Points to the declaration of the target methods
commenttargetMethodComment
 Points to the comment that must be modified
function_declUndocumentedMethods
  Points to all undocumented methods
unitUndocumentedFiles
  Points to all undocumented files
functionUndocumentedMethods
  Points to all undocumented methods
unitUndocumentedFiles
  Points to all undocumented files

Advices

endaddMethodComment
 Add a comment at the end of the comment of the target class
addAddMethodComment
 Adds a block comment
addAddFileComment
 Adds a block comment
addAddMethodComment
 Adds a block comment
addAddFileComment
 Adds a block comment

Pointcut Documentation

class targetClass (source)
Points to the target class whose comment should be modified.
function_decl targetMethodDeclaration (source)
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".
comment targetMethodComment (source)
Points to the comment that must be modified. This comment is defined as the comment that is followed by the targetMethodDeclaration pointcut.
function_decl UndocumentedMethods (source)
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'.
unit UndocumentedFiles (source)
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'.
function UndocumentedMethods (source)
Points to all undocumented methods. The XPath constraint checks if the immediate preceding-sibling of a function element is a src:comment element with the attribute type set to 'block'.
unit UndocumentedFiles (source)
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'.

Advice Documentation

end addMethodComment (source)

Triplet: comment end comment

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 AddClassComment_2 shows an alternative way to express the HTML tag.

Refers to global pointcut: comment targetMethodComment

add AddMethodComment (source)

Triplet: function_decl add comment

Adds a block comment. For more information see aspect documentation above

Refers to global pointcut: function_decl UndocumentedMethods

add AddFileComment (source)

Triplet: unit add comment

Adds a block comment. For more information see aspect documentation above

Refers to global pointcut: unit UndocumentedFiles

add AddMethodComment (source)

Triplet: function add comment

Adds a block comment. For more information see aspect documentation above

Refers to global pointcut: function UndocumentedMethods

add AddFileComment (source)

Triplet: unit add comment

Adds a block comment. For more information see aspect documentation above

Refers to global pointcut: unit UndocumentedFiles