Package javax.lang.model.element

Examples of javax.lang.model.element.TypeElement


                else if(componentType.equals("long"))  JVMSig += SIG_LONG ;
                else if(componentType.equals("float")) JVMSig += SIG_FLOAT ;
                else if(componentType.equals("double"))  JVMSig += SIG_DOUBLE ;
                else {
                    if(!componentType.equals("")){
                        TypeElement classNameDoc = elems.getTypeElement(componentType);

                        if(classNameDoc == null){
                            throw new SignatureException(componentType);
                        }else {
                            String classname = classNameDoc.getQualifiedName().toString();
                            String newclassname = classname.replace('.', '/');
                            JVMSig += "L";
                            JVMSig += newclassname;
                            JVMSig += ";";
                        }
View Full Code Here


                            if (type.getKind() == TypeKind.ERROR) {
                                // There are errors, give it up.
                                return null;
                            }
                            assert type.getKind() == TypeKind.DECLARED;
                            TypeElement te = (TypeElement) types.asElement(type);
                            methodClassType = ElementUtilities.getBinaryName(te);
                        } else {
                            //identifier = ((MemberSelectTree) ((MethodInvocationTree) node).getMethodSelect()).getIdentifier();
                            identifier = ((MethodInvocationTree) node).getMethodSelect();
                            if (identifier.getKind() == Tree.Kind.IDENTIFIER) {
                                methodName = ((IdentifierTree) identifier).getName().toString();
                                TreePath iPath = TreePath.getPath(cu, identifier);
                                TypeElement te = trees.getScope(iPath).getEnclosingClass();
                                if (te == null) {
                                    // No enclosing class? Some error, give it up.
                                    return null;
                                }
                                methodClassType = ElementUtilities.getBinaryName(te);
                            } else {
                                methodName = ((MemberSelectTree) identifier).getIdentifier().toString();
                                getStartPosFromMethodLength = true;
                                ExpressionTree exp = ((MemberSelectTree) identifier).getExpression();
                                TreePath expPath = TreePath.getPath(cu, exp);
                                TypeMirror type = trees.getTypeMirror(expPath);
                                if (type.getKind() == TypeKind.ERROR) {
                                    // There are errors, give it up.
                                    return null;
                                }
                                TypeElement te;
                                if (type.getKind() == TypeKind.DECLARED) {
                                    te = (TypeElement) types.asElement(type);
                                } else if (type.getKind() == TypeKind.TYPEVAR) {
                                    TypeParameterElement tpe = (TypeParameterElement) types.asElement(type);
                                    List<? extends TypeMirror> exts = tpe.getBounds();
View Full Code Here

        }
    }

    @Override
    public TypeElement visitClass(ClassTree arg0, Void arg1) {
        TypeElement typeElement = (TypeElement) trees.getElement(getCurrentPath());
        if (typeElement == null) {
            return super.visitClass(arg0, arg1);
        }
        String binaryName = elements.getBinaryName(typeElement).toString();
        if (match(binaryName)) {
View Full Code Here

                public void run(CompilationController control) throws Exception {
                    if (JavaSource.Phase.ELEMENTS_RESOLVED.compareTo(control.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED))<=0) {
                        Elements elements = control.getElements();
                        Trees trees = control.getTrees();
                        Types types = control.getTypes();
                        TypeElement applet = elements.getTypeElement("java.applet.Applet");     //NOI18N
                        TypeElement japplet = elements.getTypeElement("javax.swing.JApplet");   //NOI18N
                        CompilationUnitTree cu = control.getCompilationUnit();
                        List<? extends Tree> topLevels = cu.getTypeDecls();
                        for (Tree topLevel : topLevels) {
                            if (topLevel.getKind() == Tree.Kind.CLASS) {
                                TypeElement type = (TypeElement) trees.getElement(TreePath.getPath(cu, topLevel));
                                if (type != null) {
                                    Set<Modifier> modifiers = type.getModifiers();
                                    if (modifiers.contains(Modifier.PUBLIC) &&
                                        ((applet != null && types.isSubtype(type.asType(), applet.asType()))
                                        || (japplet != null && types.isSubtype(type.asType(), japplet.asType())))) {
                                            result[0] = true;
                                            break;
                                    }
                                }
                            }
View Full Code Here

        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

                    }
                    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

    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

  @Override
  public Void visitExecutable(ExecutableElement x, State state) {
    if (shouldIgnore(x, state)) {
      return null;
    }
    final TypeElement requestContextElement =
        (TypeElement) state.types.asElement(x.getReturnType());
    new ScannerBase<Void>() {

      /**
       * Scan a method within a RequestContext.
       */
      @Override
      public Void visitExecutable(ExecutableElement x, State state) {
        if (shouldIgnore(x, state)) {
          return null;
        }
        String requestContextBinaryName =
            state.elements.getBinaryName(requestContextElement).toString();
        String clientMethodDescriptor = x.asType().accept(new DescriptorBuilder(), state);
        String domainMethodDescriptor = null;
        ExecutableElement domainElement = (ExecutableElement) state.getClientToDomainMap().get(x);
        if (domainElement == null) {
          /*
           * No mapping from the client to domain type, probably because of an
           * unresolved ServiceName annotation. This can be fixed when building
           * the server by running ValidationTool.
           */
          if (state.mustResolveAllAnnotations()) {
            state.poison(x, Messages
                .deobfuscatorMissingContext(requestContextElement.getSimpleName()));
          }
        } else {
          domainMethodDescriptor = domainElement.asType().accept(new DescriptorBuilder(), state);
        }
        String methodName = x.getSimpleName().toString();
View Full Code Here

      }
      String binaryName = state.elements.getBinaryName(clientType).toString();
      // withRawTypeToken("1234ABC", "com.example.FooProxy");
      println("withRawTypeToken(\"%s\", \"%s\");", OperationKey.hash(binaryName), binaryName);

      TypeElement domainType = (TypeElement) clientToDomainMap.get(clientType);
      if (domainType == null) {
        /*
         * Missing proxy mapping, probably due to an unresolved ProxyForName. If
         * we're running as part of a build tool or an IDE, the
         * mustResolveAllAnnotations() call below will return false. The
View Full Code Here

        state.addMapping(x, (TypeElement) state.types.asElement(type));
      }
    }
    if (serviceName != null) {
      poisonIfAnnotationPresent(state, x, jsonRpcService);
      TypeElement domain =
          state.elements.getTypeElement(BinaryName.toSourceName(serviceName.value()));
      if (domain == null) {
        state.warn(x, Messages.contextMissingDomainType(serviceName.value()));
      }
      state.addMapping(x, domain);
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.