Skip to content

Commit

Permalink
JavaParserFacade: in solve(MethodCallExpr,boolean) rename params into…
Browse files Browse the repository at this point in the history
… argumentTypes
  • Loading branch information
ftomassetti committed Oct 19, 2016
1 parent d6a1f32 commit 4da014a
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -122,25 +122,25 @@ public SymbolReference<MethodDeclaration> solve(MethodCallExpr methodCallExpr) {
* Given a method call find out to which method declaration it corresponds. * Given a method call find out to which method declaration it corresponds.
*/ */
public SymbolReference<MethodDeclaration> solve(MethodCallExpr methodCallExpr, boolean solveLambdas) { public SymbolReference<MethodDeclaration> solve(MethodCallExpr methodCallExpr, boolean solveLambdas) {
List<Type> params = new LinkedList<>(); List<Type> argumentTypes = new LinkedList<>();
List<LambdaArgumentTypePlaceholder> placeholders = new LinkedList<>(); List<LambdaArgumentTypePlaceholder> placeholders = new LinkedList<>();
int i = 0; int i = 0;
for (Expression parameterValue : methodCallExpr.getArgs()) { for (Expression parameterValue : methodCallExpr.getArgs()) {
if (parameterValue instanceof LambdaExpr || parameterValue instanceof MethodReferenceExpr) { if (parameterValue instanceof LambdaExpr || parameterValue instanceof MethodReferenceExpr) {
LambdaArgumentTypePlaceholder placeholder = new LambdaArgumentTypePlaceholder(i); LambdaArgumentTypePlaceholder placeholder = new LambdaArgumentTypePlaceholder(i);
params.add(placeholder); argumentTypes.add(placeholder);
placeholders.add(placeholder); placeholders.add(placeholder);
} else { } else {
try { try {
params.add(JavaParserFacade.get(typeSolver).getType(parameterValue, solveLambdas)); argumentTypes.add(JavaParserFacade.get(typeSolver).getType(parameterValue, solveLambdas));
} catch (Exception e){ } catch (Exception e){
throw new RuntimeException(String.format("Unable to calculate the type of a parameter of a method call. Method call: %s, Parameter: %s", throw new RuntimeException(String.format("Unable to calculate the type of a parameter of a method call. Method call: %s, Parameter: %s",
methodCallExpr, parameterValue), e); methodCallExpr, parameterValue), e);
} }
} }
i++; i++;
} }
SymbolReference<MethodDeclaration> res = JavaParserFactory.getContext(methodCallExpr, typeSolver).solveMethod(methodCallExpr.getName(), params, typeSolver); SymbolReference<MethodDeclaration> res = JavaParserFactory.getContext(methodCallExpr, typeSolver).solveMethod(methodCallExpr.getName(), argumentTypes, typeSolver);
for (LambdaArgumentTypePlaceholder placeholder : placeholders) { for (LambdaArgumentTypePlaceholder placeholder : placeholders) {
placeholder.setMethod(res); placeholder.setMethod(res);
} }
Expand Down

0 comments on commit 4da014a

Please sign in to comment.