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


Java CtMethod.getElements方法代码示例

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


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

示例1: generateNewTestMethod

import spoon.reflect.declaration.CtMethod; //导入方法依赖的package包/类
private CtMethod<?> generateNewTestMethod(CtMethod<?> testMethod,
                                          Map<String, List<String>> conditionForParameter) {
    final CtMethod clone = AmplificationHelper.cloneMethodTest(testMethod, "_examplifier");
    final List<?> solutions = SMTSolver.solve(conditionForParameter);
    final Iterator<?> iterator = solutions.iterator();
    final List<CtLiteral> originalLiterals =
            clone.getElements(new TypeFilter<>(CtLiteral.class));
    conditionForParameter.keySet()
            .forEach(s -> {
                final int indexOfLit = Integer.parseInt(s.substring("param".length()));
                final CtLiteral literalToBeReplaced = originalLiterals.get(indexOfLit);
                final CtLiteral<?> newLiteral = testMethod.getFactory().createLiteral(iterator.next());
                if (literalToBeReplaced.getParent() instanceof CtUnaryOperator) {
                    literalToBeReplaced.getParent().replace(newLiteral);
                } else {
                    literalToBeReplaced.replace(newLiteral);
                }
            });
    return clone;
}
 
开发者ID:STAMP-project,项目名称:Ex2Amplifier,代码行数:21,代码来源:Ex2Amplifier.java

示例2: getExistingObjects

import spoon.reflect.declaration.CtMethod; //导入方法依赖的package包/类
private List<CtLocalVariable<?>> getExistingObjects(CtMethod method) {
	return method.getElements(new TypeFilter<CtLocalVariable<?>>(CtLocalVariable.class) {
		@Override
		public boolean matches(CtLocalVariable<?> element) {
			return element.getType() != null &&
					!element.getType().isPrimitive() &&
					element.getType().getDeclaration() != null;
		}
	});
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:11,代码来源:ObjectGenerator.java

示例3: apply

import spoon.reflect.declaration.CtMethod; //导入方法依赖的package包/类
@Override
public List<CtMethod> apply(CtMethod testMethod) {
	List<CtLiteral> literals = testMethod.getElements(literalTypeFilter);
	return literals.stream()
			.flatMap(literal ->
					this.amplify(literal).stream().map(newValue -> {
						CtMethod clone = AmplificationHelper.cloneMethodTest(testMethod, getSuffix());
						clone.getElements(literalTypeFilter).get(literals.indexOf(literal)).replace(newValue);
						return clone;
					})
			).collect(Collectors.toList());
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:13,代码来源:AbstractLiteralAmplifier.java

示例4: createTestWithLog

import spoon.reflect.declaration.CtMethod; //导入方法依赖的package包/类
static CtMethod<?> createTestWithLog(CtMethod test, final String filter) {
    CtMethod clone = AmplificationHelper.cloneMethodTest(test, "");
    clone.setSimpleName(test.getSimpleName() + "_withlog");
    final List<CtStatement> allStatement = clone.getElements(new TypeFilter<>(CtStatement.class));
    allStatement.stream()
            .filter(statement -> isStmtToLog(filter, statement))
            .forEach(statement ->
                    addLogStmt(statement,
                            test.getSimpleName() + "__" + indexOfByRef(allStatement, statement))
            );
    return clone;
}
 
开发者ID:STAMP-project,项目名称:dspot,代码行数:13,代码来源:AssertGeneratorHelper.java


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