block_around_codeFragment.xsl
Weaving Rule that replaces the contents of a block (Everything inside curly braces) with a code fragment.
- srcML element:
src:block - advice type:
around - codeModifier type:
codeFragment
Example 1
int foo() {
printf("Hello");
}
Code Modifier
<codeModifier type="codeFragment">
<text>printf("Hello World")</text>
</codeModifier>Modified Code
int foo() {
printf("Hello World");
}
Example 2
Base Code
int main() {
int i = 0;
int c = 5;
}
Code Modifier
The variable ${ blockBody} prints the original body content and indents it with two spaces (defined by the two spaces after '${').
<codeModifier type="codeFragment">
<text>try {</text>
<text>${ blockBody}</text>
<text>} catch ( ... ) {</text>
<text> <![CDATA[cout << "ERROR MESSAGE" << endl;]]></text>
<text>}</text>
</codeModifier>Modified Code
int main() {
try {
int i = 0;
int c = 5;
} catch (...) {
cout << "ERROR MESSAGE" << endl;
}
}
Examples in AspectX Sample Library
- PassiveToCyclical
- PassiveToSporadic
Examples in AspectX Test Suite
- AddSingleLineAtAround
CVS Id:
Author:
ibirrer
Copyright:
2004, P&P Software GmbH
Match Templates Summary
src:block[ax:advice[@type='around' and position() = 1]/ax:codeModifier[@type='codeFragment']] (mode: weaving) - source
Calls named template addAtEndOfBlock provided by XWeaver
Match Templates Detail
src:block[ax:advice[@type='around' and position() = 1]/ax:codeModifier[@type='codeFragment']] (mode: weaving) - source
Calls named template addAtEndOfBlock provided by XWeaver