@Override public Void visitTypeCast(TypeCastTree node, AnnotatedTypeMirror p) { if (!p.isAnnotated()) { // check if it is casting "this" if (TreeUtils.skipParens(node.getExpression()).toString().equals("this")) { annotateThis(p); } } return super.visitTypeCast(node, p); }
@Override public AnnotatedTypeMirror getAnnotatedType(Tree tree) { AnnotatedTypeMirror type = super.getAnnotatedType(tree); if (tree instanceof ExpressionTree) tree = TreeUtils.skipParens((ExpressionTree) tree); Element elt = InternalUtils.symbol(tree); if (!checker.isChecking() /*&& !checker.isDefaultAnyType(type)*/ && type.isAnnotated() && !type.getKind().isPrimitive() && type.getKind() != TypeKind.NULL && (elt == null || !ElementUtils.isStatic(elt))) { // We don't want annotations on the following trees Kind kind = tree.getKind(); if (kind == Kind.METHOD_INVOCATION || kind == Kind.ARRAY_ACCESS || kind == Kind.MEMBER_SELECT || kind == Kind.CONDITIONAL_EXPRESSION) { type = type.getCopy(false); } } return type; }