for (JCAnnotation a : tree.getModifiers().annotations) { if (a.annotationType.type.tsym == syms.overrideType.tsym) { pos = a.pos(); break;
for (JCAnnotation a : tree.getModifiers().annotations) { if (a.annotationType.type.tsym == syms.overrideType.tsym) { pos = a.pos(); break;
public void checkFunctionalInterface(JCClassDecl tree, ClassSymbol cs) { Compound functionalType = cs.attribute(syms.functionalInterfaceType.tsym); if (functionalType != null) { try { types.findDescriptorSymbol((TypeSymbol)cs); } catch (Types.FunctionDescriptorLookupError ex) { DiagnosticPosition pos = tree.pos(); for (JCAnnotation a : tree.getModifiers().annotations) { if (a.annotationType.type.tsym == syms.functionalInterfaceType.tsym) { pos = a.pos(); break; } } log.error(pos, "bad.functional.intf.anno.1", ex.getDiagnostic()); } } } }
public void checkFunctionalInterface(JCClassDecl tree, ClassSymbol cs) { Compound functionalType = cs.attribute(syms.functionalInterfaceType.tsym); if (functionalType != null) { try { types.findDescriptorSymbol((TypeSymbol)cs); } catch (Types.FunctionDescriptorLookupError ex) { DiagnosticPosition pos = tree.pos(); for (JCAnnotation a : tree.getModifiers().annotations) { if (a.annotationType.type.tsym == syms.functionalInterfaceType.tsym) { pos = a.pos(); break; } } log.error(pos, "bad.functional.intf.anno.1", ex.getDiagnostic()); } } } }
/** Check an annotation of a symbol. */ private void validateAnnotation(JCAnnotation a, Symbol s) { validateAnnotationTree(a); if (!annotationApplicable(a, s)) log.error(a.pos(), "annotation.type.not.applicable"); if (a.annotationType.type.tsym == syms.functionalInterfaceType.tsym) { if (s.kind != TYP) { log.error(a.pos(), "bad.functional.intf.anno"); } else if (!s.isInterface() || (s.flags() & ANNOTATION) != 0) { log.error(a.pos(), "bad.functional.intf.anno.1", diags.fragment("not.a.functional.intf", s)); } } }
/** Check an annotation of a symbol. */ private void validateAnnotation(JCAnnotation a, Symbol s) { validateAnnotationTree(a); if (!annotationApplicable(a, s)) log.error(a.pos(), "annotation.type.not.applicable"); if (a.annotationType.type.tsym == syms.functionalInterfaceType.tsym) { if (s.kind != TYP) { log.error(a.pos(), "bad.functional.intf.anno"); } else if (!s.isInterface() || (s.flags() & ANNOTATION) != 0) { log.error(a.pos(), "bad.functional.intf.anno.1", diags.fragment("not.a.functional.intf", s)); } } }
private void checkForDeclarationAnnotations(List<? extends JCAnnotation> annotations, Symbol sym) { // Ensure that no declaration annotations are present. // Note that a tree type might be an AnnotatedType with // empty annotations, if only declaration annotations were given. // This method will raise an error for such a type. for (JCAnnotation ai : annotations) { if (!ai.type.isErroneous() && typeAnnotations.annotationType(ai.attribute, sym) == TypeAnnotations.AnnotationType.DECLARATION) { log.error(ai.pos(), "annotation.type.not.applicable"); } } } };
private void checkForDeclarationAnnotations(List<? extends JCAnnotation> annotations, Symbol sym) { // Ensure that no declaration annotations are present. // Note that a tree type might be an AnnotatedType with // empty annotations, if only declaration annotations were given. // This method will raise an error for such a type. for (JCAnnotation ai : annotations) { if (!ai.type.isErroneous() && typeAnnotations.annotationType(ai.attribute, sym) == TypeAnnotations.AnnotationType.DECLARATION) { log.error(ai.pos(), "annotation.type.not.applicable"); } } } };
public void visitAnnotation(JCAnnotation tree) { log.error(tree.pos(), "annotation.not.valid.for.type", pt); result = tree.type = syms.errType; }
public void visitAnnotation(JCAnnotation tree) { log.error(tree.pos(), "annotation.not.valid.for.type", pt); result = tree.type = syms.errType; }
public void validateTypeAnnotation(JCAnnotation a, boolean isTypeParameter) { Assert.checkNonNull(a.type, "annotation tree hasn't been attributed yet: " + a); validateAnnotationTree(a); if (a.hasTag(TYPE_ANNOTATION) && !a.annotationType.type.isErroneous() && !isTypeAnnotation(a, isTypeParameter)) { log.error(a.pos(), "annotation.type.not.applicable"); } }
/** Check an annotation of a symbol. */ public void validateAnnotation(JCAnnotation a, Symbol s) { validateAnnotation(a); if (!annotationApplicable(a, s)) log.error(a.pos(), "annotation.type.not.applicable"); if (a.annotationType.type.tsym == syms.overrideType.tsym) { if (!isOverrider(s)) log.error(a.pos(), "method.does.not.override.superclass"); } }
/** get a diagnostic position for an attribute of Type t, or null if attribute missing */ private DiagnosticPosition getDiagnosticPosition(JCClassDecl tree, Type t) { for(List<JCAnnotation> al = tree.mods.annotations; !al.isEmpty(); al = al.tail) { if (types.isSameType(al.head.annotationType.type, t)) return al.head.pos(); } return null; }
/** Check an annotation of a symbol. */ public void validateAnnotation(JCAnnotation a, Symbol s) { validateAnnotation(a); if (!annotationApplicable(a, s)) log.error(a.pos(), "annotation.type.not.applicable"); if (a.annotationType.type.tsym == syms.overrideType.tsym) { if (!isOverrider(s)) log.error(a.pos(), "method.does.not.override.superclass"); } }
public void validateTypeAnnotation(JCAnnotation a, boolean isTypeParameter) { Assert.checkNonNull(a.type, "annotation tree hasn't been attributed yet: " + a); validateAnnotationTree(a); if (a.hasTag(TYPE_ANNOTATION) && !a.annotationType.type.isErroneous() && !isTypeAnnotation(a, isTypeParameter)) { log.error(a.pos(), "annotation.type.not.applicable"); } }
/** get a diagnostic position for an attribute of Type t, or null if attribute missing */ private DiagnosticPosition getDiagnosticPosition(JCClassDecl tree, Type t) { for(List<JCAnnotation> al = tree.mods.annotations; !al.isEmpty(); al = al.tail) { if (types.isSameType(al.head.annotationType.type, t)) return al.head.pos(); } return null; }