コード例 #1
0
  private boolean addCollectedAnnotations(
      List<AnnotationNode> collected, AnnotationNode aliasNode, AnnotatedNode origin) {
    ClassNode classNode = aliasNode.getClassNode();
    boolean ret = false;
    for (AnnotationNode annotation : classNode.getAnnotations()) {
      if (annotation.getClassNode().getName().equals(AnnotationCollector.class.getName())) {
        Expression processorExp = annotation.getMember("processor");
        AnnotationCollectorTransform act = null;
        assertStringConstant(processorExp);
        if (processorExp != null) {
          String className = (String) ((ConstantExpression) processorExp).getValue();
          Class klass = loadTransformClass(className, aliasNode);
          if (klass != null) {
            try {
              act = (AnnotationCollectorTransform) klass.newInstance();
            } catch (InstantiationException e) {
              source.getErrorCollector().addErrorAndContinue(new ExceptionMessage(e, true, source));
            } catch (IllegalAccessException e) {
              source.getErrorCollector().addErrorAndContinue(new ExceptionMessage(e, true, source));
            }
          }
        } else {
          act = new AnnotationCollectorTransform();
        }
        if (act != null) {
          // GRECLIPSE edit
          // collected.addAll(act.visit(annotation, aliasNode, origin, source));
          // original annotation added to metadata to prevent import organizer from deleting its
          // import
          List<AnnotationNode> visitResult = act.visit(annotation, aliasNode, origin, source);
          for (AnnotationNode annotationNode : visitResult) {
            Set<AnnotationNode> aliases = annotationNode.getNodeMetaData("AnnotationCollector");
            if (aliases == null)
              annotationNode.setNodeMetaData("AnnotationCollector", (aliases = new HashSet(1)));

            aliases.add(aliasNode);
          }
          collected.addAll(visitResult);
          // GRECLIPSE end
        }
        ret = true;
      }
    }
    return ret;
  }