Package japa.parser.ast.type

Examples of japa.parser.ast.type.ReferenceType


            // We only provide very primitive support for wildcard types; Roo
            // only needs metadata at the end of the day,
            // not complete binding support from an AST
            final WildcardType wt = (WildcardType) internalType;
            if (wt.getSuper() != null) {
                final ReferenceType rt = wt.getSuper();
                final ClassOrInterfaceType cit = (ClassOrInterfaceType) rt
                        .getType();
                final JavaType effectiveType = getJavaTypeNow(
                        compilationUnitServices, cit, typeParameters);
                return new JavaType(effectiveType.getFullyQualifiedTypeName(),
                        rt.getArrayCount(), effectiveType.getDataType(),
                        JavaType.WILDCARD_SUPER, effectiveType.getParameters());
            }
            else if (wt.getExtends() != null) {
                final ReferenceType rt = wt.getExtends();
                final ClassOrInterfaceType cit = (ClassOrInterfaceType) rt
                        .getType();
                final JavaType effectiveType = getJavaTypeNow(
                        compilationUnitServices, cit, typeParameters);
                return new JavaType(effectiveType.getFullyQualifiedTypeName(),
                        rt.getArrayCount(), effectiveType.getDataType(),
                        JavaType.WILDCARD_EXTENDS,
                        effectiveType.getParameters());
            }
            else {
                return new JavaType(OBJECT.getFullyQualifiedTypeName(), 0,
View Full Code Here


     * @param nameExpr to convert (required)
     * @return the corresponding {@link ReferenceType} (never null)
     */
    public static ReferenceType getReferenceType(final NameExpr nameExpr) {
        Validate.notNull(nameExpr, "Java type required");
        return new ReferenceType(getClassOrInterfaceType(nameExpr));
    }
View Full Code Here

        }
       
        if (current.getArray() > 0) {
          // Primitives includes array declaration in resolvedName
          if (!current.isPrimitive()){
            return new ReferenceType(resolvedName, current.getArray());
          }
        }

        return resolvedName;
    }
View Full Code Here

                typeArgs.add(JavaParserUtils.importParametersForType(
                        targetType,
                        imports, parameter));
            }
        }
        return  new ReferenceType(cit);
    }
View Full Code Here

                }
            }

            // Handle arrays
            if (method.getReturnType().isArray()) {
                final ReferenceType rt = new ReferenceType();
                rt.setArrayCount(method.getReturnType().getArray());
                rt.setType(cit);
                returnType = rt;
            }
            else {
                returnType = cit;
            }
        }

        // Start with the basic method
        final MethodDeclaration d = new MethodDeclaration();
        d.setModifiers(JavaParserUtils.getJavaParserModifier(method
                .getModifier()));
        d.setName(method.getMethodName().getSymbolName());
        d.setType(returnType);

        // Add any method-level annotations (not parameter annotations)
        final List<AnnotationExpr> annotations = new ArrayList<AnnotationExpr>();
        d.setAnnotations(annotations);
        for (final AnnotationMetadata annotation : method.getAnnotations()) {
            JavaParserAnnotationMetadataBuilder.addAnnotationToList(
                    compilationUnitServices, annotations, annotation);
        }

        // Add any method parameters, including their individual annotations and
        // type parameters
        final List<Parameter> parameters = new ArrayList<Parameter>();
        d.setParameters(parameters);

        int index = -1;
        for (final AnnotatedJavaType methodParameter : method
                .getParameterTypes()) {
            index++;

            // Add the parameter annotations applicable for this parameter type
            final List<AnnotationExpr> parameterAnnotations = new ArrayList<AnnotationExpr>();

            for (final AnnotationMetadata parameterAnnotation : methodParameter
                    .getAnnotations()) {
                JavaParserAnnotationMetadataBuilder.addAnnotationToList(
                        compilationUnitServices, parameterAnnotations,
                        parameterAnnotation);
            }

            // Compute the parameter name
            final String parameterName = method.getParameterNames().get(index)
                    .getSymbolName();

            // Compute the parameter type
            Type parameterType = null;
            if (methodParameter.getJavaType().isPrimitive()) {
                parameterType = JavaParserUtils.getType(methodParameter
                        .getJavaType());
            }
            else {
                final NameExpr type = JavaParserUtils.importTypeIfRequired(
                        compilationUnitServices.getEnclosingTypeName(),
                        compilationUnitServices.getImports(),
                        methodParameter.getJavaType());
                final ClassOrInterfaceType cit = JavaParserUtils
                        .getClassOrInterfaceType(type);

                // Add any type arguments presented for the return type
                if (methodParameter.getJavaType().getParameters().size() > 0) {
                    final List<Type> typeArgs = new ArrayList<Type>();
                    cit.setTypeArgs(typeArgs);
                    for (final JavaType parameter : methodParameter
                            .getJavaType().getParameters()) {
                        typeArgs.add(JavaParserUtils.importParametersForType(
                                compilationUnitServices.getEnclosingTypeName(),
                                compilationUnitServices.getImports(), parameter));
                    }
                }

                // Handle arrays
                if (methodParameter.getJavaType().isArray()) {
                    final ReferenceType rt = new ReferenceType();
                    rt.setArrayCount(methodParameter.getJavaType().getArray());
                    rt.setType(cit);
                    parameterType = rt;
                }
                else {
                    parameterType = cit;
                }
View Full Code Here

     * @param arrayCount
     *            number os arrays or <code>0</code> if is not a array.
     * @return instanceof {@link ReferenceType}
     */
    public static ReferenceType createReferenceType(String name, int arrayCount) {
        return new ReferenceType(new ClassOrInterfaceType(name), arrayCount);
    }
View Full Code Here

     * @param arrayCount
     *            number os arrays or <code>0</code> if is not a array.
     * @return instanceof {@link ReferenceType}
     */
    public static ReferenceType createReferenceType(PrimitiveType type, int arrayCount) {
        return new ReferenceType(type, arrayCount);
    }
View Full Code Here

        return Boolean.TRUE;
    }

    public Boolean visit(ReferenceType n1, Node arg) {
        ReferenceType n2 = (ReferenceType) arg;

        if (n1.getArrayCount() != n2.getArrayCount()) {
            return Boolean.FALSE;
        }

        if (!nodeEquals(n1.getType(), n2.getType())) {
            return Boolean.FALSE;
        }

        return Boolean.TRUE;
    }
View Full Code Here

                jj_consume_token(-1);
                throw new ParseException();
        }
        {
            if (true) {
                return new ReferenceType(type.getBeginLine(), type.getBeginColumn(), token.endLine, token.endColumn, type, arrayCount);
            }
        }
        throw new Error("Missing return statement in function");
    }
View Full Code Here

        }
        throw new Error("Missing return statement in function");
    }

    final public WildcardType Wildcard() throws ParseException {
        ReferenceType ext = null;
        ReferenceType sup = null;
        int line;
        int column;
        jj_consume_token(HOOK);
        line = token.beginLine;
        column = token.beginColumn;
View Full Code Here

TOP

Related Classes of japa.parser.ast.type.ReferenceType

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.