public MethodUsage solveMethodAsUsage(MethodCallExpr call) { List<ResolvedType> params = new ArrayList<>(); if (call.getArguments() != null) { for (Expression param : call.getArguments()) { //getTypeConcrete(Node node, boolean solveLambdas) try { params.add(getType(param, false)); } catch (Exception e) { throw new RuntimeException(String.format("Error calculating the type of parameter %s of method call %s", param, call), e); } //params.add(getTypeConcrete(param, false)); } } Context context = JavaParserFactory.getContext(call, typeSolver); Optional<MethodUsage> methodUsage = context.solveMethodAsUsage(call.getName().getId(), params); if (!methodUsage.isPresent()) { throw new RuntimeException("Method '" + call.getName() + "' cannot be resolved in context " + call + " (line: " + call.getRange().map(r -> "" + r.begin.line).orElse("??") + ") " + context + ". Parameter types: " + params); } return methodUsage.get(); }
public MethodUsage solveMethodAsUsage(MethodCallExpr call) { List<ResolvedType> params = new ArrayList<>(); if (call.getArguments() != null) { for (Expression param : call.getArguments()) { //getTypeConcrete(Node node, boolean solveLambdas) try { params.add(getType(param, false)); } catch (Exception e) { throw new RuntimeException(String.format("Error calculating the type of parameter %s of method call %s", param, call), e); } //params.add(getTypeConcrete(param, false)); } } Context context = JavaParserFactory.getContext(call, typeSolver); Optional<MethodUsage> methodUsage = context.solveMethodAsUsage(call.getName().getId(), params, typeSolver); if (!methodUsage.isPresent()) { throw new RuntimeException("Method '" + call.getName() + "' cannot be resolved in context " + call + " (line: " + call.getRange().get().begin.line + ") " + context + ". Parameter types: " + params); } return methodUsage.get(); }
public MethodUsage solveMethodAsUsage(MethodCallExpr call) { List<ResolvedType> params = new ArrayList<>(); if (call.getArguments() != null) { for (Expression param : call.getArguments()) { //getTypeConcrete(Node node, boolean solveLambdas) try { params.add(getType(param, false)); } catch (Exception e) { throw new RuntimeException(String.format("Error calculating the type of parameter %s of method call %s", param, call), e); } //params.add(getTypeConcrete(param, false)); } } Context context = JavaParserFactory.getContext(call, typeSolver); Optional<MethodUsage> methodUsage = context.solveMethodAsUsage(call.getName().getId(), params, typeSolver); if (!methodUsage.isPresent()) { throw new RuntimeException("Method '" + call.getName() + "' cannot be resolved in context " + call + " (line: " + call.getRange().get().begin.line + ") " + context + ". Parameter types: " + params); } return methodUsage.get(); }