static boolean isCorrectReturn(CtInvocation<?> invocation) { return invocation.getType() != null && !(isVoidReturn(invocation)) && !(invocation.getType() instanceof CtWildcardReference) && invocation.getType().getTypeDeclaration() != null && !("java.lang.Class".equals(invocation.getType().getTypeDeclaration().getQualifiedName())); }
if (executable != null && aType != null && invocation.getType() != null && execDeclaringType != null && execDeclaringType.isSubtypeOf(aType.getReference())) { CtBlock<?> b = evaluate(executable.getBody());
public <T> void visitCtInvocation(CtInvocation<T> invocation) { enter(invocation); scan(invocation.getAnnotations()); scan(invocation.getType()); scanReferences(invocation.getTypeCasts()); scan(invocation.getTarget()); scan(invocation.getExecutable()); scan(invocation.getArguments()); exit(invocation); }
invocations.stream() .filter(invocation -> !(invocation.getType() instanceof CtWildcardReference) && !TypeUtils.isPrimitive(invocation.getType()) && !TypeUtils.isString(invocation.getType()) ).forEach(invocation -> { List<CtMethod<?>> methodsWithTargetType = AmplifierHelper.findMethodsWithTargetType(invocation.getType()); if (!methodsWithTargetType.isEmpty()) { int indexOfInvocation = getIndexOf(testMethod, invocation); CtLocalVariable localVar = testMethod.getFactory().Code().createLocalVariable( invocation.getType(), "__DSPOT_invoc_" + indexOfInvocation, invocation.clone());
@SuppressWarnings("rawtypes") private List<InvocationPlaceholder> generate(CtAbstractInvocation ctAbstractInvocation, T originalStatement) { List<InvocationPlaceholder> tosGenerated = new ArrayList<>(); // We collect all variables List<CtAbstractInvocation> invocations = InvocationResolver.collectInvocation(originalStatement, true); int nrmethod = 0; for (int i = 0; i < invocations.size(); i++) { CtAbstractInvocation invocation_i = invocations.get(i); if (invocation_i instanceof CtInvocation) { if (ctAbstractInvocation.equals(invocation_i)) { CtInvocation cinvocationToModify = (CtInvocation) invocation_i; if (cinvocationToModify.getTarget() == null) { //log.debug("\nTarget null " + ctAbstractInvocation); continue; } String newName = String.format(PATTERN, cinvocationToModify.getTarget().getType().getQualifiedName(), cinvocationToModify.getType().getQualifiedName(), nrmethod++); InvocationPlaceholder tf = new InvocationPlaceholder(newName, cinvocationToModify, cinvocationToModify.getTarget().getType(), cinvocationToModify.getType()); tosGenerated.add(tf); break; } } } return tosGenerated; }
private MapList<CtInvocation, Ingredient> retrieveMethodHasCompatibleParameterAndReturnSameMethod( CtElement suspiciousElement) { MapList<CtInvocation, Ingredient> result = new MapList<CtInvocation, Ingredient>(); List<CtInvocation> invocations = suspiciousElement.getElements(e -> (e instanceof CtInvocation)).stream() .map(CtInvocation.class::cast).collect(Collectors.toList()); for (CtInvocation invocation : invocations) { for (Object oparameter : invocation.getArguments()) { CtExpression argument = (CtExpression) oparameter; if (SupportOperators.compareTypes(invocation.getType(), argument.getType())) { CtExpression clonedExpressionArgument = argument.clone(); MutationSupporter.clearPosition(clonedExpressionArgument); Ingredient newIngredient = new Ingredient(clonedExpressionArgument); result.add(invocation, newIngredient); } } } return result; }
CtInvocation invocationToBeReplaced = (CtInvocation) statementToBeAsserted.clone(); final CtLocalVariable localVariable = factory.createLocalVariable( invocationToBeReplaced.getType(), "o_" + id.split("___")[0], invocationToBeReplaced ); statementToBeAsserted.replace(localVariable);
CtTypeReference returnTypeOfInvocation = invocationToReplace.getType();
public <T> void visitCtInvocation(CtInvocation<T> invocation) { CtInvocation<T> i = invocation.getFactory().Core().createInvocation(); i.setType(invocation.getType()); i.setExecutable(invocation.getExecutable()); boolean constant = true; if ((executable != null) && (invocation.getType() != null) && invocation.getExecutable().getDeclaringType() .isAssignableFrom(((CtType<?>) invocation.getParent(CtType.class)).getReference())) { CtBlock<?> b = evaluate(invocation.getParent(), executable.getBody());
insertAfter = invocation; } else { final CtLocalVariable localVariable = stmt.getFactory().createLocalVariable(invocation.getType(), "o_" + id, invocation.clone()); try {