unit_add_include.xsl

Weaving Rule that adds an include statement to a unit.
  • srcML element: src:unit
  • advice type: add
  • codeModifier type: cpp:include
Adds includes to the first possible location of the following choices:
  1. Directly before other inlcudes
  2. Before first class definition (or before the comment or this class if it has one)
  3. Before first function definition

Example

#include <stdio.h>
void Foo:foo() {
  printf("foo");
}

Code Modifier

<codeModifier type="include">
  <text>#include "MyClass.h"</text>
</codeModifier>

Modified Code

#include <stdio.h>
#include "MyClass.h"
void Foo:foo() {
  printf("foo");
}

Examples in AspectX Sample Library

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

Match Templates Summary

* (param: node-set advicemode: weaving_unit_add_include_class) - source
Default copy template for adding an include before a class definition
src:class[1] (param: node-set advicemode: weaving_unit_add_include_class) - source
Adds includes before the first class containing a block that occurs in the source file
src:comment[following-sibling::src:class[1]][last()] (param: node-set advicemode: weaving_unit_add_include_class) - source
If a class has a comment attached the include is added before the comment
* (param: node-set advicemode: weaving_unit_add_include_function) - source
Default copy template for adding includes before a function definiton
src:function[1] (param: node-set advicemode: weaving_unit_add_include_function) - source
This template adds the includes before the first function that occurs in the source file
* (param: node-set advicemode: weaving_unit_add_include_include) - source
Default copy template for adding includes before an existing include
cpp:include[1] (param: node-set advicemode: weaving_unit_add_include_include) - source
This template adds the includes before the first include
Adds includes to the first possible location of the following choices:

Match Templates Detail

* (param: node-set advicemode: weaving_unit_add_include_class) - source
Default copy template for adding an include before a class definition
Parameters:
node-set advice - The advice element which will be used for weaving the unit.
src:class[1] (param: node-set advicemode: weaving_unit_add_include_class) - source
Adds includes before the first class containing a block that occurs in the source file
Parameters:
node-set advice - The advice element which will be used for weaving the unit.
src:comment[following-sibling::src:class[1]][last()] (param: node-set advicemode: weaving_unit_add_include_class) - source
If a class has a comment attached the include is added before the comment
 
Parameters:
node-set advice - The advice element which will be used for weaving the unit.
* (param: node-set advicemode: weaving_unit_add_include_function) - source
Default copy template for adding includes before a function definiton
 
Parameters:
node-set advice - The advice element which will be used for weaving the unit.
src:function[1] (param: node-set advicemode: weaving_unit_add_include_function) - source
This template adds the includes before the first function that occurs in the source file
Parameters:
node-set advice - The advice element which will be used for weaving the unit.
* (param: node-set advicemode: weaving_unit_add_include_include) - source
Default copy template for adding includes before an existing include
Parameters:
node-set advice - The advice element which will be used for weaving the unit.
cpp:include[1] (param: node-set advicemode: weaving_unit_add_include_include) - source
This template adds the includes before the first include
 
Parameters:
node-set advice - The advice element which will be used for weaving the unit.
Adds includes to the first possible location of the following choices: