Package javax.lang.model.element

Examples of javax.lang.model.element.Element


    }
    if (updateAnnotated.size() > 1) {
      messager.printMessage(Kind.ERROR, "Only one @Update hook is allowed with the project", updateAnnotated.iterator().next());
      return null;
    }
    Element updateElement = updateAnnotated.iterator().next();
    TypeElement typeElement = updateElement.accept(new TypeResolvingVisitor(), null);
    boolean implementsDbUpdate = false;
    for (TypeMirror typeMirror : typeElement.getInterfaces()) {
      if (typeMirror.toString().equals(DbUpdate.class.getCanonicalName())) {
        implementsDbUpdate = true;
      }
View Full Code Here


      tableObject.setIsChildTable(true);
    }

    for (TableObject tableObject : tableObjectCache.values()) {
      logger.d("Writing for " + tableObject.getTableName());
      Element element = tableObject.getOriginatingElement();
      try {
        JavaFileObject jfo = filer.createSourceFile(tableObject.getFqcn(), element);
        Writer writer = jfo.openWriter();
        tableObject.brewJava(writer);
        writer.flush();
View Full Code Here

  private void checkForFields(TableObject tableObject, Element columnElement) {
    Field fieldAnnotation = columnElement.getAnnotation(Field.class);
    if (fieldAnnotation == null) return;

    /* Convert the element from a field to a type */
    final Element typeElement = typeUtils.asElement(columnElement.asType());
    final String type = typeElement == null ? columnElement.asType().toString()
        : elementUtils.getBinaryName((TypeElement) typeElement).toString();

    TableColumn tableColumn = new TableColumn(columnElement, type);
    if (tableColumn.isBlob() && !tableColumn.isByteArray()) {
      if (!checkForSuperType(columnElement, Serializable.class)
          && !columnElement.asType().toString().equals("java.lang.Byte[]")) {
        logger.e(String.format(
            "%s in %s is not Serializable and will not be able to be converted to a byte array",
            columnElement.toString(), tableObject.getTableName()));
      }
    } else if (tableColumn.isOneToMany()) {
      // List<T> should only have one generic type. Get that type and make sure
      // it has @Table annotation
      TypeMirror typeMirror = ((DeclaredType) columnElement.asType()).getTypeArguments().get(0);
      if (typeUtils.asElement(typeMirror).getAnnotation(Table.class) == null) {
        logger.e("One to many relationship in class %s where %s is not annotated with @Table",
            tableObject.getTableName(), tableColumn.getColumnName());
      }
      oneToManyCache.put(typeMirror.toString(), tableObject);
      TypeElement childColumnElement = elementUtils.getTypeElement(typeMirror.toString());
      tableColumn.setType(getClassName(childColumnElement, getPackageName(childColumnElement)));
    } else if (tableColumn.getSqlType() == SqliteType.UNKNOWN) {
      @SuppressWarnings("ConstantConditions")
      Table annotation = typeElement.getAnnotation(Table.class);
      if (annotation == null) {
        logger.e(String.format("%s in %s needs to be marked as a blob or should be "
            + "annotated with @Table", columnElement.toString(), tableObject.getTableName()));
      }
      tableColumn.setOneToOne(true);
View Full Code Here

        @Override
         public Set<TypeElement> scan(Element e, Set<TypeElement> p) {
            for (AnnotationMirror annotationMirror :
                     elements.getAllAnnotationMirrors(e) ) {
                Element e2 = annotationMirror.getAnnotationType().asElement();
                p.add((TypeElement) e2);
            }
            return super.scan(e, p);
        }
View Full Code Here


public class Main {

    public static PackageElement getPackage(TypeElement type) {
        Element owner = type;
        while (owner.getKind() != ElementKind.PACKAGE)
            owner = owner.getEnclosingElement();
        return (PackageElement)owner;
    }
View Full Code Here

        return getDeclaredTypeName(comp, false);
      }
      mirror = box ? box(mirror) : mirror;
      if (isPrimitive(mirror))
        return ((PrimitiveType)mirror).toString();
      Element elem = typeUtility.asElement(mirror);
      if (elem == null)
          throw new RuntimeException(_loc.get("mmg-no-type", mirror).getMessage());
        return elem.toString();
    }
View Full Code Here

  private String getBinaryName(TypeElement element) {
    return getBinaryNameImpl(element, element.getSimpleName().toString());
  }

  private String getBinaryNameImpl(TypeElement element, String className) {
    Element enclosingElement = element.getEnclosingElement();

    if (enclosingElement instanceof PackageElement) {
      PackageElement pkg = (PackageElement) enclosingElement;
      if (pkg.isUnnamed()) {
        return className;
View Full Code Here

  }

  // Utility methods for this test.

  private TypeMirror extractReturnTypeFromHolder(TypeElement typeElement) {
    Element element = Iterables.getOnlyElement(typeElement.getEnclosedElements());
    TypeMirror arrayType = MoreElements.asExecutable(element).getReturnType();
    return arrayType;
  }
View Full Code Here

  }

  public static TypeElement asTypeElement(Types types, TypeMirror mirror) {
    checkNotNull(types);
    checkNotNull(mirror);
    Element element = types.asElement(mirror);
    checkArgument(element != null);
    return element.accept(new SimpleElementVisitor6<TypeElement, Void>() {
      @Override
      protected TypeElement defaultAction(Element e, Void p) {
        throw new IllegalArgumentException();
      }
View Full Code Here

   * Returns the name of the package that the given type is in. If the type is in the default
   * (unnamed) package then the name is the empty string.
   */
  static String packageNameOf(TypeElement type) {
    while (true) {
      Element enclosing = type.getEnclosingElement();
      if (enclosing instanceof PackageElement) {
        return ((PackageElement) enclosing).getQualifiedName().toString();
      }
      type = (TypeElement) enclosing;
    }
View Full Code Here

TOP

Related Classes of javax.lang.model.element.Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.