Package javax.lang.model.util

Examples of javax.lang.model.util.Elements


    if (t1.getKind() == TypeKind.WILDCARD) {
      WildcardType wc1 = (WildcardType) t1;
      Type bound = (Type) wc1.getExtendsBound();
      if (bound == null) {
        // Implicit upper bound of java.lang.Object
        Elements elements = processingEnv.getElementUtils();
        return elements.getTypeElement("java.lang.Object").asType();
      }
      t1 = bound;
    }
    if (t2.getKind() == TypeKind.WILDCARD) {
      WildcardType wc2 = (WildcardType) t2;
      Type bound = (Type) wc2.getExtendsBound();
      if (bound == null) {
        // Implicit upper bound of java.lang.Object
        Elements elements = processingEnv.getElementUtils();
        return elements.getTypeElement("java.lang.Object").asType();
      }
      t2 = bound;
    }
    return types.lub(t1, t2);
  }
View Full Code Here


public class BoundAnnotationChecker extends AbstractProcessor {

  @Override
  public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    final Types types = processingEnv.getTypeUtils();
    final Elements elements = processingEnv.getElementUtils();
    final TypeMirror gwtWidgetType = elements.getTypeElement(TypeNames.GWT_WIDGET).asType();
    final TypeMirror gwtElementType = elements.getTypeElement(TypeNames.GWT_ELEMENT).asType();

    Map<TypeElement, List<Element>> classesWithBoundThings = new HashMap<TypeElement, List<Element>>();
    for (TypeElement annotation : annotations) {
      for (Element target : roundEnv.getElementsAnnotatedWith(annotation)) {
        TypeMirror targetType;
View Full Code Here

  /**
   * Returns the set of all bindable property names in the given model.
   */
  private Set<String> getPropertyNames(TypeMirror modelType) {
    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

   * @param classContainingBindableThings
   * @return
   */
  private List<TypeMirror> findAllModelTypes(TypeElement classContainingBindableThings) {
    final List<TypeMirror> result = new ArrayList<TypeMirror>();
    final Elements elements = processingEnv.getElementUtils();

    for (Element el : elements.getAllMembers(classContainingBindableThings)) {
      switch (el.getKind()) {
      case METHOD:
      case CONSTRUCTOR:
        if (!hasAnnotation(el, TypeNames.JAVAX_INJECT)) continue;

View Full Code Here

            if (rb != null) {
                name = rb.bundleName();
                pack = rb.packageName();
            } else {
                Elements eUtils = _pe.getElementUtils();

                pack = eUtils.getPackageOf(ele).getQualifiedName().toString();
                name = ele.getEnclosingElement().getSimpleName().toString();
            }
            if (!msg.locale().isEmpty()) {
                name += UNDERSCORE + msg.locale();
            }
View Full Code Here

        qualifiers = _environment.getOptions().get( QUALIFIERS );
    }

    public boolean process( final Set<? extends TypeElement> annotations, final RoundEnvironment round )
    {
        final Elements elementUtils = environment.getElementUtils();
        for ( final TypeElement anno : annotations )
        {
            if ( !ALL.equals( qualifiers ) || hasQualifier( anno ) )
            {
                for ( final Element elem : round.getElementsAnnotatedWith( anno ) )
                {
                    if ( elem.getKind().isClass() )
                    {
                        addClassToIndex( NAMED, elementUtils.getBinaryName( (TypeElement) elem ) );
                    }
                }
            }
        }
View Full Code Here

        JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
        fm.setLocation(CLASS_PATH, Collections.<File>emptyList());
        JavacTask javac = (JavacTask)tool.getTask(null, fm, null, null, null, null);
        Elements elements = javac.getElements();

        final Set<String> packages = new LinkedHashSet<String>();

        int nestedClasses = 0;
        int classes = 0;

        for (JavaFileObject file : fm.list(PLATFORM_CLASS_PATH, "", EnumSet.of(CLASS), true)) {
            String type = fm.inferBinaryName(PLATFORM_CLASS_PATH, file);
            if (type.endsWith("package-info"))
                continue;
            try {
                TypeElement elem = elements.getTypeElement(type);
                if (elem == null && type.indexOf('$') > 0) {
                    nestedClasses++;
                    type = null;
                    continue;
                }
                classes++;
                packages.add(getPackage(elem).getQualifiedName().toString());
                elements.getTypeElement(type).getKind(); // force completion
                type = null;
            } finally {
                if (type != null)
                    System.err.println("Looking at " + type);
            }
        }
        javac = null;
        elements = null;

        javac = (JavacTask)tool.getTask(null, fm, null, null, null, null);
        elements = javac.getElements();

        for (String name : packages) {
            PackageElement pe = elements.getPackageElement(name);
            for (Element e : pe.getEnclosedElements()) {
                e.getSimpleName().getClass();
            }
        }
        /*
 
View Full Code Here

        JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
        String srcdir = System.getProperty("test.src");
        File file = new File(srcdir, args[0]);
        JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, fm, null, null, null, fm.getJavaFileObjectsFromFiles(Arrays.asList(file)));
        Elements elements = task.getElements();
        for (TypeElement clazz : task.enter(task.parse())) {
            String doc = elements.getDocComment(clazz);
            if (doc == null)
                throw new AssertionError(clazz.getSimpleName() + ": no doc comment");
            System.out.format("%s: %s%n", clazz.getSimpleName(), doc);
        }
    }
View Full Code Here

  }

  @Override
  public boolean process(Set<? extends TypeElement> annotations,
      RoundEnvironment roundEnv) {
    Elements elementUtils = this.processingEnv.getElementUtils();
    for (Element element : roundEnv.getElementsAnnotatedWith(elementUtils
        .getTypeElement(configurationPropertiesAnnotation()))) {
      processElement(element);
    }
    if (roundEnv.processingOver()) {
      writeMetaData(this.metadata);
View Full Code Here

    return "public static volatile " + parent.importType( getMetaType() ) + "<" + parent.importType( parent.getQualifiedName() ) + ", " + parent
        .importType( getTypeDeclaration() ) + "> " + getPropertyName() + ";";
  }

  public String getPropertyName() {
    Elements elementsUtil = parent.getContext().getElementUtils();
    if ( element.getKind() == ElementKind.FIELD ) {
      return element.getSimpleName().toString();
    }
    else if ( element.getKind() == ElementKind.METHOD ) {
      String name = element.getSimpleName().toString();
      if ( name.startsWith( "get" ) ) {
        return elementsUtil.getName( Introspector.decapitalize( name.substring( "get".length() ) ) ).toString();
      }
      else if ( name.startsWith( "is" ) ) {
        return ( elementsUtil.getName( Introspector.decapitalize( name.substring( "is".length() ) ) ) ).toString();
      }
      return elementsUtil.getName( Introspector.decapitalize( name ) ).toString();
    }
    else {
      return elementsUtil.getName( element.getSimpleName() + "/* " + element.getKind() + " */" ).toString();
    }
  }
View Full Code Here

TOP

Related Classes of javax.lang.model.util.Elements

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.