Package javax.lang.model.element

Examples of javax.lang.model.element.TypeElement


    /* Construct super() call. */
    if (kind != ElementKind.ENUM) {
      TypeMirror superMirror = e.getSuperclass();
      if (superMirror.getKind() == TypeKind.DECLARED) {
        TypeElement superType =
            (TypeElement) utils.typeUtils.asElement(superMirror);
        SuperCallBuilder visitor =
            new SuperCallBuilder((DeclaredType) superMirror, type, utils);
        superType.accept(visitor, null);
      }
    }

    /* Process generic signature. */
    List<? extends TypeParameterElement> typeParams = e.getTypeParameters();
View Full Code Here


  /**
   * Visits the superclass and interfaces of the specified
   * TypeElement with a ContractExtensionBuilder.
   */
  protected void scanSuper(TypeElement e) {
    TypeElement superElement =
        (TypeElement) utils.typeUtils.asElement(e.getSuperclass());
    if (superElement != null) {
      superElement.accept(new ContractExtensionBuilder(), type);
    }
    for (TypeMirror iface : e.getInterfaces()) {
      TypeElement ifaceElement =
          (TypeElement) utils.typeUtils.asElement(iface);
      ifaceElement.accept(new ContractExtensionBuilder(), type);
    }
  }
View Full Code Here

        String metaClass = factory.getMetaModelClassName(originalClass);

        SourceCode source = new SourceCode(metaClass);
        comment(source);
        annotate(source, originalClass);
        TypeElement supCls = handler.getPersistentSupertype(e);
        if (supCls != null) {
            String superName = factory.getMetaModelClassName(supCls.toString());
            source.getTopLevelClass().setSuper(superName);
        }
        try {
            PrintWriter writer = createSourceFile(originalClass, metaClass, e);
            SourceCode.Class modelClass = source.getTopLevelClass();
View Full Code Here

    public TypeMirror ref(Class c) {
        if(c.isArray())
            return env.getTypeUtils().getArrayType( ref(c.getComponentType()) );
        if(c.isPrimitive())
            return getPrimitive(c);
        TypeElement t = env.getElementUtils().getTypeElement(getSourceClassName(c));
        // Annotation Processing only operates on a set of classes used in the compilation,
        // and it won't recognize additional classes (even if they are visible from javac)
        // and return null.
        //
        // this is causing a problem where we check if a type is collection.
View Full Code Here

    }

    @Override
    public void parse(Element element, Function<TypeElement, Type> storage) {
        final ExecutableElement method = (ExecutableElement) element;
        final TypeElement typeElement = (TypeElement) method.getEnclosingElement();
        final FirstClass annotation = method.getAnnotation(FirstClass.class);
        final ClosureName delegate = new ClosureName(method.getSimpleName().toString());;

        final ClosureName name;
       
        if (annotation.value().isEmpty()) {
            name = delegate;
        } else {
            name = new ClosureName(annotation.value());
        }
       
        final boolean isStatic = method.getModifiers().contains(Modifier.STATIC);

        final Name parameterType;

        if (isStatic) {
            final VariableElement firstParameter = method.getParameters().get(0);
            parameterType = new Name(firstParameter.asType().toString());
        } else {
            parameterType = new Name(typeElement.getQualifiedName().toString());
        }

        final Closure closure;

        if (method.getReturnType().getKind() == TypeKind.BOOLEAN) {
View Full Code Here

      Set<? extends Element> elements = roundEnv
          .getElementsAnnotatedWith(annotation);
      for (Element element : elements) {

        try {
          TypeElement typeElement = (TypeElement) element;

          String qualifiedName = typeElement.getQualifiedName().toString();
          Class<?> modelClass = Class.forName(qualifiedName);

          String code = ModelGenerator.generateJavascript(modelClass,
              outputConfig);

          Model modelAnnotation = element.getAnnotation(Model.class);
          String modelName = modelAnnotation.value();
          String fileName;
          String packageName = "";
          if (StringUtils.hasText(modelName)) {
            int lastDot = modelName.lastIndexOf('.');
            if (lastDot != -1) {
              fileName = modelName.substring(lastDot + 1);
              int firstDot = modelName.indexOf('.');
              if (firstDot < lastDot) {
                packageName = modelName.substring(firstDot + 1, lastDot);
              }
            }
            else {
              fileName = modelName;
            }
          }
          else {
            fileName = typeElement.getSimpleName().toString();
          }

          if (createBaseAndSubclass) {
            code = code.replaceFirst("(Ext.define\\([\"'].+?)([\"'],)",
                "$1Base$2");
View Full Code Here

  @Override
  public Schema read() {
    Schema schema = new Schema(persistence.dbName(), persistence.dbVersion(), updateHookClassName, createHookClassName);
    for (Element element : entities) {
      TypeElement entity = element.accept(new TypeResolvingVisitor(), null);
      TableReader tableReader = new TableReader(entity, entityNames, messager);
      Table read = tableReader.read();
      if (read != null) {
        schema.addTable(read);
      }
View Full Code Here

      messager.printMessage(Kind.ERROR,
          "Only one " + hookAnnotation.getCanonicalName() + " hook is allowed with the project", annotated.iterator().next());
      return null;
    }
    Element updateElement = annotated.iterator().next();
    TypeElement typeElement = updateElement.accept(new TypeResolvingVisitor(), null);
    boolean implementsDbUpdate = false;
    for (TypeMirror typeMirror : typeElement.getInterfaces()) {
      if (typeMirror.toString().equals(hookInterface.getCanonicalName())) {
        implementsDbUpdate = true;
      }
    }
    if (!implementsDbUpdate) {
      messager.printMessage(Kind.ERROR,
          "The " + hookAnnotation + " hook has to implement the " + hookInterface.getCanonicalName() + " interface", updateElement);
      return null;
    }
    return typeElement.getQualifiedName().toString();
  }
View Full Code Here

      Set<? extends Element> elements = roundEnv
          .getElementsAnnotatedWith(annotation);
      for (Element element : elements) {

        try {
          TypeElement typeElement = (TypeElement) element;

          String qualifiedName = typeElement.getQualifiedName()
              .toString();
          Class<?> modelClass = Class.forName(qualifiedName);

          String code = ModelGenerator.generateJavascript(modelClass,
              outputConfig);

          Model modelAnnotation = element.getAnnotation(Model.class);
          String modelName = modelAnnotation.value();
          String fileName;
          String packageName = "";
          if (StringUtils.hasText(modelName)) {
            int lastDot = modelName.lastIndexOf('.');
            if (lastDot != -1) {
              fileName = modelName.substring(lastDot + 1);
              int firstDot = modelName.indexOf('.');
              if (firstDot < lastDot) {
                packageName = modelName.substring(firstDot + 1,
                    lastDot);
              }
            }
            else {
              fileName = modelName;
            }
          }
          else {
            fileName = typeElement.getSimpleName().toString();
          }

          if (createBaseAndSubclass) {
            code = code.replaceFirst(
                "(Ext.define\\([\"'].+?)([\"'],)", "$1Base$2");
View Full Code Here

      }

      // validation processing for annotations with annotation constraint
      for (AnnotationMirror annotationMirror : annotationType
          .getAnnotationMirrors()) {
        TypeElement memberAnnotationTypeElement = (TypeElement) annotationMirror
            .getAnnotationType().asElement();
        Class<? extends ConstraintValidator> constraintValidatorClass = null;

        if (shouldSkip(memberAnnotationTypeElement)) {
          continue;
        }

        constraintValidatorClass = (Class<? extends ConstraintValidator>) getConstraintValidatorClass(
            memberAnnotationTypeElement, Constraint.class);
        ConstraintValidator validator = getConstraintValidator(
            constraintValidatorClass, constraintValidatorMap);

        if (validator != null) {
          for (Element e : roundEnv
              .getElementsAnnotatedWith(annotationType)) {
            validator.validate(processingEnv, roundEnv,
                annotationType, annotationMirror, e);
          }
        }
      }

      // validation processing for annotation member values
      for (ExecutableElement annotationMember : ElementFilter
          .methodsIn(annotationType.getEnclosedElements())) {
        // annotationMember is a method of an annotation
        for (AnnotationMirror annotationMirror : annotationMember
            .getAnnotationMirrors()) {
          // annotationMirror is an annotation on a method of an
          // annotation
          TypeElement memberAnnotationTypeElement = (TypeElement) annotationMirror
              .getAnnotationType().asElement();
          Class<? extends ValueConstraintValidator> constraintValidatorClass = null;

          if (shouldSkip(memberAnnotationTypeElement)) {
            continue;
View Full Code Here

TOP

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

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.