Package javax.lang.model.util

Examples of javax.lang.model.util.Types.asElement()


  private void findLocalAndInheritedMethods(TypeElement type, List<ExecutableElement> methods) {
    note("Looking at methods in " + type);
    Types typeUtils = processingEnv.getTypeUtils();
    Elements elementUtils = processingEnv.getElementUtils();
    for (TypeMirror superInterface : type.getInterfaces()) {
      findLocalAndInheritedMethods((TypeElement) typeUtils.asElement(superInterface), methods);
    }
    if (type.getSuperclass().getKind() != TypeKind.NONE) {
      // Visit the superclass after superinterfaces so we will always see the implementation of a
      // method after any interfaces that declared it.
      findLocalAndInheritedMethods(
View Full Code Here


    }
    if (type.getSuperclass().getKind() != TypeKind.NONE) {
      // Visit the superclass after superinterfaces so we will always see the implementation of a
      // method after any interfaces that declared it.
      findLocalAndInheritedMethods(
          (TypeElement) typeUtils.asElement(type.getSuperclass()), methods);
    }
    // Add each method of this class, and in so doing remove any inherited method it overrides.
    // This algorithm is quadratic in the number of methods but it's hard to see how to improve
    // that while still using Elements.overrides.
    List<ExecutableElement> theseMethods = ElementFilter.methodsIn(type.getEnclosedElements());
View Full Code Here

      TypeMirror parentMirror = type.getSuperclass();
      if (parentMirror.getKind() == TypeKind.NONE) {
        return false;
      }
      Types typeUtils = processingEnv.getTypeUtils();
      TypeElement parentElement = (TypeElement) typeUtils.asElement(parentMirror);
      if (parentElement.getAnnotation(AutoValue.class) != null) {
        return true;
      }
      type = parentElement;
    }
View Full Code Here

    final Elements elements = processingEnv.getElementUtils();
    final Types types = processingEnv.getTypeUtils();

    Set<String> result = new HashSet<String>();

    for (Element el : ElementFilter.methodsIn(elements.getAllMembers((TypeElement) types.asElement(modelType)))) {
      String propertyName = AnnotationProcessors.propertyNameOfMethod(el);
      if (propertyName != null) {
        result.add(propertyName);
      }
      // TODO extract type info from methods
View Full Code Here

    final Elements elements = processingEnv.getElementUtils();
    final Types types = processingEnv.getTypeUtils();

    Set<String> result = new HashSet<String>();

    for (Element el : ElementFilter.methodsIn(elements.getAllMembers((TypeElement) types.asElement(modelType)))) {
      String propertyName = AnnotationProcessors.propertyNameOfMethod(el);
      if (propertyName != null) {
        result.add(propertyName);
      }
      // TODO extract type info from methods
View Full Code Here

                    throw new AssertionError("Trees.getOriginalType() error!");
                }

                Types types = task.getTypes();

                str1 = types.asElement(trees.getOriginalType((ErrorType)typeMirror)).toString();
                if (!str1.equals("java.lang.Number")) {
                    throw new AssertionError("Types.asElement() error!");
                }

                i++;
View Full Code Here

                    throw new AssertionError("Trees.getOriginalType() error!");
                }

                Types types = task.getTypes();

                str1 = types.asElement(trees.getOriginalType((ErrorType)typeMirror)).toString();
                if (!str1.equals("FooBar")) {
                    throw new AssertionError("Types.asElement() error!");
                }
                foundError = true;
              }
View Full Code Here

            case "char":
            case "boolean":
                final TypeKind kind = TypeKind.valueOf(name.toUpperCase(Locale.ENGLISH));
                return types.boxedClass(types.getPrimitiveType(kind));
            default:
                return (TypeElement) types.asElement(returnType);
        }
    }

    private Argument findInput(List<? extends VariableElement> parameters) {
        if (parameters.size() == 1) {
View Full Code Here

        throw new IllegalStateException("no package for " + typeElement);
    }

    protected TypeElement asTypeElement(TypeMirror typeMirror) {
        Types TypeUtils = this.processingEnv.getTypeUtils();
        return (TypeElement)TypeUtils.asElement(typeMirror);
    }


    protected void generateJavaClass(String className, Template mustache, ImmutableMap<String, Object> ctx,
                                     Element originatingElements) throws IOException {
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.