Exemplo n.º 1
0
 /**
  * We don't include nested types because structural changes of nested types should not affect
  * Xtend classes which use top level types.
  *
  * @deprecated This method is not used anymore.
  */
 @Deprecated
 protected void traverseType(IType type, NameBasedEObjectDescriptionBuilder acceptor) {
   try {
     if (type.exists()) {
       for (IField field : type.getFields()) {
         if (!Flags.isSynthetic(field.getFlags())) {
           String fieldName = field.getElementName();
           acceptor.accept(fieldName);
         }
       }
       for (IMethod method : type.getMethods()) {
         if (!Flags.isSynthetic(method.getFlags())) {
           String methodName = method.getElementName();
           acceptor.accept(methodName);
         }
       }
     }
   } catch (JavaModelException e) {
     if (LOGGER.isDebugEnabled()) LOGGER.debug(e, e);
   }
 }
  private void extractIType(IType type) {
    try {
      String fqn = type.getFullyQualifiedName();

      // Write the entity
      if (type.isClass()) {
        entityWriter.writeClass(fqn, type.getFlags(), path);

        // Write the superclass
        String superSig = type.getSuperclassTypeSignature();
        if (superSig != null) {
          relationWriter.writeExtends(fqn, typeSignatureToFqn(superSig), path);
        }
      } else if (type.isAnnotation()) {
        entityWriter.writeAnnotation(fqn, type.getFlags(), path);
      } else if (type.isInterface()) {
        entityWriter.writeInterface(fqn, type.getFlags(), path);
      } else if (type.isEnum()) {
        entityWriter.writeEnum(fqn, type.getFlags(), path);
      }

      // Write the superinterfaces
      for (String superIntSig : type.getSuperInterfaceTypeSignatures()) {
        relationWriter.writeImplements(fqn, typeSignatureToFqn(superIntSig), path);
      }

      if (!fqnStack.isEmpty()) {
        relationWriter.writeInside(type.getFullyQualifiedName(), fqnStack.peek(), path);
      }

      fqnStack.push(type.getFullyQualifiedName());

      for (IType child : type.getTypes()) {
        extractIType(child);
      }

      for (IField field : type.getFields()) {
        if (!Flags.isSynthetic(field.getFlags())) {
          extractIField(field);
        }
      }

      for (IMethod method : type.getMethods()) {
        if (!Flags.isSynthetic(method.getFlags())
            || (Flags.isSynthetic(method.getFlags())
                && method.isConstructor()
                && method.getParameterTypes().length == 0)) {
          extractIMethod(method, type.isAnnotation());
        }
      }

      int pos = 0;
      for (ITypeParameter param : type.getTypeParameters()) {
        relationWriter.writeParametrizedBy(fqn, getTypeParam(param), pos++, path);
      }

      fqnStack.pop();
    } catch (Exception e) {
      logger.log(Level.SEVERE, "Error in extracting class file", e);
    }
  }