com.sun.source.tree.ParameterizedTypeTree Java Examples

The following examples show how to use com.sun.source.tree.ParameterizedTypeTree. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElementOverlay.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private String fqnFor(Tree t) {
    Element el = ASTService.getElementImpl(t);

    if (el != null) {
        if (el.getKind().isClass() || el.getKind().isInterface() || el.getKind() == ElementKind.PACKAGE) {
            return ((QualifiedNameable) el).getQualifiedName().toString();
        } else {
            Logger.getLogger(ElementOverlay.class.getName()).log(Level.SEVERE, "Not a QualifiedNameable: {0}", el);
            return null;
        }
    } else if (t instanceof QualIdentTree) {
        return ((QualIdentTree) t).getFQN();
    } else if (t.getKind() == Kind.PARAMETERIZED_TYPE) {
        return fqnFor(((ParameterizedTypeTree) t).getType());
    } else {
        Logger.getLogger(ElementOverlay.class.getName()).log(Level.FINE, "No element and no QualIdent");
        return null;
    }
}
 
Example #2
Source File: ApplicationSubclassGenerator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private ClassTree createMethodsOlderVersion(Collection<String> classNames,
        TreeMaker maker,ClassTree modified,
        CompilationController controller) throws IOException
{
    WildcardTree wildCard = maker.Wildcard(Tree.Kind.UNBOUNDED_WILDCARD,
            null);
    ParameterizedTypeTree wildClass = maker.ParameterizedType(
            maker.QualIdent(Class.class.getCanonicalName()),
            Collections.singletonList(wildCard));
    ParameterizedTypeTree wildSet = maker.ParameterizedType(
            maker.QualIdent(Set.class.getCanonicalName()),
            Collections.singletonList(wildClass));
    //StringBuilder builder = new StringBuilder();
    String methodBody = MiscPrivateUtilities.collectRestResources(classNames, restSupport, true);
    ModifiersTree modifiersTree = maker.Modifiers(EnumSet
            .of(Modifier.PRIVATE));
    MethodTree methodTree = maker.Method(modifiersTree,
            GET_REST_RESOURCE_CLASSES, wildSet,
            Collections.<TypeParameterTree> emptyList(),
            Collections.<VariableTree> emptyList(),
            Collections.<ExpressionTree> emptyList(), methodBody,
            null);
    modified = maker.addClassMember(modified, methodTree);
    return modified;
}
 
Example #3
Source File: ConvertToDiamondBulkHint.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void performRewrite(TransformationContext ctx) {
    WorkingCopy copy = ctx.getWorkingCopy();
    TreePath tp = ctx.getPath();
    if (tp.getLeaf().getKind() != Tree.Kind.NEW_CLASS) {
        //XXX: warning
        return ;
    }

    NewClassTree nct = (NewClassTree) tp.getLeaf();

    if (nct.getIdentifier().getKind() != Tree.Kind.PARAMETERIZED_TYPE) {
        //XXX: warning
        return ;
    }

    TreeMaker make = copy.getTreeMaker();
    ParameterizedTypeTree ptt = (ParameterizedTypeTree) nct.getIdentifier();
    ParameterizedTypeTree nue = make.ParameterizedType(ptt.getType(), Collections.<Tree>emptyList());

    copy.rewrite(ptt, nue);
}
 
Example #4
Source File: ApplicationSubclassGenerator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private ClassTree createMethods(Collection<String> classNames, MethodTree getClasses,
        TreeMaker maker, ClassTree modified,
        CompilationController controller) throws IOException
{
    WildcardTree wildCard = maker.Wildcard(Tree.Kind.UNBOUNDED_WILDCARD,
            null);
    ParameterizedTypeTree wildClass = maker.ParameterizedType(
            maker.QualIdent(Class.class.getCanonicalName()),
            Collections.singletonList(wildCard));
    ParameterizedTypeTree wildSet = maker.ParameterizedType(
            maker.QualIdent(Set.class.getCanonicalName()),
            Collections.singletonList(wildClass));

    String methodBody = MiscPrivateUtilities.collectRestResources(classNames, restSupport, false);
    
    return MiscUtilities.createAddResourceClasses(maker, modified, controller, methodBody, false);
}
 
Example #5
Source File: ComputeImports.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void filterByKind(Tree toFilter, Set<ElementKind> acceptedKinds, Set<ElementKind> notAcceptedKinds) {
    if (toFilter == null) return;
    switch (toFilter.getKind()) {
        case IDENTIFIER:
            hints.add(new KindHint(((IdentifierTree) toFilter).getName().toString(), acceptedKinds, notAcceptedKinds));
            break;
        case PARAMETERIZED_TYPE:
            filterByKind(((ParameterizedTypeTree) toFilter).getType(), acceptedKinds, notAcceptedKinds);
            break;
    }
}
 
Example #6
Source File: TreeDiffer.java    From compile-testing with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitParameterizedType(ParameterizedTypeTree expected, Tree actual) {
  Optional<ParameterizedTypeTree> other = checkTypeAndCast(expected, actual);
  if (!other.isPresent()) {
    addTypeMismatch(expected, actual);
    return null;
  }

  scan(expected.getType(), other.get().getType());
  parallelScan(expected.getTypeArguments(), other.get().getTypeArguments());
  return null;
}
 
Example #7
Source File: TreeTypeInternal.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
@Override
public String rawName() {
  if (type instanceof ParameterizedTypeTree) {
    ParameterizedTypeTree parameterizedType = (ParameterizedTypeTree) type;
    return ((TypeElement)((JCTree.JCTypeApply) parameterizedType).type.asElement()).getQualifiedName().toString();
  }
  return null;
}
 
Example #8
Source File: UTypeApply.java    From Refaster with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public Unifier visitParameterizedType(
    ParameterizedTypeTree typeApply, @Nullable Unifier unifier) {
  unifier = getType().unify(typeApply.getType(), unifier);
  return Unifier.unifyList(unifier, getTypeArguments(), typeApply.getTypeArguments());
}
 
Example #9
Source File: Translator.java    From groovy-cps with Apache License 2.0 5 votes vote down vote up
@Override
public JType visitParameterizedType(ParameterizedTypeTree pt, Void __) {
    JClass base = (JClass)visit(pt.getType());
    List<JClass> args = new ArrayList<>();
    for (Tree arg : pt.getTypeArguments()) {
        args.add((JClass)visit(arg));
    }
    return base.narrow(args);
}
 
Example #10
Source File: JavaInputAstVisitor.java    From google-java-format with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitParameterizedType(ParameterizedTypeTree node, Void unused) {
  sync(node);
  if (node.getTypeArguments().isEmpty()) {
    scan(node.getType(), null);
    token("<");
    token(">");
  } else {
    builder.open(plusFour);
    scan(node.getType(), null);
    token("<");
    builder.breakOp();
    builder.open(ZERO);
    boolean first = true;
    for (Tree typeArgument : node.getTypeArguments()) {
      if (!first) {
        token(",");
        builder.breakOp(" ");
      }
      scan(typeArgument, null);
      first = false;
    }
    builder.close();
    builder.close();
    token(">");
  }
  return null;
}
 
Example #11
Source File: ASTPathCriterion.java    From annotation-tools with MIT License 5 votes vote down vote up
private boolean checkTypePath(int i, Tree typeTree) {
        try {
loop:       while (typeTree != null && i < astPath.size()) {
                ASTPath.ASTEntry entry = astPath.get(i);
                Tree.Kind kind = entry.getTreeKind();
                switch (kind) {
                case ANNOTATED_TYPE:
                    typeTree = ((AnnotatedTypeTree) typeTree)
                        .getUnderlyingType();
                    continue;
                case ARRAY_TYPE:
                    typeTree = ((ArrayTypeTree) typeTree).getType();
                    break;
                case MEMBER_SELECT:
                    typeTree = ((MemberSelectTree) typeTree).getExpression();
                    break;
                case PARAMETERIZED_TYPE:
                    if (entry.childSelectorIs(ASTPath.TYPE_ARGUMENT)) {
                        int arg = entry.getArgument();
                        typeTree = ((ParameterizedTypeTree) typeTree)
                                .getTypeArguments().get(arg);
                    } else {  // TYPE
                        typeTree = ((ParameterizedTypeTree) typeTree).getType();
                    }
                    break;
                default:
                    if (isWildcard(kind)) {
                        return ++i == astPath.size();  // ???
                    }
                    break loop;
                }
                ++i;
            }
        } catch (RuntimeException ex) {}
        return false;
    }
 
Example #12
Source File: TreeFinder.java    From annotation-tools with MIT License 5 votes vote down vote up
@Override
public Pair<ASTRecord, Integer> visitParameterizedType(ParameterizedTypeTree node, Insertion ins) {
  Tree parent = parent(node);
  dbug.debug("TypePositionFinder.visitParameterizedType %s parent=%s%n",
      node, parent);
  Integer pos = getBaseTypePosition(((JCTypeApply) node).getType()).b;
  return Pair.of(astRecord(node), pos);
}
 
Example #13
Source File: JavaInputAstVisitor.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Void visitParameterizedType(ParameterizedTypeTree node, Void unused) {
    sync(node);
    if (node.getTypeArguments().isEmpty()) {
        scan(node.getType(), null);
        token("<");
        token(">");
    } else {
        builder.open(plusFour);
        scan(node.getType(), null);
        token("<");
        builder.breakOp();
        builder.open(ZERO);
        boolean first = true;
        for (Tree typeArgument : node.getTypeArguments()) {
            if (!first) {
                token(",");
                // TODO(cushon): unify breaks
                builder.breakToFill(" ");
            }
            scan(typeArgument, null);
            first = false;
        }
        builder.close();
        builder.close();
        token(">");
    }
    return null;
}
 
Example #14
Source File: MiscUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** creates addResourceClasses method
 * 
 * @param maker tree maker
 * @param classTree class tree
 * @param controller compilation controller
 * @param methodBody method body
 * @param addComment add comment or not
 * @return modified class tree
 * @throws IOException 
 */
public static ClassTree createAddResourceClasses(TreeMaker maker,
        ClassTree classTree, CompilationController controller,
        String methodBody, boolean addComment) throws IOException
{
    WildcardTree wildCard = maker.Wildcard(Tree.Kind.UNBOUNDED_WILDCARD,
            null);
    ParameterizedTypeTree wildClass = maker.ParameterizedType(
            maker.QualIdent(Class.class.getCanonicalName()),
            Collections.singletonList(wildCard));
    ParameterizedTypeTree wildSet = maker.ParameterizedType(
            maker.QualIdent(Set.class.getCanonicalName()),
            Collections.singletonList(wildClass));
    ModifiersTree modifiersTree = maker.Modifiers(EnumSet
            .of(Modifier.PRIVATE));
    VariableTree newParam = maker.Variable(
            maker.Modifiers(Collections.<Modifier>emptySet()),
            "resources", wildSet, null);
    MethodTree methodTree = maker.Method(modifiersTree,
            RestConstants.GET_REST_RESOURCE_CLASSES2, maker.Type("void"),
            Collections.<TypeParameterTree> emptyList(),
            Arrays.asList(newParam),
            Collections.<ExpressionTree> emptyList(), methodBody,
            null);
    if (addComment) {
        Comment comment = Comment.create(Comment.Style.JAVADOC,// -2, -2, -2,
                "Do not modify "+RestConstants.GET_REST_RESOURCE_CLASSES2+"() method.\n"
                + "It is automatically populated with\n"
                + "all resources defined in the project.\n"
                + "If required, comment out calling this method in getClasses()."); // NOI18N
        maker.addComment(methodTree, comment, true);
    }
    return maker.addClassMember(classTree, methodTree);
}
 
Example #15
Source File: DeptectiveTreeVisitor.java    From deptective with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitParameterizedType(ParameterizedTypeTree node, Void p) {
    node.getTypeArguments().forEach(s -> {
        checkPackageAccess(s, getQualifiedPackageName(s));
    });
    return super.visitParameterizedType(node, p);
}
 
Example #16
Source File: JavaFixUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Number visitParameterizedType(ParameterizedTypeTree node, Void p) {
    List<? extends ExpressionTree> typeArgs = (List<? extends ExpressionTree>) resolveMultiParameters(node.getTypeArguments());
    ParameterizedTypeTree nue = make.ParameterizedType(node.getType(), typeArgs);

    rewrite(node, nue);
    return super.visitParameterizedType(node, p);
}
 
Example #17
Source File: SnakeYAMLMojo.java    From helidon-build-tools with Apache License 2.0 5 votes vote down vote up
private static void addPropertyParametersIfNeeded(VariableTree node, Type type, String propName) {
    if (node.getType().getKind() == Tree.Kind.PARAMETERIZED_TYPE) {
        ParameterizedTypeTree pTree = (ParameterizedTypeTree) node.getType();

        List<String> parameterTypeNames = pTree.getTypeArguments().stream()
                .filter(argTree -> argTree.getKind() == Tree.Kind.IDENTIFIER)
                .map(argTree -> ((IdentifierTree) argTree).getName().toString())
                .collect(Collectors.toList());
        type.propertyParameter(propName, parameterTypeNames);
    }
}
 
Example #18
Source File: JavaInputAstVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitParameterizedType(ParameterizedTypeTree node, Void unused) {
    sync(node);
    if (node.getTypeArguments().isEmpty()) {
        scan(node.getType(), null);
        token("<");
        token(">");
    } else {
        builder.open(plusFour);
        scan(node.getType(), null);
        token("<");
        builder.breakOp();
        builder.open(ZERO);
        boolean first = true;
        for (Tree typeArgument : node.getTypeArguments()) {
            if (!first) {
                token(",");
                // TODO(cushon): unify breaks
                builder.breakToFill(" ");
            }
            scan(typeArgument, null);
            first = false;
        }
        builder.close();
        builder.close();
        token(">");
    }
    return null;
}
 
Example #19
Source File: DeptectiveTreeVisitor.java    From deptective with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitParameterizedType(ParameterizedTypeTree node, Void p) {
    node.getTypeArguments().forEach(s -> {
        checkPackageAccess(s, getQualifiedPackageName(s));
    });
    return super.visitParameterizedType(node, p);
}
 
Example #20
Source File: TreeDuplicator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Tree visitParameterizedType(ParameterizedTypeTree tree, Void p) {
    ParameterizedTypeTree n = make.ParameterizedType(tree.getType(), tree.getTypeArguments());
    model.setType(n, model.getType(tree));
    comments.copyComments(tree, n);
    model.setPos(n, model.getPos(tree));
    return n;
}
 
Example #21
Source File: CopyFinder.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Boolean visitParameterizedType(ParameterizedTypeTree node, TreePath p) {
    if (p == null)
        return super.visitParameterizedType(node, p);

    ParameterizedTypeTree t = (ParameterizedTypeTree) p.getLeaf();

    if (!scan(node.getType(), t.getType(), p))
        return false;

    return checkLists(node.getTypeArguments(), t.getTypeArguments(), p);
}
 
Example #22
Source File: CreateElementUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static List<? extends TypeMirror> computeNewClass(Set<ElementKind> types, CompilationInfo info, TreePath parent, Tree error, int offset) {
    NewClassTree nct = (NewClassTree) parent.getLeaf();
    boolean errorInRealArguments = false;
    
    for (Tree param : nct.getArguments()) {
        errorInRealArguments |= param == error;
    }
    
    if (errorInRealArguments) {
        List<TypeMirror> proposedTypes = new ArrayList<TypeMirror>();
        int[] proposedIndex = new int[1];
        List<ExecutableElement> ee = fuzzyResolveMethodInvocation(info, parent, proposedTypes, proposedIndex);
        
        if (ee.isEmpty()) { //cannot be resolved
            return null;
        }
        
        types.add(ElementKind.PARAMETER);
        types.add(ElementKind.LOCAL_VARIABLE);
        types.add(ElementKind.FIELD);
        
        return proposedTypes;
    }

    Tree id = nct.getIdentifier();

    if (id.getKind() == Kind.PARAMETERIZED_TYPE) {
        id = ((ParameterizedTypeTree) id).getType();
    }

    if (id == error) {
        return resolveType(EnumSet.noneOf(ElementKind.class), info, parent.getParentPath(), nct, offset, null, null);
    }
    
    return null;
}
 
Example #23
Source File: BreadCrumbsNodeImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static String simpleName(Tree t) {
    switch (t.getKind()) {
        case PARAMETERIZED_TYPE:
            return simpleName(((ParameterizedTypeTree) t).getType());
        case IDENTIFIER:
            return ((IdentifierTree) t).getName().toString();
        case MEMBER_SELECT:
            return ((MemberSelectTree) t).getIdentifier().toString();
        default:
            return "";//XXX
    }
}
 
Example #24
Source File: TreeNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitParameterizedType(ParameterizedTypeTree tree, List<Node> d) {
    List<Node> below = new ArrayList<Node>();
    
    addCorrespondingElement(below);
    addCorrespondingType(below);
    addCorrespondingComments(below);
    
    super.visitParameterizedType(tree, below);
    
    d.add(new TreeNode(info, getCurrentPath(), below));
    return null;
}
 
Example #25
Source File: CreateElementUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static List<? extends TypeMirror> computeNewClass(Set<ElementKind> types, CompilationInfo info, TreePath parent, Tree error, int offset) {
    NewClassTree nct = (NewClassTree) parent.getLeaf();
    boolean errorInRealArguments = false;
    
    for (Tree param : nct.getArguments()) {
        errorInRealArguments |= param == error;
    }
    
    if (errorInRealArguments) {
        List<TypeMirror> proposedTypes = new ArrayList<TypeMirror>();
        int[] proposedIndex = new int[1];
        List<ExecutableElement> ee = org.netbeans.modules.editor.java.Utilities.fuzzyResolveMethodInvocation(info, parent, proposedTypes, proposedIndex);
        
        if (ee.isEmpty()) { //cannot be resolved
            return null;
        }
        
        types.add(ElementKind.PARAMETER);
        types.add(ElementKind.LOCAL_VARIABLE);
        types.add(ElementKind.FIELD);
        
        return proposedTypes;
    }

    Tree id = nct.getIdentifier();

    if (id.getKind() == Kind.PARAMETERIZED_TYPE) {
        id = ((ParameterizedTypeTree) id).getType();
    }

    if (id == error) {
        return resolveType(EnumSet.noneOf(ElementKind.class), info, parent.getParentPath(), nct, offset, null, null);
    }
    
    return null;
}
 
Example #26
Source File: Flow.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Boolean visitParameterizedType(ParameterizedTypeTree node, ConstructorData p) {
    super.visitParameterizedType(node, p);
    return null;
}
 
Example #27
Source File: RestUtils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static FileObject createApplicationConfigClass(final RestSupport restSupport, FileObject packageFolder,
        String name ) throws IOException
{   
    FileObject appClass = GenerationUtils.createClass(packageFolder,name, null );
    JavaSource javaSource = JavaSource.forFileObject(appClass);
    if ( javaSource == null ){
        return null;
    }        
    javaSource.runModificationTask( new Task<WorkingCopy>(){

        @Override
        public void run(WorkingCopy workingCopy) throws Exception {
            workingCopy.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
            JavaSourceHelper.addClassAnnotation(workingCopy, 
                    new String[]{"javax.ws.rs.ApplicationPath"}, 
                    new String[]{"webresources"});         // NOI18N
            ClassTree tree = JavaSourceHelper.getTopLevelClassTree(workingCopy);
            TreeMaker maker = workingCopy.getTreeMaker();
            ClassTree newTree = maker.setExtends(tree, 
                    maker.QualIdent(JAX_RS_APPLICATION_CLASS)); // NOI18N
            
            ModifiersTree modifiersTree = maker.Modifiers(
                    EnumSet.of(Modifier.PUBLIC), Collections.singletonList(
                            maker.Annotation( maker.QualIdent(
                                    Override.class.getCanonicalName()),
                                    Collections.<ExpressionTree>emptyList())));
            
            WildcardTree wildCard = maker.Wildcard(Tree.Kind.UNBOUNDED_WILDCARD,
                    null);
            ParameterizedTypeTree wildClass = maker.ParameterizedType(
                    maker.QualIdent(Class.class.getCanonicalName()),
                    Collections.singletonList(wildCard));
            ParameterizedTypeTree wildSet = maker.ParameterizedType(
            maker.QualIdent(Set.class.getCanonicalName()),
            Collections.singletonList(wildClass));
            
            MethodTree methodTree = maker.Method(modifiersTree,
                    RestConstants.GET_CLASSES, wildSet,
                    Collections.<TypeParameterTree>emptyList(),
                    Collections.<VariableTree>emptyList(),
                    Collections.<ExpressionTree>emptyList(),
                    MiscUtilities.createBodyForGetClassesMethod(restSupport), null);
            newTree = maker.addClassMember(newTree, methodTree);
            
            newTree = MiscUtilities.createAddResourceClasses(maker, newTree, workingCopy, "{}", true);
            
            workingCopy.rewrite( tree, newTree);
        }
        
    }).commit();
    return appClass;
}
 
Example #28
Source File: Utilities.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private String simpleName(Tree t) {
    if (t == null) {
        return Bundle.DisplayName_Unknown();
    }
    if (t.getKind() == Kind.IDENTIFIER) {
        return ((IdentifierTree) t).getName().toString();
    }

    if (t.getKind() == Kind.MEMBER_SELECT) {
        return ((MemberSelectTree) t).getIdentifier().toString();
    }

    if (t.getKind() == Kind.METHOD_INVOCATION) {
        return scan(t, null);
    }

    if (t.getKind() == Kind.PARAMETERIZED_TYPE) {
        return simpleName(((ParameterizedTypeTree) t).getType()) + "<...>"; // NOI18N
    }

    if (t.getKind() == Kind.ARRAY_ACCESS) {
        return simpleName(((ArrayAccessTree) t).getExpression()) + "[]"; //NOI18N
    }

    if (t.getKind() == Kind.PARENTHESIZED) {
        return "(" + simpleName(((ParenthesizedTree)t).getExpression()) + ")"; //NOI18N
    }

    if (t.getKind() == Kind.TYPE_CAST) {
        return simpleName(((TypeCastTree)t).getType());
    }

    if (t.getKind() == Kind.ARRAY_TYPE) {
        return simpleName(((ArrayTypeTree)t).getType());
    }

    if (t.getKind() == Kind.PRIMITIVE_TYPE) {
        return ((PrimitiveTypeTree) t).getPrimitiveTypeKind().name().toLowerCase();
    }
    
    throw new IllegalStateException("Currently unsupported kind of tree: " + t.getKind()); // NOI18N
}
 
Example #29
Source File: ExpressionScanner.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public List<Tree> visitParameterizedType(ParameterizedTypeTree node, ExpressionScanner.ExpressionsInfo p) {
    return null;
}
 
Example #30
Source File: TreeConverter.java    From j2objc with Apache License 2.0 4 votes vote down vote up
private TreeNode convertTypeApply(ParameterizedTypeTree node, TreePath parent) {
  TypeMirror typeMirror = getTypeMirror(getTreePath(parent, node));
  return new ParameterizedType().setType(Type.newType(typeMirror)).setTypeMirror(typeMirror);
}