本文整理汇总了Java中spoon.reflect.code.CtStatement.insertBefore方法的典型用法代码示例。如果您正苦于以下问题:Java CtStatement.insertBefore方法的具体用法?Java CtStatement.insertBefore怎么用?Java CtStatement.insertBefore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spoon.reflect.code.CtStatement
的用法示例。
在下文中一共展示了CtStatement.insertBefore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import spoon.reflect.code.CtStatement; //导入方法依赖的package包/类
private CtMethod apply(CtMethod method, int invocation_index) {
CtMethod<?> cloned_method = AmplificationHelper.cloneMethodTest(method, "_add");
//add the cloned method in the same class as the original method
//get the lit_indexth literal of the cloned method
CtInvocation stmt = Query.getElements(cloned_method, new TypeFilter<>(CtInvocation.class)).get(invocation_index);
CtInvocation cloneStmt = stmt.clone();
final CtStatement parent = getParent(stmt);
parent.insertBefore(cloneStmt);
cloneStmt.setParent(parent.getParent(CtBlock.class));
Counter.updateInputOf(cloned_method, 1);
DSpotUtils.addComment(cloneStmt, "MethodCallAdder", CtComment.CommentType.INLINE);
return cloned_method;
}
示例2: insertBeforeUnderSameParent
import spoon.reflect.code.CtStatement; //导入方法依赖的package包/类
public static void insertBeforeUnderSameParent(CtStatement toBeInserted, CtStatement insertionPoint) {
CtElement parent;
if (isBlock(insertionPoint)) {
CtBlock<?> block = (CtBlock<?>) insertionPoint;
block.insertBegin(toBeInserted);
parent = block;
} else {
insertionPoint.insertBefore(toBeInserted);
parent = insertionPoint.getParent();
}
setParent(parent, toBeInserted);
}