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


Java CtMethod.getDeclaringType方法代码示例

本文整理汇总了Java中spoon.reflect.declaration.CtMethod.getDeclaringType方法的典型用法代码示例。如果您正苦于以下问题:Java CtMethod.getDeclaringType方法的具体用法?Java CtMethod.getDeclaringType怎么用?Java CtMethod.getDeclaringType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在spoon.reflect.declaration.CtMethod的用法示例。


在下文中一共展示了CtMethod.getDeclaringType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import spoon.reflect.declaration.CtMethod; //导入方法依赖的package包/类
public List<CtMethod> apply(CtMethod method) {
    List<CtMethod> methods = new ArrayList<>();

    if (method.getDeclaringType() != null) {
        //get the list of method calls
        List<CtInvocation> invocations = Query.getElements(method, new TypeFilter(CtInvocation.class));
        //this index serves to replace ith literal is replaced by zero in the ith clone of the method
        int invocation_index = 0;
        for (CtInvocation invocation : invocations) {
            try {
                if (toRemove(invocation)
                        && !AmplificationChecker.isAssert(invocation)
                        && !inWhileLoop(invocation)
                        && !containsIteratorNext(invocation)) {
                    methods.add(apply(method, invocation_index));
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            invocation_index++;
        }
    }
    return AmplificationHelper.updateAmpTestToParent(methods, method);
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:25,代码来源:TestMethodCallRemover.java

示例2: apply

import spoon.reflect.declaration.CtMethod; //导入方法依赖的package包/类
public List<CtMethod> apply(CtMethod method) {
    List<CtMethod> methods = new ArrayList<>();

    if (method.getDeclaringType() != null) {
        //get the list of method calls
        List<CtInvocation> invocations = Query.getElements(method, new TypeFilter(CtInvocation.class));
        //this index serves to replace ith literal is replaced by zero in the ith clone of the method
        int invocation_index = 0;
        for (CtInvocation invocation : invocations) {
            try {
                if (AmplificationChecker.canBeAdded(invocation) && !AmplificationChecker.isAssert(invocation)) {
                    methods.add(apply(method, invocation_index));
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            invocation_index++;
        }
    }
    return AmplificationHelper.updateAmpTestToParent(methods, method);
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:22,代码来源:TestMethodCallAdder.java

示例3: applyRandom

import spoon.reflect.declaration.CtMethod; //导入方法依赖的package包/类
public CtMethod applyRandom(CtMethod method) {
    if (method.getDeclaringType() != null) {
        List<CtInvocation> invocations = Query.getElements(method, new TypeFilter(CtInvocation.class));
        if (!invocations.isEmpty()) {
            try {
                int invocation_index = AmplificationHelper.getRandom().nextInt(invocations.size());
                return apply(method, invocation_index);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
    return null;
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:15,代码来源:TestMethodCallRemover.java

示例4: applyRandom

import spoon.reflect.declaration.CtMethod; //导入方法依赖的package包/类
public CtMethod applyRandom(CtMethod method) {
    if (method.getDeclaringType() != null) {
        List<CtInvocation> invocations = Query.getElements(method, new TypeFilter(CtInvocation.class));
        while (!invocations.isEmpty()) {
            try {
                int invocation_index = AmplificationHelper.getRandom().nextInt(invocations.size());
                return apply(method, invocation_index);
            } catch (Exception ignored) {

            }
        }
    }
    return null;
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:15,代码来源:TestMethodCallAdder.java


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