Examples of TypeElement


Examples of javax.lang.model.element.TypeElement

         */
        public List<VariableElement> getEnumConstants() {
            if (isEnum() == false) {
                throw new IllegalStateException();
            }
            TypeElement decl = (TypeElement) element;
            List<VariableElement> results = Lists.create();
            for (Element member : decl.getEnclosedElements()) {
                if (isEnumConstant(member)) {
                    results.add((VariableElement) member);
                }
            }
            return results;
View Full Code Here

Examples of javax.lang.model.element.TypeElement

    void assertTypeEquals(
            OperatorCompilingEnvironment env,
            TypeMirror type,
            Class<?> expected) {
        TypeElement elem = env.getElementUtils().getTypeElement(expected.getName());
        TypeMirror exType = env.getTypeUtils().getDeclaredType(elem);
        assertTrue(env.getTypeUtils().isSameType(type, exType));
    }
View Full Code Here

Examples of javax.lang.model.element.TypeElement

     * @return 対応する宣言型
     * @throws IllegalArgumentException 引数に{@code null}が含まれる場合
     */
    public DeclaredType getDeclaredType(Class<?> type) {
        Precondition.checkMustNotBeNull(type, "type"); //$NON-NLS-1$
        TypeElement elem = getElementUtils().getTypeElement(type.getName());
        if (elem == null) {
            throw new IllegalStateException(type.getName());
        }
        return getTypeUtils().getDeclaredType(elem);
    }
View Full Code Here

Examples of javax.lang.model.element.TypeElement

     */
    public TypeMirror getErasure(TypeMirror type) {
        Precondition.checkMustNotBeNull(type, "type"); //$NON-NLS-1$
        // Eclipse のバグでイレイジャを正しく計算できない
        if (type.getKind() == TypeKind.DECLARED) {
            TypeElement element = (TypeElement) ((DeclaredType) type).asElement();
            return getTypeUtils().getDeclaredType(element);
        }
        return getTypeUtils().erasure(type);
    }
View Full Code Here

Examples of javax.lang.model.element.TypeElement

    "element.getKind() != ElementKind.OTHER"
  })
  @Ensures("element != null")
  protected static TypeElement getRootElement(Element element) {
    if (element.getKind().isClass() || element.getKind().isInterface()) {
      TypeElement type = (TypeElement) element;
      if (!type.getNestingKind().isNested()) {
        return type;
      }
    }

    return getRootElement(element.getEnclosingElement());
View Full Code Here

Examples of javax.lang.model.element.TypeElement

        boolean found = false;
        String consumerClassName = null;
        String consumerPrefix = Strings.getOrElse(uriEndpoint.consumerPrefix(), "");
        if (consumerType != null) {
            consumerClassName = consumerType.toString();
            TypeElement consumerElement = findTypeElement(roundEnv, consumerClassName);
            if (consumerElement != null) {
                writer.println("<h2>" + scheme + " consumer" + "</h2>");
                showDocumentationAndFieldInjections(writer, roundEnv, consumerElement, consumerPrefix);
                found = true;
            }
View Full Code Here

Examples of javax.lang.model.element.TypeElement

                    }
                    name = prefix + name;
                    // if the field type is a nested parameter then iterate through its fields
                    TypeMirror fieldType = fieldElement.asType();
                    String fieldTypeName = fieldType.toString();
                    TypeElement fieldTypeElement = findTypeElement(roundEnv, fieldTypeName);
                    UriParams fieldParams = null;
                    if (fieldTypeElement != null) {
                        fieldParams = fieldTypeElement.getAnnotation(UriParams.class);
                    }
                    if (fieldParams != null) {
                        String nestedPrefix = prefix;
                        String extraPrefix = fieldParams.prefix();
                        if (!Strings.isNullOrEmpty(extraPrefix)) {
                            nestedPrefix += extraPrefix;
                        }
                        findClassProperties(roundEnv, sortedMap, fieldTypeElement, nestedPrefix);
                    } else {
                        String docComment = elementUtils.getDocComment(fieldElement);
                        if (Strings.isNullOrEmpty(docComment)) {
                            String setter = "set" + fieldName.substring(0, 1).toUpperCase();
                            if (fieldName.length() > 1) {
                                setter += fieldName.substring(1);
                            }
                            //  lets find the setter
                            List<ExecutableElement> methods = ElementFilter.methodsIn(classElement.getEnclosedElements());
                            for (ExecutableElement method : methods) {
                                String methodName = method.getSimpleName().toString();
                                if (setter.equals(methodName) && method.getParameters().size() == 1) {
                                    String doc = elementUtils.getDocComment(method);
                                    if (!Strings.isNullOrEmpty(doc)) {
                                        docComment = doc;
                                        break;
                                    }
                                }
                            }
                        }
                        if (docComment == null) {
                            docComment = "";
                        }
                        List<String> values = new ArrayList<String>();
                        values.add("    <td>" + fieldTypeName + "</td>");
                        values.add("    <td>" + docComment.trim() + "</td>");

                        // TODO would be nice here to create a default endpoint/consumer object
                        // and return the default value of the field so we can put it into the docs
                        Object defaultValue = null;
                        if (defaultValue != null) {
                            values.add("    <td>" + defaultValue + "</td>");
                        }
                        if (sortedMap.containsKey(name)) {
                            error("Duplicate parameter annotation named '" + name + "' on class " + classElement.getQualifiedName());
                        } else {
                            sortedMap.put(name, values);
                        }
                    }
                }
            }
            TypeElement baseTypeElement = null;
            TypeMirror superclass = classElement.getSuperclass();
            if (superclass != null) {
                String superClassName = canonicalClassName(superclass.toString());
                baseTypeElement = findTypeElement(roundEnv, superClassName);
            }
View Full Code Here

Examples of javax.lang.model.element.TypeElement

    protected TypeElement findTypeElement(RoundEnvironment roundEnv, String className) {
        if (!Strings.isNullOrEmpty(className) && !"java.lang.Object".equals(className)) {
            Set<? extends Element> rootElements = roundEnv.getRootElements();
            for (Element rootElement : rootElements) {
                if (rootElement instanceof TypeElement) {
                    TypeElement typeElement = (TypeElement) rootElement;
                    String aRootName = canonicalClassName(typeElement.getQualifiedName().toString());
                    if (className.equals(aRootName)) {
                        return typeElement;
                    }
                }
            }
View Full Code Here

Examples of javax.lang.model.element.TypeElement

      //we don't know if an entity go up
      //
      //superclasses are always treated after their entities
      //and their access type are discovered
      //FIXME is it really true if only the superclass is changed
      TypeElement superClass = element;
      do {
        superClass = TypeUtils.getSuperclassTypeElement( superClass );
        if ( superClass != null ) {
          if ( TypeUtils.containsAnnotation( superClass, Entity.class, MappedSuperclass.class ) ) {
            //FIXME make it work for XML
View Full Code Here

Examples of javax.lang.model.element.TypeElement

    @Override
    public AnnotationMetaAttribute visitDeclared(DeclaredType declaredType, Element element) {
      //FIXME consider XML
      if ( isPersistent( element ) ) {
        TypeElement returnedElement = ( TypeElement ) context.getProcessingEnvironment()
            .getTypeUtils()
            .asElement( declaredType );
        // WARNING: .toString() is necessary here since Name equals does not compare to String
        String fqElementName = returnedElement.getQualifiedName().toString();
        String collection = COLLECTIONS.get( fqElementName );
        String targetEntity = getTargetEntity( element.getAnnotationMirrors() );
        if ( collection != null ) {
          if ( TypeUtils.containsAnnotation( element, ElementCollection.class ) ) {
            TypeMirror collectionElementType = getCollectionElementType( declaredType, fqElementName );
            final TypeElement collectionElement = ( TypeElement ) context.getProcessingEnvironment()
                .getTypeUtils()
                .asElement( collectionElementType );
            this.parent.context.processElement(
                collectionElement,
                this.parent.defaultAccessTypeForElement
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.