private void annotateMethod(ExecutableElement methodElt, AnnotatedExecutableType methodType) { if (checker.isChecking() || methodType.isAnnotated()) { return; } // First annotate the receiver annotateThis(methodType.getReceiverType()); // If it is from library if (checker.isFromLibrary(methodElt)) { Set<AnnotationMirror> set = AnnotationUtils.createAnnotationSet(); set.add(checker.PEER); annotateConstants(methodType, set); } // methodType.isAnnotated() only checks the annotations on methodType, // but not the type of its receiver, parameters or return; if (!methodType.isAnnotated()) methodType.addAnnotation(checker.BOTTOM); }
@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; }
private void annotateThis(AnnotatedTypeMirror type) { if (checker.isChecking()) return; type.clearAnnotations(); type.addAnnotation(checker.SELF); }