Search in sources :

Example 6 with AbstractTypedTree

use of org.sonar.java.model.AbstractTypedTree in project sonar-java by SonarSource.

the class Resolve method findMethodReference.

Resolution findMethodReference(Env env, List<JavaType> samMethodArgs, MethodReferenceTree methodRefTree) {
    Tree expression = methodRefTree.expression();
    JavaType expressionType = (JavaType) ((AbstractTypedTree) expression).symbolType();
    String methodName = getMethodReferenceMethodName(methodRefTree.method().name());
    Resolution resolution = findMethod(env, expressionType, methodName, samMethodArgs);
    // JLS ยง15.13.1
    if (secondSearchRequired(expression, expressionType, resolution.symbol, samMethodArgs)) {
        resolution = findMethod(env, expressionType, methodName, samMethodArgs.stream().skip(1).collect(Collectors.toList()));
    }
    return resolution;
}
Also used : AbstractTypedTree(org.sonar.java.model.AbstractTypedTree) ConditionalExpressionTree(org.sonar.plugins.java.api.tree.ConditionalExpressionTree) Tree(org.sonar.plugins.java.api.tree.Tree) LambdaExpressionTree(org.sonar.plugins.java.api.tree.LambdaExpressionTree) MemberSelectExpressionTree(org.sonar.plugins.java.api.tree.MemberSelectExpressionTree) IdentifierTree(org.sonar.plugins.java.api.tree.IdentifierTree) MethodReferenceTree(org.sonar.plugins.java.api.tree.MethodReferenceTree)

Aggregations

AbstractTypedTree (org.sonar.java.model.AbstractTypedTree)6 IdentifierTree (org.sonar.plugins.java.api.tree.IdentifierTree)4 MemberSelectExpressionTree (org.sonar.plugins.java.api.tree.MemberSelectExpressionTree)4 ConditionalExpressionTree (org.sonar.plugins.java.api.tree.ConditionalExpressionTree)3 LambdaExpressionTree (org.sonar.plugins.java.api.tree.LambdaExpressionTree)3 LambdaExpressionTreeImpl (org.sonar.java.model.expression.LambdaExpressionTreeImpl)2 Resolution (org.sonar.java.resolve.Resolve.Resolution)2 Type (org.sonar.plugins.java.api.semantic.Type)2 AnnotationTree (org.sonar.plugins.java.api.tree.AnnotationTree)2 Arguments (org.sonar.plugins.java.api.tree.Arguments)2 ArrayAccessExpressionTree (org.sonar.plugins.java.api.tree.ArrayAccessExpressionTree)2 AssignmentExpressionTree (org.sonar.plugins.java.api.tree.AssignmentExpressionTree)2 MethodReferenceTree (org.sonar.plugins.java.api.tree.MethodReferenceTree)2 Tree (org.sonar.plugins.java.api.tree.Tree)2 VariableTree (org.sonar.plugins.java.api.tree.VariableTree)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Maps (com.google.common.collect.Maps)1 ArrayList (java.util.ArrayList)1