Package com.redhat.ceylon.compiler.loader.mirror

Examples of com.redhat.ceylon.compiler.loader.mirror.TypeMirror


                paramName = paramMirror.getName();
           
            Parameter parameter = new Parameter();
            parameter.setName(paramName);
           
            TypeMirror typeMirror = paramMirror.getType();
            Module module = Decl.getModuleContainer((Scope) decl);

            ProducedType type;
            if(isVariadic){
                // possibly make it optional
                TypeMirror variadicType = typeMirror.getComponentType();
                // we pretend it's toplevel because we want to get magic string conversion for variadic methods
                type = obtainType(Decl.getModuleContainer((Scope)decl), variadicType, (Scope)decl, TypeLocation.TOPLEVEL, VarianceLocation.CONTRAVARIANT);
                if(!isCeylon && !variadicType.isPrimitive()){
                    // Java parameters are all optional unless primitives
                    ProducedType optionalType = getOptionalType(type, module);
                    optionalType.setUnderlyingType(type.getUnderlyingType());
                    type = optionalType;
                }
View Full Code Here


                setValueTransientLateFlags(value, meth, true);
                setAnnotations(value, meth);
                markUnboxed(value, meth, meth.getReturnType());

                TypeMirror setterClass = (TypeMirror) getAnnotationValue(value.classMirror, CEYLON_ATTRIBUTE_ANNOTATION, "setterClass");
                // void.class is the default value, I guess it's a primitive?
                if(setterClass != null && !setterClass.isPrimitive()){
                    ClassMirror setterClassMirror = setterClass.getDeclaredClass();
                    value.setVariable(true);
                    SetterWithLocalDeclarations setter = makeSetter(value, setterClassMirror);
                    // adding local scopes should be done last, when we have the setter, because it may be needed by container chain
                    addLocalDeclarations(value, value.classMirror, value.classMirror);
                    addLocalDeclarations(setter, setterClassMirror, setterClassMirror);
View Full Code Here

            return term;
        }
    }
    private void setPrimaryFromAnnotationInvocationAnnotation(AnnotationMirror annotationInvocationAnnotation,
            AnnotationInvocation ai) {
        TypeMirror annotationType = (TypeMirror)annotationInvocationAnnotation.getValue(CEYLON_ANNOTATION_INSTANTIATION_ANNOTATION_MEMBER);
        ClassMirror annotationClassMirror = annotationType.getDeclaredClass();
        Module module = findModuleForClassMirror(annotationClassMirror);
        if (annotationClassMirror.getAnnotation(CEYLON_METHOD_ANNOTATION) != null) {
            ai.setPrimary((Method)convertToDeclaration(module, annotationClassMirror, DeclarationType.VALUE));
        } else {
            ai.setPrimary((Class)convertToDeclaration(module, annotationClassMirror, DeclarationType.TYPE));
View Full Code Here

    }
    private LiteralAnnotationTerm readObjectValuesAnnotation(
            Module moduleScope,
            AnnotationMirror valueAnnotation, boolean singleValue) {
        if (singleValue) {
            TypeMirror klass = getAnnotationClassValues(valueAnnotation, "value").get(0);
            ProducedType type = obtainType(moduleScope, klass, null, null, null);
            ObjectLiteralAnnotationTerm term = new ObjectLiteralAnnotationTerm(type);
            return term;
        } else {
            CollectionLiteralAnnotationTerm result = new CollectionLiteralAnnotationTerm(ObjectLiteralAnnotationTerm.FACTORY);
View Full Code Here

        }
        return null;
    }
   
    private ProducedType obtainType(Module moduleScope, TypeMirror type, Scope scope, TypeLocation location, VarianceLocation variance) {
        TypeMirror originalType = type;
        // ERASURE
        type = applyTypeMapping(type, location);
       
        ProducedType ret = getNonPrimitiveType(moduleScope, type, scope, variance);
        if (ret.getUnderlyingType() == null) {
View Full Code Here

        } else if (sameType(type, EXCEPTION_TYPE)) {
            return CEYLON_EXCEPTION_TYPE;
           
        } else if (type.getKind() == TypeKind.ARRAY) {

            TypeMirror ct = type.getComponentType();
           
            if (sameType(ct, PRIM_BOOLEAN_TYPE)) {
                return JAVA_BOOLEAN_ARRAY_TYPE;
            } else if (sameType(ct, PRIM_BYTE_TYPE)) {
                return JAVA_BYTE_ARRAY_TYPE;
View Full Code Here

                    TypeParameter typeParameter = null;
                    if(i < typeParameters.size())
                        typeParameter = typeParameters.get(i);
                    ProducedType producedTypeArgument = null;
                    // do we have a type argument?
                    TypeMirror typeArgument = null;
                    SiteVariance siteVariance = null;
                    if(hasTypeArguments){
                        typeArgument = javacTypeArguments.get(i);
                        // if a single type argument is a wildcard and we are in a covariant location, we erase to Object
                        if(typeArgument.getKind() == TypeKind.WILDCARD){
                           
                            TypeMirror bound = typeArgument.getUpperBound();
                            if(bound != null){
                                siteVariance = SiteVariance.OUT;
                            } else {
                                bound = typeArgument.getLowerBound();
                                if(bound != null){
                                    // it has a lower bound
                                    siteVariance = SiteVariance.IN;
                                }
                            }
                            // use the bound in any case
                            typeArgument = bound;
                        }
                    }
                    // if we have no type argument, or if it's a wildcard with no bound, use the type parameter bounds if we can
                    if(typeArgument == null && typeParameterMirrors != null && i < typeParameterMirrors.size()){
                        TypeParameterMirror typeParameterMirror = typeParameterMirrors.get(i);
                        // FIXME: multiple bounds?
                        if(typeParameterMirror.getBounds().size() == 1){
                            // make sure we don't go overboard
                            if(rawDeclarationsSeen == null){
                                rawDeclarationsSeen = new HashSet<TypeDeclaration>();
                                // detect recursive bounds that we can't possibly satisfy, such as Foo<T extends Foo<T>>
                                if(!rawDeclarationsSeen.add(declaration))
                                    throw new RecursiveTypeParameterBoundException();
                            }
                            TypeMirror bound = typeParameterMirror.getBounds().get(0);
                            try{
                                producedTypeArgument = obtainTypeParameterBound(moduleScope, bound, declaration, rawDeclarationsSeen);
                                siteVariance = SiteVariance.OUT;
                            }catch(RecursiveTypeParameterBoundException x){
                                // damnit, go for Object later
View Full Code Here

                return it.getType();
            }else
                // no bound is Object
                return typeFactory.getObjectDeclaration().getType();
        }else{
            TypeMirror mappedType = applyTypeMapping(type, TypeLocation.TYPE_PARAM);

            TypeDeclaration declaration = (TypeDeclaration) convertNonPrimitiveTypeToDeclaration(moduleScope, mappedType, scope, DeclarationType.TYPE);
            if(declaration == null){
                throw new RuntimeException("Failed to find declaration for "+type);
            }
View Full Code Here

                // and the method's containing class
                enclosingClass = method.getEnclosingClass();
            }
           
            // if we are in a setter class, the attribute is declared in the getter class, so look for its declaration there
            TypeMirror getterClass = (TypeMirror) getAnnotationValue(enclosingClass, CEYLON_SETTER_ANNOTATION, "getterClass");
            boolean isSetter = false;
            // we use void.class as default value
            if(getterClass != null && !getterClass.isPrimitive()){
                enclosingClass = getterClass.getDeclaredClass();
                isSetter = true;
            }
           
            String javaClassName = enclosingClass.getQualifiedName();
           
View Full Code Here

    }
   
    private ClassOrInterface getContainer(Module module, ClassMirror classMirror) {
        AnnotationMirror containerAnnotation = classMirror.getAnnotation(CEYLON_CONTAINER_ANNOTATION);
        if(containerAnnotation != null){
            TypeMirror javaClassMirror = (TypeMirror)containerAnnotation.getValue("klass");
            String javaClassName = javaClassMirror.getQualifiedName();
            ClassOrInterface containerDecl = (ClassOrInterface) convertToDeclaration(module, javaClassName, DeclarationType.TYPE);
            if(containerDecl == null)
                throw new ModelResolutionException("Failed to load outer type " + javaClassName
                        + " for inner type " + classMirror.getQualifiedName().toString());
            return containerDecl;
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.loader.mirror.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.