Separate type annotations from declaration annotations and
determine the correct positions for type annotations.
This version only visits types in signatures and should be
called from MemberEnter.
500307
public void organizeTypeAnnotationsSignatures(final Env<AttrContext> env, final JCClassDecl tree) {
        annotate.afterTypes(() -> {
            JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);
            try {
                new TypeAnnotationPositions(true).scan(tree);
            } finally {
                log.useSource(oldSource);
            }
        });
    }
1299258
public static List<ExecutableElement> getSortedAnnotationMembers(TypeElement annotation) {
    List<ExecutableElement> members = Lists.newArrayList(getMethods(annotation));
    Collections.sort(members, (m1, m2) -> getName(m1).compareTo(getName(m2)));
    return members;
  }
1183634
private Type enterSyntheticAnnotation(String name) {
        ClassType type = (ClassType)enterClass(name);
        ClassSymbol sym = (ClassSymbol)type.tsym;
        sym.completer = null;
        sym.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
        sym.erasure_field = type;
        sym.members_field = new Scope(sym);
        type.typarams_field = List.nil();
        type.allparams_field = List.nil();
        type.supertype_field = annotationType;
        type.interfaces_field = List.nil();
        return type;
    }
361884
private boolean checkAnnotations(List<? extends AnnotationTree> annotations, Tree node) {
    for (AnnotationTree annotation : annotations) {
      if (isJ2ObjCIncompatible(annotation)) {
        nodesToStrip.add(node);
        return false;
      }
    }
    return true;
  }
472097
public static TypeAnnotationPosition
        methodThrows(final List<TypePathEntry> location,
                     final int type_index) {
        return methodThrows(location, null, type_index, -1);
    }
1015140
private void visitMemberDeclarator(AstNode node) {

    if (isOverriddenMethod(node)) {
      // assume that ancestor method is documented
      // and do not count as public API
      return;
    }

    AstNode container = node.getFirstAncestor(
      CxxGrammarImpl.templateDeclaration,
      CxxGrammarImpl.classSpecifier);

    AstNode docNode = node;
    List<Token> comments;

    if (container == null || container.getType().equals(CxxGrammarImpl.classSpecifier)) {
      comments = getBlockDocumentation(docNode);
    } else { // template
      do {
        comments = getBlockDocumentation(container);
        if (!comments.isEmpty()) {
          break;
        }
        container = container.getFirstAncestor(CxxGrammarImpl.templateDeclaration);
      } while (container != null);
    }

    // documentation may be inlined
    if (comments.isEmpty()) {
      comments = getDeclaratorInlineComment(node);
    }

    // find the identifier to present to concrete visitors
    String id = null;

    // first look for an operator function id
    AstNode idNode = node.getFirstDescendant(CxxGrammarImpl.operatorFunctionId);

    if (idNode != null) {
      id = getOperatorId(idNode);
    } else {
      // look for a declarator id
      idNode = node.getFirstDescendant(CxxGrammarImpl.declaratorId);

      if (idNode != null) {
        id = idNode.getTokenValue();
      } else {
        // look for an identifier (e.g in bitfield declaration)
        idNode = node.getFirstDescendant(GenericTokenType.IDENTIFIER);

        if (idNode != null) {
          id = idNode.getTokenValue();
        } else {
          LOG.error("Unsupported declarator at {}", node.getTokenLine());
        }
      }
    }

    if (idNode != null && id != null) {
      visitPublicApi(idNode, id, comments);
    }
  }
623518
public AnnotationTypeDoc[] annotationTypes() {
        ListBuffer<AnnotationTypeDocImpl> ret = new ListBuffer<>();
        for (ClassDocImpl c : getClasses(true)) {
            if (c.isAnnotationType()) {
                ret.append((AnnotationTypeDocImpl)c);
            }
        }
        return ret.toArray(new AnnotationTypeDocImpl[ret.length()]);
    }
1352601
public static Annotation detachedAnnotation(@NonNull AnnotationType type, int start, int end) {
      return new Annotation(type, start, end);
   }
1332254
function(types) {
			if (textUtil.compare(this._overviewAnnotationTypesVisible, types)) return;
			this._overviewAnnotationTypesVisible = types;
			if (!this._overviewRuler || !this._textView || !this._overviewRulerVisible) { return; }
			this._overviewRuler.setAnnotationTypeVisible(types);
			this._textView.redrawLines(0, undefined, this._overviewRuler);
		}
48719
protected void appendFunctionalInterfaceAnnotation(JvmGenericType type) {
		if (type != null && Utils.isFunctionalInterface(type, this.sarlSignatureProvider)
				&& this.annotationFinder.findAnnotation(type, FunctionalInterface.class) == null) {
			addAnnotationSafe(type, FunctionalInterface.class);
		}
	}
143758
public static TypeAnnotationPosition
        methodTypeParameterBound(final List<TypePathEntry> location,
                                 final int parameter_index,
                                 final int bound_index) {
        return methodTypeParameterBound(location, null, parameter_index,
                                        bound_index, -1);
    }
1161677
public static TypeAnnotationPosition
        methodParameter(final List<TypePathEntry> location,
                        final JCLambda onLambda,
                        final int parameter_index,
                        final int pos) {
        return new TypeAnnotationPosition(TargetType.METHOD_FORMAL_PARAMETER,
                                          pos, parameter_index, onLambda,
                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
                                          location);
    }
189620
public void check()
        throws FatalCompileTimeException
    {
        HashSet declsToCheck = new HashSet();

        //
        // First, build up the Set of declarations to check.  We don't want any duplicates.
        //
        for ( int i = 0; i < _atds.length; ++i )
        {
            AnnotationTypeDeclaration atd = _atds[i];
            Declaration[] decls = getAnnotationProcessorEnvironment().getDeclarationsAnnotatedWith( atd );
            for ( int j = 0; j < decls.length; j++ )
            {
                declsToCheck.add( decls[j] );
            }
        }

        // Now, check the declarations.
        check(declsToCheck);
    }
339488
protected void mergeTypeDeclarations(TypeDeclaration oldDeclaration,
                                       TypeDeclaration newDeclaration) {
        if (oldDeclaration == null) {
            return;
        }

        //add the missing fields (if any) to newDeclaration
        for (FieldDefinition oldFactField : oldDeclaration.getTypeClassDef().getFieldsDefinitions()) {
            FieldDefinition newFactField = newDeclaration.getTypeClassDef().getField(oldFactField.getName());
            if (newFactField == null) {
                newDeclaration.getTypeClassDef().addField(oldFactField);
            }
        }

        //copy the defined class
        newDeclaration.setTypeClass( oldDeclaration.getTypeClass() );
    }
905073
void annotation( AnnotatedDescrBuilder<?> adb ) {
        AnnotationDescrBuilder<?> annotation = null;

        try {
            if (speculateFullAnnotation()) {
                boolean buildState = exprParser.isBuildDescr();
                exprParser.setBuildDescr(true);
                exprParser.fullAnnotation(adb);
                exprParser.setBuildDescr(buildState);
            } else {

                // '@'
                Token at = match(input,
                        DRL6Lexer.AT,
                        null,
                        null,
                        DroolsEditorType.SYMBOL);
                if (state.failed)
                    return;

                // identifier
                String fqn = qualifiedIdentifier();
                if (state.failed)
                    return;

                if (state.backtracking == 0) {
                    annotation = adb.newAnnotation(fqn);
                    helper.setStart(annotation,
                            at);
                }

                try {
                    if (input.LA(1) == DRL6Lexer.LEFT_PAREN) {
                        String value = chunk(DRL6Lexer.LEFT_PAREN,
                                DRL6Lexer.RIGHT_PAREN,
                                -1).trim();
                        if (state.failed)
                            return;
                        if (state.backtracking == 0) {
                            annotation.value(value);
                        }
                    }
                } finally {
                    if (state.backtracking == 0) {
                        helper.setEnd(annotation);
                    }
                }
            }

        } catch (RecognitionException re) {
            reportError(re);
        }
    }
168125
private static List<TypeMirror> getAnnotationClassValues(Element member, Annotation annotation, String annotationMemberName) {
        for (AnnotationMirror annotationMirror : member.getAnnotationMirrors()) {
            if (((TypeElement) annotationMirror.getAnnotationType().asElement()).getQualifiedName().contentEquals(annotation.annotationType().getName())) {
                for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotationMirror.getElementValues().entrySet()) {
                    if (entry.getKey().getSimpleName().contentEquals(annotationMemberName)) {
                        @SuppressWarnings({ "unchecked", "rawtypes" })
                        List<AnnotationValue> types = (List) entry.getValue().getValue();
                        TypeMirror[] result = new TypeMirror[types.size()];
                        for (int i = 0; i < types.size(); i++) {
                            result[i] = (TypeMirror) types.get(i).getValue();
                        }
                        return Arrays.asList(result);
                    }
                }
                return Collections.emptyList();
            }
        }

        throw new IllegalStateException(annotation.annotationType().getName() + " not found in " + member);
    }
1018533
public void markTypeNode(Node typeNode, int lineno, int startCharno,
      int endLineno, int endCharno, boolean hasLC) {
    if (currentMarker != null) {
      JSDocInfo.TypePosition position = new JSDocInfo.TypePosition();
      position.setItem(typeNode);
      position.setHasBrackets(hasLC);
      position.setPositionInformation(lineno, startCharno,
          endLineno, endCharno);
      currentMarker.setType(position);
    }
  }