Search in sources :

Example 16 with LambdaExpressionTree

use of org.sonar.plugins.java.api.tree.LambdaExpressionTree in project sonar-java by SonarSource.

the class MethodReferenceResolutionTest method method_references_type_defered_should_not_raise_npe.

@Test
public void method_references_type_defered_should_not_raise_npe() throws Exception {
    Result result = Result.createFor("MethodReferencesDeferedType");
    LambdaExpressionTree lambda = (LambdaExpressionTree) result.symbol("qualifier").declaration().parent();
    Type symbolType = ((MethodInvocationTree) lambda.body()).symbolType();
    assertThat(symbolType.is("java.util.stream.Stream")).isTrue();
    assertThat(symbolType).isInstanceOf(ParametrizedTypeJavaType.class);
    List<JavaType> substitutedTypes = ((ParametrizedTypeJavaType) symbolType).typeSubstitution.substitutedTypes();
    assertThat(substitutedTypes).hasSize(1);
    assertThat(substitutedTypes.get(0).is("Qualifier")).isTrue();
}
Also used : LambdaExpressionTree(org.sonar.plugins.java.api.tree.LambdaExpressionTree) Type(org.sonar.plugins.java.api.semantic.Type) MethodInvocationTree(org.sonar.plugins.java.api.tree.MethodInvocationTree) Test(org.junit.Test)

Aggregations

LambdaExpressionTree (org.sonar.plugins.java.api.tree.LambdaExpressionTree)16 Tree (org.sonar.plugins.java.api.tree.Tree)8 ExpressionTree (org.sonar.plugins.java.api.tree.ExpressionTree)6 VariableTree (org.sonar.plugins.java.api.tree.VariableTree)6 Test (org.junit.Test)5 IdentifierTree (org.sonar.plugins.java.api.tree.IdentifierTree)5 MemberSelectExpressionTree (org.sonar.plugins.java.api.tree.MemberSelectExpressionTree)5 MethodInvocationTree (org.sonar.plugins.java.api.tree.MethodInvocationTree)5 NewClassTree (org.sonar.plugins.java.api.tree.NewClassTree)5 Type (org.sonar.plugins.java.api.semantic.Type)4 AssignmentExpressionTree (org.sonar.plugins.java.api.tree.AssignmentExpressionTree)4 ClassTree (org.sonar.plugins.java.api.tree.ClassTree)4 ConditionalExpressionTree (org.sonar.plugins.java.api.tree.ConditionalExpressionTree)4 MethodReferenceTree (org.sonar.plugins.java.api.tree.MethodReferenceTree)4 BinaryExpressionTree (org.sonar.plugins.java.api.tree.BinaryExpressionTree)3 BlockTree (org.sonar.plugins.java.api.tree.BlockTree)3 ExpressionStatementTree (org.sonar.plugins.java.api.tree.ExpressionStatementTree)3 MethodTree (org.sonar.plugins.java.api.tree.MethodTree)3 ParenthesizedTree (org.sonar.plugins.java.api.tree.ParenthesizedTree)3 ReturnStatementTree (org.sonar.plugins.java.api.tree.ReturnStatementTree)3