当前位置: 首页>>代码示例>>Java>>正文


Java CtStatement.insertBefore方法代码示例

本文整理汇总了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;
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:14,代码来源:TestMethodCallAdder.java

示例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);
}
 
开发者ID:SpoonLabs,项目名称:nopol,代码行数:13,代码来源:SpoonStatementLibrary.java


注:本文中的spoon.reflect.code.CtStatement.insertBefore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。