Package javax.lang.model.type

Examples of javax.lang.model.type.TypeMirror


        writer.println("<h1>" + title + "</h1>");

        showDocumentationAndFieldInjections(writer, roundEnv, classElement, "");

        // This code is not my fault, it seems to honestly be the hacky way to find a class name in APT :)
        TypeMirror consumerType = null;
        try {
            uriEndpoint.consumerClass();
        } catch (MirroredTypeException mte) {
            consumerType = mte.getTypeMirror();
        }

        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


                    String defaultValue = param.defaultValue();
                    String defaultValueNote = param.defaultValueNote();

                    // 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 (!isNullOrEmpty(extraPrefix)) {
                            nestedPrefix += extraPrefix;
                        }
                        findClassProperties(roundEnv, endpointOptions, fieldTypeElement, nestedPrefix);
                    } else {
                        String docComment = elementUtils.getDocComment(fieldElement);
                        if (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 (!isNullOrEmpty(doc)) {
                                        docComment = doc;
                                        break;
                                    }
                                }
                            }
                        }
                        if (docComment == null) {
                            docComment = "";
                        }

                        // gather enums
                        Set<String> enums = new LinkedHashSet<>();
                        boolean isEnum = fieldTypeElement != null && fieldTypeElement.getKind() == ElementKind.ENUM;
                        if (isEnum) {
                            TypeElement enumClass = findTypeElement(roundEnv, fieldTypeElement.asType().toString());
                            // find all the enum constants which has the possible enum value that can be used
                            List<VariableElement> fields = ElementFilter.fieldsIn(enumClass.getEnclosedElements());
                            for (VariableElement var : fields) {
                                if (var.getKind() == ElementKind.ENUM_CONSTANT) {
                                    String val = var.toString();
                                    enums.add(val);
                                }
                            }
                        }

                        EndpointOption option = new EndpointOption(name, fieldTypeName, defaultValue, defaultValueNote,  docComment.trim(), isEnum, enums);
                        endpointOptions.add(option);
                    }
                }
            }
            TypeElement baseTypeElement = null;
            TypeMirror superclass = classElement.getSuperclass();
            if (superclass != null) {
                String superClassName = canonicalClassName(superclass.toString());
                baseTypeElement = findTypeElement(roundEnv, superClassName);
            }
            if (baseTypeElement != null) {
                classElement = baseTypeElement;
            } else {
View Full Code Here

            return false;
        }
        if (isKindMatched(environment, type) == false) {
            return false;
        }
        TypeMirror datamodel = environment.getDeclaredType(DataModel.class);
        return environment.getTypeUtils().isSubtype(type, datamodel);
    }
View Full Code Here

     * @throws IllegalArgumentException if some parameters were {@code null}
     */
    public Expression toMetaData(OperatorPortDeclaration var, int position) {
        Precondition.checkMustNotBeNull(var, "var"); //$NON-NLS-1$
        NamedType type;
        TypeMirror representation = var.getType().getRepresentation();
        List<AnnotationElement> members = Lists.create();
        members.add(factory.newAnnotationElement(
                factory.newSimpleName("name"),
                Models.toLiteral(factory, var.getName())));
        members.add(factory.newAnnotationElement(
View Full Code Here

        works.add(type);
        Set<TypeMirror> saw = Sets.create();
        List<TypeElement> types = Lists.create();
        int countDown = 100; // avoid infinite loop
        while (works.isEmpty() == false && --countDown >= 0) {
            TypeMirror target = works.removeFirst();
            if (saw.contains(target)) {
                continue;
            }
            saw.add(target);
            Element element = environment.getTypeUtils().asElement(target);
View Full Code Here

            ModelFactory f = context.environment.getFactory();
            ImportBuilder ib = context.importer;
            Jsr269 conv = new Jsr269(f);
            List<Expression> parameterTypeLiterals = Lists.create();
            for (VariableElement parameter : helperMethod.getParameters()) {
                TypeMirror type = context.environment.getErasure(parameter.asType());
                parameterTypeLiterals.add(new TypeBuilder(f, ib.resolve(conv.convert(type)))
                    .dotClass()
                    .toExpression());
            }
            Expression attribute = new TypeBuilder(f, ib.toType(OperatorHelper.class))
View Full Code Here

            List<OperatorPortDeclaration> parameters) {
        assert output != null;
        assert inputPorts != null;
        assert parameters != null;
        Types types = environment.getTypeUtils();
        TypeMirror outputType = output.getType().getRepresentation();
        for (OperatorPortDeclaration input : inputPorts) {
            if (types.isSameType(outputType, input.getType().getRepresentation())) {
                return new OperatorPortDeclaration(
                        output.getKind(),
                        output.getDocumentation(),
                        output.getName(),
                        PortTypeDescription.reference(outputType, input.getName()),
                        output.getParameterPosition(),
                        null);
            }
        }
        DeclaredType classType = environment.getDeclaredType(Class.class);
        for (OperatorPortDeclaration param : parameters) {
            // check is form of M<T>
            TypeMirror paramType = param.getType().getRepresentation();
            if (paramType.getKind() != TypeKind.DECLARED) {
                continue;
            }
            DeclaredType declParamType = (DeclaredType) paramType;
            if (declParamType.getTypeArguments().size() != 1) {
                continue;
View Full Code Here

            .toAttributes();
    }

    @Override
    protected Type getSuperClass() {
        TypeMirror type = operatorClass.getElement().asType();
        return util.t(type);
    }
View Full Code Here

        Precondition.checkMustNotBeNull(processor, "processor"); //$NON-NLS-1$
        Class<? extends Annotation> target = processor.getTargetAnnotationType();
        assert target != null;
        TypeElement annotation = environment.getElementUtils().getTypeElement(target.getCanonicalName());
        assert annotation != null;
        TypeMirror annotationType = annotation.asType();

        Set<? extends Element> elements = round.getElementsAnnotatedWith(annotation);
        for (Element element : elements) {
            ExecutableElement method = toOperatorMethodElement(element);
            if (method == null) {
View Full Code Here

        return targetOperatorAnnotation;
    }

    @Override
    public synchronized AnnotationMirror getOperatorAnnotation(ExecutableElement element) {
        TypeMirror targetType = environment
                .getElementUtils()
                .getTypeElement(targetOperatorAnnotation.getName())
                .asType();
        Types types = environment.getTypeUtils();
        for (AnnotationMirror annotation : element.getAnnotationMirrors()) {
View Full Code Here

TOP

Related Classes of javax.lang.model.type.TypeMirror

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.