Search in sources :

Example 6 with ParameterizedTypeTree

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

the class TypeAndReferenceSolver method resolveIdentifierType.

private JavaType resolveIdentifierType(Resolve.Env newClassEnv, @Nullable ExpressionTree enclosingExpression, TypeTree typeTree, String typeName) {
    if (enclosingExpression != null) {
        resolveAs(enclosingExpression, JavaSymbol.VAR);
        Resolution idType = resolve.findIdentInType(newClassEnv, (JavaSymbol.TypeJavaSymbol) enclosingExpression.symbolType().symbol(), typeName, JavaSymbol.TYP);
        JavaType type = idType.type();
        if (typeTree.is(Tree.Kind.PARAMETERIZED_TYPE)) {
            TypeArguments typeArguments = ((ParameterizedTypeTree) typeTree).typeArguments();
            scan(typeArguments);
            type = parametrizedTypeWithTypeArguments(type.symbol, typeArguments);
        }
        registerType(typeTree, type);
    } else {
        resolveAs(typeTree, JavaSymbol.TYP, newClassEnv, false);
    }
    return (JavaType) typeTree.symbolType();
}
Also used : ParameterizedTypeTree(org.sonar.plugins.java.api.tree.ParameterizedTypeTree) TypeArguments(org.sonar.plugins.java.api.tree.TypeArguments) Resolution(org.sonar.java.resolve.Resolve.Resolution)

Aggregations

ParameterizedTypeTree (org.sonar.plugins.java.api.tree.ParameterizedTypeTree)6 Test (org.junit.Test)3 TypeArguments (org.sonar.plugins.java.api.tree.TypeArguments)3 ArrayTypeTree (org.sonar.plugins.java.api.tree.ArrayTypeTree)2 MemberSelectExpressionTree (org.sonar.plugins.java.api.tree.MemberSelectExpressionTree)2 NewClassTree (org.sonar.plugins.java.api.tree.NewClassTree)2 TypeTree (org.sonar.plugins.java.api.tree.TypeTree)2 VariableTree (org.sonar.plugins.java.api.tree.VariableTree)2 Resolution (org.sonar.java.resolve.Resolve.Resolution)1 AnnotationTree (org.sonar.plugins.java.api.tree.AnnotationTree)1 ClassTree (org.sonar.plugins.java.api.tree.ClassTree)1 IdentifierTree (org.sonar.plugins.java.api.tree.IdentifierTree)1 NewArrayTree (org.sonar.plugins.java.api.tree.NewArrayTree)1 PrimitiveTypeTree (org.sonar.plugins.java.api.tree.PrimitiveTypeTree)1 TypeCastTree (org.sonar.plugins.java.api.tree.TypeCastTree)1 UnionTypeTree (org.sonar.plugins.java.api.tree.UnionTypeTree)1 WildcardTree (org.sonar.plugins.java.api.tree.WildcardTree)1