protected void removeInvocationArgument(CtInvocation<?> invocation) { invocation.removeArgument(invocation.getArguments().get(this.parameterIndex)); }
private void checkInvocation(CtInvocation<?> invocation) { final CtExpression<?> toBeRemovedExpression = invocation.getArguments().get(this.parameterIndex); if (canRemoveExpression(toBeRemovedExpression) == false) { createExpressionCannotBeRemovedIssue(invocation, toBeRemovedExpression); } }
/** * Actually invokes from a compile-time invocation (by using runtime * reflection). */ @SuppressWarnings("unchecked") public static <T> T invoke(CtInvocation<T> i) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Object target = i.getTarget() == null ? null : ((CtLiteral<?>) i.getTarget()).getValue(); List<Object> args = new ArrayList<>(); for (CtExpression<?> e : i.getArguments()) { args.add(((CtLiteral<?>) e).getValue()); } Class<?> c = i.getExecutable().getDeclaringType().getActualClass(); ArrayList<Class<?>> argTypes = new ArrayList<>(); for (CtTypeReference<?> type : i.getExecutable().getActualTypeArguments()) { argTypes.add(type.getActualClass()); } return (T) c.getMethod(i.getExecutable().getSimpleName(), argTypes.toArray(new Class[0])) .invoke(target, args.toArray()); }
public <T> void visitCtInvocation(final spoon.reflect.code.CtInvocation<T> invocation) { spoon.reflect.code.CtInvocation other = ((spoon.reflect.code.CtInvocation) (this.stack.peek())); enter(invocation); biScan(spoon.reflect.path.CtRole.ANNOTATION, invocation.getAnnotations(), other.getAnnotations()); biScan(spoon.reflect.path.CtRole.CAST, invocation.getTypeCasts(), other.getTypeCasts()); biScan(spoon.reflect.path.CtRole.TARGET, invocation.getTarget(), other.getTarget()); biScan(spoon.reflect.path.CtRole.EXECUTABLE_REF, invocation.getExecutable(), other.getExecutable()); biScan(spoon.reflect.path.CtRole.ARGUMENT, invocation.getArguments(), other.getArguments()); biScan(spoon.reflect.path.CtRole.COMMENT, invocation.getComments(), other.getComments()); exit(invocation); }
@Override public void visitCtInvocation(CtInvocation invocation) { this.scan(invocation.getTypeCasts()); this.scan(invocation.getExecutable()); if (!this.isImportedInMethodImports(invocation.getExecutable())) { this.scan(invocation.getTarget()); } this.scan(invocation.getArguments()); }
public <T> void visitCtInvocation(final CtInvocation<T> invocation) { enter(invocation); scan(CtRole.ANNOTATION, invocation.getAnnotations()); scan(CtRole.CAST, invocation.getTypeCasts()); scan(CtRole.TARGET, invocation.getTarget()); scan(CtRole.EXECUTABLE_REF, invocation.getExecutable()); scan(CtRole.ARGUMENT, invocation.getArguments()); scan(CtRole.COMMENT, invocation.getComments()); exit(invocation); }
@java.lang.Override public <T> void visitCtInvocation(final spoon.reflect.code.CtInvocation<T> invocation) { replaceInListIfExist(invocation.getAnnotations(), new spoon.support.visitor.replace.ReplacementVisitor.CtElementAnnotationsReplaceListener(invocation)); replaceInListIfExist(invocation.getTypeCasts(), new spoon.support.visitor.replace.ReplacementVisitor.CtExpressionTypeCastsReplaceListener(invocation)); replaceElementIfExist(invocation.getTarget(), new spoon.support.visitor.replace.ReplacementVisitor.CtTargetedExpressionTargetReplaceListener(invocation)); replaceElementIfExist(invocation.getExecutable(), new spoon.support.visitor.replace.ReplacementVisitor.CtAbstractInvocationExecutableReplaceListener(invocation)); replaceInListIfExist(invocation.getArguments(), new spoon.support.visitor.replace.ReplacementVisitor.CtAbstractInvocationArgumentsReplaceListener(invocation)); replaceInListIfExist(invocation.getComments(), new spoon.support.visitor.replace.ReplacementVisitor.CtElementCommentsReplaceListener(invocation)); }
@Override public <T> void visitCtInvocation(CtInvocation<T> invocation) { for (CtExpression<?> argument : invocation.getArguments()) { scan(argument); } }
public <T> void visitCtInvocation(final spoon.reflect.code.CtInvocation<T> invocation) { spoon.reflect.code.CtInvocation<T> aCtInvocation = invocation.getFactory().Core().createInvocation(); this.builder.copy(invocation, aCtInvocation); aCtInvocation.setAnnotations(this.cloneHelper.clone(invocation.getAnnotations())); aCtInvocation.setTypeCasts(this.cloneHelper.clone(invocation.getTypeCasts())); aCtInvocation.setTarget(this.cloneHelper.clone(invocation.getTarget())); aCtInvocation.setExecutable(this.cloneHelper.clone(invocation.getExecutable())); aCtInvocation.setArguments(this.cloneHelper.clone(invocation.getArguments())); aCtInvocation.setComments(this.cloneHelper.clone(invocation.getComments())); this.cloneHelper.tailor(invocation, aCtInvocation); this.other = aCtInvocation; }
constant = false; for (CtExpression<?> e : invocation.getArguments()) { CtExpression<?> re = evaluate(e); if (!(re instanceof CtLiteral)) {
@Override public <T> void visitCtInvocation(CtInvocation<T> invocation) { super.visitCtInvocation(invocation); List<CtExpression<?>> argumentlist = invocation.getArguments(); for (int i = 0; i < argumentlist.size(); i++) { @SuppressWarnings("rawtypes") CtExpression p = argumentlist.get(i); if (candidates.containsKey(p)) { argumentlist.set(i, candidates.get(p)); // invocation.setArguments(argumentlist); saveSketchAndSynthesize(); argumentlist.set(i, p); resoreDiskFile(); // invocation.setArguments(argumentlist); } } }
public <T> void visitCtInvocation(CtInvocation<T> invocation) { write("("); scan(invocation.getExecutable()); write("("); for (int i = 0; i < invocation.getArguments().size(); i++) { CtExpression<?> arg_i = invocation.getArguments().get(i); scan(arg_i); if (i != (invocation.getArguments().size() - 1)) { write(","); } } write(")"); write(")"); }
private static boolean isGetter(CtInvocation invocation) { return invocation.getArguments().isEmpty() && MethodsHandler.isASupportedMethodName(invocation.getExecutable().getSimpleName()); }
elementPrinterHelper.printList(invocation.getArguments(), null, false, "(", false, false, ",", true, false, ")", e -> scan(e));
/** * Actually invokes from a compile-time invocation (by using runtime * reflection). */ @SuppressWarnings("unchecked") public static <T> T invoke(CtInvocation<T> i) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Object target = i.getTarget() == null ? null : ((CtLiteral<?>) i.getTarget()).getValue(); List<Object> args = new ArrayList<Object>(); for (CtExpression<?> e : i.getArguments()) { args.add(((CtLiteral<?>) e).getValue()); } Class<?> c = i.getExecutable().getDeclaringType().getActualClass(); ArrayList<Class<?>> argTypes = new ArrayList<Class<?>>(); for (CtTypeReference<?> type : i.getExecutable().getActualTypeArguments()) { argTypes.add(type.getActualClass()); } return (T) c.getMethod(i.getExecutable().getSimpleName(), argTypes.toArray(new Class[argTypes.size()])) .invoke(target, args.toArray()); }
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; }
@Override public <T> void visitCtInvocation(CtInvocation<T> invocation) { enter(invocation); scan(invocation.getAnnotations()); scanReferences(invocation.getTypeCasts()); scan(invocation.getTarget()); scan(invocation.getArguments()); exit(invocation); }
/** * replace assertNotNull * * @param ctInvocation * @return */ private CtStatement replaceAssertNotNull(CtInvocation<?> ctInvocation) { List<?> arguments = ctInvocation.getArguments(); CtIf newIf = ctInvocation.getFactory().Core().createIf(); Object elem1 = arguments.get(0); CtExpression<Boolean> condition = ctInvocation.getFactory().Code() .createCodeSnippetExpression("(" + elem1 + ") != null"); newIf.setCondition(condition); // newIf.setThenStatement(getFactory().Code().createCodeSnippetStatement( // Debug.class.getCanonicalName() + ".printPC(\"Path Condition: \")")); /* * CtBlock<Object> thenStatement = ctInvocation.getFactory().Core() * .createBlock(); thenStatement .addStatement((getFactory().Code() * .createCodeSnippetStatement("System.out.println(\"Then...\")"))); * thenStatement.addStatement((getFactory().Code() * .createCodeSnippetStatement("System.out.println(" + * Debug.class.getCanonicalName() + ".getSolvedPC())"))); * newIf.setThenStatement(thenStatement); */ newIf.setThenStatement(createThen(ctInvocation)); return newIf; }
@SuppressWarnings({ "rawtypes", "unchecked" }) private void fetchLibOverload(CtInvocation call) { List<String> origTypes = resolveTypes(call.getArguments()); CtExpression exp = call.getTarget(); String typename=exp.getType().getQualifiedName(); if(typename==null||typename.isEmpty()) return; CtClass classname = parser.getClassMap().get(typename); if(classname!=null) { Set<CtMethod> overloadmethods=classname.getMethods(); for(CtMethod methodoverloaded : overloadmethods) { if(call.getExecutable().getSimpleName().equals(methodoverloaded.getSimpleName())) { List<CtParameter> paramlist=methodoverloaded.getParameters(); List<String> target=resolveParams(paramlist); transformOneMethod(origTypes,target, call); } } } else { List<Class[]> params = parser.fetchMethods(typename, call.getExecutable().getSimpleName()); for (Class[] p : params) transformOneConstructor(origTypes, call, p); } }
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); }