private void processProjectionTypes(Set<TypeElement> elements) {
   Set<Element> visited = new HashSet<Element>();
   for (Element element : getElements(QueryProjection.class)) {
     Element parent = element.getEnclosingElement();
     if (!elements.contains(parent) && !visited.contains(parent)) {
       EntityType model = elementHandler.handleProjectionType((TypeElement) parent);
       registerTypeElement(model.getFullName(), (TypeElement) parent);
       context.projectionTypes.put(model.getFullName(), model);
       visited.add(parent);
     }
   }
 }
Ejemplo n.º 2
0
  private void collectMessagesImpl(
      List<Message> collectedMessages, Set<MessageContainer> visitedSinks) {
    collectedMessages.addAll(getMessages());
    for (MessageContainer sink : findChildContainers()) {
      if (visitedSinks.contains(sink)) {
        return;
      }

      visitedSinks.add(sink);
      sink.collectMessagesImpl(collectedMessages, visitedSinks);
    }
  }
Ejemplo n.º 3
0
  private void emitMessagesImpl(
      TypeElement baseElement, Log log, Set<MessageContainer> visitedSinks) {
    for (Message message : getMessages()) {
      emitDefault(baseElement, log, message);
    }

    for (MessageContainer sink : findChildContainers()) {
      if (visitedSinks.contains(sink)) {
        continue;
      }

      visitedSinks.add(sink);
      sink.emitMessagesImpl(baseElement, log, visitedSinks);
    }
  }
Ejemplo n.º 4
0
  private boolean hasErrorsImpl(Set<MessageContainer> visitedSinks) {
    for (Message msg : getMessages()) {
      if (msg.getKind() == Kind.ERROR) {
        return true;
      }
    }
    for (MessageContainer sink : findChildContainers()) {
      if (visitedSinks.contains(sink)) {
        return false;
      }

      visitedSinks.add(sink);

      if (sink.hasErrorsImpl(visitedSinks)) {
        return true;
      }
    }
    return false;
  }
  protected Set<TypeElement> collectElements() {
    Set<TypeElement> elements = new HashSet<TypeElement>();

    // from delegate methods
    elements.addAll(processDelegateMethods());

    // from class annotations
    for (Class<? extends Annotation> annotation : conf.getEntityAnnotations()) {
      for (Element element : getElements(annotation)) {
        if (element instanceof TypeElement) {
          elements.add((TypeElement) element);
        }
      }
    }

    // from package annotations
    if (conf.getEntitiesAnnotation() != null) {
      for (Element element : getElements(conf.getEntitiesAnnotation())) {
        AnnotationMirror mirror =
            TypeUtils.getAnnotationMirrorOfType(element, conf.getEntitiesAnnotation());
        elements.addAll(TypeUtils.getAnnotationValuesAsElements(mirror, "value"));
      }
    }

    // from embedded annotations
    if (conf.getEmbeddedAnnotation() != null) {
      elements.addAll(getEmbeddedTypes());
    }

    // from embedded
    if (conf.isUnknownAsEmbedded()) {
      elements.addAll(getTypeFromProperties(elements));
    }

    // from annotation less supertypes
    elements.addAll(getAnnotationlessSupertypes(elements));

    // register possible embedded types of non-tracked supertypes
    if (conf.getEmbeddedAnnotation() != null) {
      Class<? extends Annotation> embedded = conf.getEmbeddedAnnotation();
      Set<TypeElement> embeddedElements = new HashSet<TypeElement>();
      for (TypeElement element : elements) {
        TypeMirror superTypeMirror = element.getSuperclass();
        while (superTypeMirror != null) {
          TypeElement superTypeElement =
              (TypeElement) processingEnv.getTypeUtils().asElement(superTypeMirror);
          if (superTypeElement != null) {
            List<? extends Element> enclosed = superTypeElement.getEnclosedElements();
            for (Element child : enclosed) {
              if (child.getAnnotation(embedded) != null) {
                handleEmbeddedType(child, embeddedElements);
              }
            }
            superTypeMirror = superTypeElement.getSuperclass();
            if (superTypeMirror instanceof NoType) {
              superTypeMirror = null;
            }
          } else {
            superTypeMirror = null;
          }
        }
      }

      // register found elements
      for (TypeElement element : embeddedElements) {
        if (!elements.contains(element)) {
          elementHandler.handleEntityType(element);
        }
      }
    }

    return elements;
  }