Package com.redhat.ceylon.compiler.typechecker.model

Examples of com.redhat.ceylon.compiler.typechecker.model.Module


        synchronized(getLock()){
            boolean isJdk = false;
            boolean defaultModule = false;

            // make sure it isn't loaded
            Module module = getLoadedModule(moduleName);
            if(module != null)
                return module;

            if(JDKUtils.isJDKModule(moduleName) || JDKUtils.isOracleJDKModule(moduleName)){
                isJdk = true;
            }

            java.util.List<String> moduleNameList = Arrays.asList(moduleName.split("\\."));
            module = moduleManager.getOrCreateModule(moduleNameList, version);
            // make sure that when we load the ceylon language module we set it to where
            // the typechecker will look for it
            if(moduleName.equals(CEYLON_LANGUAGE)
                    && modules.getLanguageModule() == null){
                modules.setLanguageModule(module);
            }

            // TRICKY We do this only when isJava is true to prevent resetting
            // the value to false by mistake. LazyModule get's created with
            // this attribute to false by default, so it should work
            if (isJdk && module instanceof LazyModule) {
                ((LazyModule)module).setJava(true);
            }

            // FIXME: this can't be that easy.
            if(isJdk)
                module.setAvailable(true);
            module.setDefault(defaultModule);
            return module;
        }
    }
View Full Code Here


            for (AnnotationMirror importAttribute : imports) {
                String dependencyName = (String) importAttribute.getValue("name");
                if (dependencyName != null) {
                    String dependencyVersion = (String) importAttribute.getValue("version");

                    Module dependency = moduleManager.getOrCreateModule(ModuleManager.splitModuleName(dependencyName), dependencyVersion);

                    Boolean optionalVal = (Boolean) importAttribute.getValue("optional");

                    Boolean exportVal = (Boolean) importAttribute.getValue("export");

                    ModuleImport moduleImport = moduleManager.findImport(module, dependency);
                    if (moduleImport == null) {
                        boolean optional = optionalVal != null && optionalVal;
                        boolean export = exportVal != null && exportVal;
                        moduleImport = new ModuleImport(dependency, optional, export);
                        module.addImport(moduleImport);
                    }
                }
            }
        }
       
        module.setAvailable(true);
       
        modules.getListOfModules().add(module);
        Module languageModule = modules.getLanguageModule();
        module.setLanguageModule(languageModule);
        if(!Decl.equalModules(module, languageModule)){
            ModuleImport moduleImport = moduleManager.findImport(module, languageModule);
            if (moduleImport == null) {
                moduleImport = new ModuleImport(languageModule, false, false);
View Full Code Here

        if(annotation == null)
            return;
        List<String> values = getAnnotationStringValues(annotation, "value");
        String parentClassName = classContainerMirror.getQualifiedName();
        Package pkg = Decl.getPackageContainer(container);
        Module module = pkg.getModule();
        for(String scope : values){
            // assemble the name with the parent
            String name;
            if(scope.startsWith("::")){
                // interface pulled to toplevel
View Full Code Here

        return javaClass;
    }

    private void addInnerClassesFromMirror(ClassOrInterface klass, ClassMirror classMirror) {
        boolean isJDK = isFromJDK(classMirror);
        Module module = Decl.getModule(klass);
        for(ClassMirror innerClass : classMirror.getDirectInnerClasses()){
            // We skip members marked with @Ignore
            if(innerClass.getAnnotation(CEYLON_IGNORE_ANNOTATION) != null)
                continue;
            // We skip anonymous inner classes
View Full Code Here

           
            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();
View Full Code Here

    private ProducedType logModelResolutionException(ModelResolutionException x, Scope container, String message) {
        return logModelResolutionException(x.getMessage(), container, message);
    }
   
    private ProducedType logModelResolutionException(final String exceptionMessage, Scope container, final String message) {
        final Module module = Decl.getModuleContainer(container);
        Runnable errorReporter;
        if(module != null && !module.isDefault()){
            final StringBuilder sb = new StringBuilder();
            sb.append("Error while loading the ").append(module.getNameAsString()).append("/").append(module.getVersion());
            sb.append(" module:\n ");
            sb.append(message);
           
            if(exceptionMessage != null)
                sb.append(":\n ").append(exceptionMessage);
View Full Code Here

    }
    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

                }
            }
            klass.setCaseTypes(caseTypes);
        } else {
            String selfType = getSelfTypeFromAnnotations(classMirror);
            Module moduleScope = Decl.getModuleContainer(klass);
            if(selfType != null && !selfType.isEmpty()){
                ProducedType type = decodeType(selfType, klass, moduleScope, "self type");
                if(!(type.getDeclaration() instanceof TypeParameter)){
                    logError("Invalid type signature for self type of "+klass.getQualifiedNameString()+": "+selfType+" is not a type parameter");
                }else{
View Full Code Here

           
            params.add(param);
            i++;
        }

        Module moduleScope = Decl.getModuleContainer(scope);
        // Now all type params have been set, we can resolve the references parts
        Iterator<TypeParameter> paramsIterator = params.iterator();
        for(AnnotationMirror typeParamAnnotation : typeParameterAnnotations){
            TypeParameter param = paramsIterator.next();
           
View Full Code Here

        // make sure we don't return anything for ceylon.language
        if(name.equals(CEYLON_LANGUAGE))
            return null;
       
        // we're bootstrapping ceylon.language so we need to return the ProducedTypes straight from the model we're compiling
        Module languageModule = modules.getLanguageModule();
       
        int lastDot = name.lastIndexOf(".");
        if(lastDot == -1)
            return null;
        String pkgName = name.substring(0, lastDot);
        String simpleName = name.substring(lastDot+1);
        // Nothing is a special case with no real decl
        if(name.equals("ceylon.language.Nothing"))
            return typeFactory.getNothingDeclaration();

        // find the right package
        Package pkg = languageModule.getDirectPackage(pkgName);
        if(pkg != null){
            Declaration member = pkg.getDirectMember(simpleName, null, false);
            // if we get a value, we want its type
            if(Decl.isValue(member)
                    && ((Value)member).getTypeDeclaration().getName().equals(simpleName)){
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.model.Module

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.