* Anna's code from here
*/
- ASTNode block = fragment.getAssociatedNode();
- while(! (block instanceof Block)){
- block = block.getParent();
+ ASTNode exprstatement = fragment.getAssociatedNode();
+ while( !(exprstatement instanceof ExpressionStatement)){
+ exprstatement = exprstatement.getParent();
}
+
- ASTNode exprstatement = fragment.getAssociatedNode();
- while( ! (exprstatement instanceof ExpressionStatement)){
+ ASTNode block = exprstatement.getParent();
+
+ while(! (block instanceof Block)){
+ block = block.getParent();
exprstatement = exprstatement.getParent();
}
+
ListRewrite lr = rewrite.getListRewrite(block, Block.STATEMENTS_PROPERTY);
lr.insertBefore(getAssertStatement(block.getAST()), exprstatement, null);