本文整理汇总了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;
}
示例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;
}
});
}
示例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());
}
示例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;
}