Java Code Examples for spoon.reflect.code.CtInvocation#getArguments()
The following examples show how to use
spoon.reflect.code.CtInvocation#getArguments() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractCodeAnalyzer.java From coming with MIT License | 6 votes |
public CtInvocation checkInvocationWithParemetrCompatibleType(List<CtInvocation> invocationsFromClass, CtTypeReference type) { for (CtInvocation anInvocation : invocationsFromClass) { for (Object anObjArgument : anInvocation.getArguments()) { CtExpression anArgument = (CtExpression) anObjArgument; if (compareTypes(type, anArgument.getType())) { return anInvocation; } } } return null; }
Example 2
Source File: UnwrapfromMethodCallOp.java From astor with GNU General Public License v2.0 | 6 votes |
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.checkIsSubtype(argument.getType(), invocation.getType())) { CtExpression clonedExpressionArgument = argument.clone(); MutationSupporter.clearPosition(clonedExpressionArgument); Ingredient newIngredient = new Ingredient(clonedExpressionArgument); result.add(invocation, newIngredient); } } } return result; }
Example 3
Source File: TransformStrategy.java From astor with GNU General Public License v2.0 | 6 votes |
@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); } } }
Example 4
Source File: VariableAnalyzer.java From coming with MIT License | 4 votes |
/** * * @param varsAffected * @param element * @param context */ private void analyzeV4(List<CtVariableAccess> varsAffected, CtElement element, Cntx<Object> context) { try { for (CtVariableAccess varInFaulty : varsAffected) { CtInvocation parentInvocation = varInFaulty.getParent(CtInvocation.class); int appearsInParams = 0; MapCounter<CtElement> parameterFound = new MapCounter<>(); if (parentInvocation != null) { List<CtElement> arguments = parentInvocation.getArguments(); for (CtElement i_Argument : arguments) { List<CtVariableAccess> varsAccessInParameter = VariableResolver.collectVariableRead(i_Argument); // .stream().filter(e -> e.getRoleInParent().equals(CtRole.PARAMETER)) // .collect(Collectors.toList()); if (varsAccessInParameter.contains(varInFaulty)) { appearsInParams++; if (!parameterFound.containsKey(varInFaulty)) { writeGroupedInfo(context, adjustIdentifyInJson(varInFaulty), CodeFeatures.V4_FIRST_TIME_USED_AS_PARAMETER, true, "FEATURES_VARS"); } else { writeGroupedInfo(context, adjustIdentifyInJson(varInFaulty), CodeFeatures.V4_FIRST_TIME_USED_AS_PARAMETER, false, "FEATURES_VARS"); } parameterFound.add(varInFaulty); } if(appearsInParams > 1) break; } } writeGroupedInfo(context, adjustIdentifyInJson(varInFaulty), CodeFeatures.V4B_USED_MULTIPLE_AS_PARAMETER, (appearsInParams > 1), "FEATURES_VARS"); } } catch (Throwable e) { e.printStackTrace(); } }
Example 5
Source File: MethodAnalyzer.java From coming with MIT License | 4 votes |
private void analyzeVarMethodArgumentPrimitiveM13 (List<CtInvocation> invocationsaffected, Cntx<Object> context) { try { for (CtInvocation invAffected : invocationsaffected) { boolean M13ArgumentHasPrimitive = false; List<CtExpression> invocationArguments = invAffected.getArguments(); for(int index=0; index<invocationArguments.size(); index++ ) { CtExpression certainexpression=invocationArguments.get(index); if (certainexpression.getType()!=null && (certainexpression.getType().isPrimitive() || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("string") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("list") || certainexpression.getType().getQualifiedName().toString().toLowerCase().indexOf("string")!=-1 || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("long") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("boolean") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("double") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("byte")|| certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("short")|| certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("float") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("chart") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("character") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("integer")|| certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("string[]") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("long[]") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("boolean[]") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("double[]") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("byte[]")|| certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("short[]")|| certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("float[]") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("chart[]") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("character[]") || certainexpression.getType().getQualifiedName().toString().toLowerCase().endsWith("integer[]") || certainexpression.getType().getQualifiedName().toString().toLowerCase().startsWith("java.util.") || certainexpression.getType().getQualifiedName().toString().toLowerCase().startsWith("java.nio.") || certainexpression.getType().getQualifiedName().toString().toLowerCase().startsWith("java.io."))) { M13ArgumentHasPrimitive = true; break; } } writeGroupedInfo(context, adjustIdentifyInJson(invAffected), CodeFeatures.M13_Argument_Has_Primitive, M13ArgumentHasPrimitive, "FEATURES_METHODS"); } } catch (Throwable e) { e.printStackTrace(); } }