class_add_declaration.xsl

Weaving Rule that adds a declaration to a class
  • srcML element: src:class
  • advice type: add
  • codeModifier type: declaration
Adds a declaration to the first possible location of the following choices:
  • Check if appropriate access modifiers exist, if not add an advice to the class so they are added the next time.
  • If all access modifiers have been added, the add advices of the class are moved to the access modifier elements.

Example 1

Base Code

class Foo {
  public:
}

Code Modifier

<codeModifier type="declaration">
    <accessModifier type="public"/>
    <text>int foo();</text>
</codeModifier>

Modified Code

class Foo {
  public:
    int foo();
}

Example 2

Access modifier blocks are added by the weaver if needed.

Base Code

class Foo {
  public:
    int foo1();
}

Code Modifier

<codeModifier type="declaration">
    <accessModifier type="private"/>
    <text>int foo2();</text>
</codeModifier>

Modified Code

class Foo {
  public:
    int foo1();
  private:
    int foo2();
}

Examples in AspectX Sample Library

Examples in AspectX Test Suite

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

Match Templates Summary

* (param: advicesmode: class_add_declaration_move_declarations) - source
Default copy template for class_add_declaration_move_declarations
src:public | src:private | src:protected (param: advicesmode: class_add_declaration_move_declarations) - source
Move advices to the appropriate access modifier element

Match Templates Detail

* (param: advicesmode: class_add_declaration_move_declarations) - source
Default copy template for class_add_declaration_move_declarations
Parameters:
advices -
src:public | src:private | src:protected (param: advicesmode: class_add_declaration_move_declarations) - source
Move advices to the appropriate access modifier element
Parameters:
advices -
This template does the following:
  • Check if appropriate access modifiers exist, if not add an advice to the class so they are added the next time.
  • If all access modifiers have been added, the add advices of the class are moved to the access modifier elements.