protected int diffAnnotatedType(JCAnnotatedType oldT, JCAnnotatedType newT, int[] bounds) { int localPointer = bounds[0]; if (!listsMatch(oldT.annotations, newT.annotations)) { int pos = oldT.annotations.nonEmpty() ? getOldPos(oldT.annotations.head) : bounds[0]; copyTo(localPointer, pos); localPointer = diffParameterList( oldT.annotations, newT.annotations, null, null, pos, Measure.ARGUMENT, true, //TODO: should read the code style configuration false, false, "" ); } int[] underlyingBounds = getBounds(oldT.underlyingType); copyTo(localPointer, underlyingBounds[0]); localPointer = diffTree(oldT.underlyingType, newT.underlyingType, underlyingBounds); copyTo(localPointer, bounds[1]); return bounds[1]; }
@Override public Pair<ASTRecord, Integer> visitNewClass(NewClassTree node, Insertion ins) { JCNewClass na = (JCNewClass) node; JCExpression className = na.clazz; // System.out.printf("classname %s (%s)%n", className, className.getClass()); while (! (className.getKind() == Tree.Kind.IDENTIFIER)) { // IdentifierTree if (className instanceof JCAnnotatedType) { className = ((JCAnnotatedType) className).underlyingType; } else if (className instanceof JCTypeApply) { className = ((JCTypeApply) className).clazz; } else if (className instanceof JCFieldAccess) { // This occurs for fully qualified names, e.g. "new java.lang.Object()". // I'm not quite sure why the field "selected" is taken, but "name" would // be a type mismatch. It seems to work, see NewPackage test case. className = ((JCFieldAccess) className).selected; } else { throw new Error(String.format("unrecognized JCNewClass.clazz (%s): %s%n" + " surrounding new class tree: %s%n", className.getClass(), className, node)); } // System.out.printf("classname %s (%s)%n", className, className.getClass()); } return visitIdentifier((IdentifierTree) className, ins); }
/** * Gets the symbol for a tree. Returns null if this tree does not have a symbol because it is of * the wrong type, if {@code tree} is null, or if the symbol cannot be found due to a compilation * error. */ // TODO(eaftan): refactor other code that accesses symbols to use this method public static Symbol getSymbol(Tree tree) { if (tree instanceof JCFieldAccess) { return ((JCFieldAccess) tree).sym; } if (tree instanceof JCIdent) { return ((JCIdent) tree).sym; } if (tree instanceof JCMethodInvocation) { return ASTHelpers.getSymbol((MethodInvocationTree) tree); } if (tree instanceof JCNewClass) { return ASTHelpers.getSymbol((NewClassTree) tree); } if (tree instanceof MemberReferenceTree) { return ((JCMemberReference) tree).sym; } if (tree instanceof JCAnnotatedType) { return getSymbol(((JCAnnotatedType) tree).underlyingType); } return getDeclaredSymbol(tree); }
@Override public JCAnnotatedType inline(Inliner inliner) throws CouldNotResolveImportException { return inliner .maker() .AnnotatedType( List.convert(JCAnnotation.class, inliner.inlineList(getAnnotations())), getUnderlyingType().inline(inliner)); }
private boolean matchAnnotatedType(JCAnnotatedType t1, JCAnnotatedType t2) { return treesMatch(t1.underlyingType, t2.underlyingType) && listsMatch(t1.annotations, t2.annotations); }
private boolean isAnnotatedArray(JCTree tree) { return tree.hasTag(ANNOTATED_TYPE) && ((JCAnnotatedType)tree).underlyingType.hasTag(TYPEARRAY); }
public final static List<? extends AnnotationMirror> annotationsFromTree(AnnotatedTypeTree node) { return annotationsFromTypeAnnotationTrees(((JCAnnotatedType)node).annotations); }
public static final List<? extends AnnotationMirror> annotationsFromTree( AnnotatedTypeTree node) { return annotationsFromTypeAnnotationTrees(((JCAnnotatedType) node).annotations); }