public static Flow flowsForPassedArguments(List<Integer> argumentIndices, MethodInvocationTree mit) { String methodName = mit.symbol().name(); Flow.Builder flowBuilder = Flow.builder(); argumentIndices.stream() .map(index -> getArgumentIdentifier(mit, index)) .filter(Objects::nonNull) .map(identifierTree -> new JavaFileScannerContext.Location(String.format("'%s' is passed to '%s()'.", identifierTree.name(), methodName), identifierTree)) .forEach(flowBuilder::add); return flowBuilder.build().reverse(); }
public static Flow flowsForPassedArguments(List<Integer> argumentIndices, MethodInvocationTree mit) { String methodName = mit.symbol().name(); Flow.Builder flowBuilder = Flow.builder(); argumentIndices.stream() .map(index -> getArgumentIdentifier(mit, index)) .filter(Objects::nonNull) .map(identifierTree -> new JavaFileScannerContext.Location(String.format("'%s' is passed to '%s()'.", identifierTree.name(), methodName), identifierTree)) .forEach(flowBuilder::add); return flowBuilder.build().reverse(); }
public static Flow flowsForArgumentsChangingName(List<Integer> argumentIndices, MethodInvocationTree mit) { JavaSymbol.MethodJavaSymbol methodSymbol = (JavaSymbol.MethodJavaSymbol) mit.symbol(); MethodTree declaration = methodSymbol.declaration(); if (declaration == null) { return Flow.empty(); } Flow.Builder flowBuilder = Flow.builder(); List<VariableTree> methodParameters = declaration.parameters(); for (Integer argumentIndex : argumentIndices) { // do not consider varargs part if (methodSymbol.isVarArgs() && argumentIndex >= methodParameters.size() - 1) { break; } IdentifierTree argumentName = getArgumentIdentifier(mit, argumentIndex); if (argumentName != null) { IdentifierTree parameterIdentifier = methodParameters.get(argumentIndex).simpleName(); String identifierName = parameterIdentifier.name(); if (!argumentName.name().equals(identifierName)) { flowBuilder.add(new JavaFileScannerContext.Location(String.format(IMPLIES_SAME_VALUE, identifierName, argumentName.name()), parameterIdentifier)); } } } return flowBuilder.build().reverse(); }
public static Flow flowsForArgumentsChangingName(List<Integer> argumentIndices, MethodInvocationTree mit) { JavaSymbol.MethodJavaSymbol methodSymbol = (JavaSymbol.MethodJavaSymbol) mit.symbol(); MethodTree declaration = methodSymbol.declaration(); if (declaration == null) { return Flow.empty(); } Flow.Builder flowBuilder = Flow.builder(); List<VariableTree> methodParameters = declaration.parameters(); for (Integer argumentIndex : argumentIndices) { // do not consider varargs part if (methodSymbol.isVarArgs() && argumentIndex >= methodParameters.size() - 1) { break; } IdentifierTree argumentName = getArgumentIdentifier(mit, argumentIndex); if (argumentName != null) { IdentifierTree parameterIdentifier = methodParameters.get(argumentIndex).simpleName(); String identifierName = parameterIdentifier.name(); if (!argumentName.name().equals(identifierName)) { flowBuilder.add(new JavaFileScannerContext.Location(String.format(IMPLIES_SAME_VALUE, identifierName, argumentName.name()), parameterIdentifier)); } } } return flowBuilder.build().reverse(); }
IdentifierTree identifierTree = FlowComputation.getArgumentIdentifier(mit, parameterCausingExceptionIndex); if (identifierTree != null) { methodInvocationMessage = new JavaFileScannerContext.Location(String.format("'%s' is passed to '%s()'.", identifierTree.name(), methodName), identifierTree);
IdentifierTree identifierTree = FlowComputation.getArgumentIdentifier(mit, parameterCausingExceptionIndex); if (identifierTree != null) { methodInvocationMessage = new JavaFileScannerContext.Location(String.format("'%s' is passed to '%s()'.", identifierTree.name(), methodName), identifierTree);