class_add_member.xsl

Weaving Rule that adds a member to a Java class
  • srcML element: src:class
  • advice type: add
  • codeModifier type: member
Adds a member to the first possible location of the following choices:
  • Before the first method
  • As the last member in the class
A member is anything that can be a member of a class. E.g a method, a field, an inner class.

Example 1

Base Code

class Foo {
  public void foo() {}
}

Code Modifier

<codeModifier type="declaration">
    <accessModifier type="public"/>
    <text>public void foo_new() {}</text>
</codeModifier>

Modified Code

class Foo {
  public void foo_new() {}
  public void foo() {}
}

Examples in AspectX Sample Library

CVS Id:
Author:
ibirrer
Copyright:
2004-2005, P&P Software GmbH

Match Templates Summary

* (param: node-set advicemode: weaving_class_add_member_function) - source
Default copy template for adding declarations before a function definiton
src:comment[following-sibling::*[position() = 1 and self::src:function]][1] (param: node-set advicemode: weaving_class_add_member_function) - source
If a function has a comment attached, the declaration is added before the comment
src:function[1] (param: node-set advicemode: weaving_class_add_member_function) - source
This template adds the member before the first method that occurs in the source file
Adds a member to the first possible location of the following choices:

Match Templates Detail

* (param: node-set advicemode: weaving_class_add_member_function) - source
Default copy template for adding declarations before a function definiton
 
Parameters:
node-set advice - The advice element which will be used for weaving the unit.
src:comment[following-sibling::*[position() = 1 and self::src:function]][1] (param: node-set advicemode: weaving_class_add_member_function) - source
If a function has a comment attached, the declaration is added before the comment
 
Parameters:
node-set advice - The advice element which will be used for weaving the class.
src:function[1] (param: node-set advicemode: weaving_class_add_member_function) - source
This template adds the member before the first method that occurs in the source file
Parameters:
node-set advice - The advice element which will be used for weaving the unit.
Adds a member to the first possible location of the following choices: