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

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


    }
   
    @Override
    public void visit(Tree.ModuleLiteral that) {
        super.visit(that);
        Module m;
        if (that.getImportPath()==null) {
            that.setImportPath(new ImportPath(null));
            m = unit.getPackage().getModule();
        }
        else {
View Full Code Here


    }


    private static boolean checkModuleVisibility(Declaration member, ProducedType pt) {
        if (inExportedScope(member)) {
            Module declarationModule = getModule(member);
            if (declarationModule!=null) {
                return isCompletelyVisibleFromOtherModules(member,pt,declarationModule);
            }
        }
        return true;
View Full Code Here

        // type parameters are OK
        if (type instanceof TypeParameter) {
            return true;
        }
       
        Module typeModule = getModule(type);
        if (typeModule!=null && thisModule!=null &&
                thisModule!=typeModule) {
            // find the module import, but only in exported imports, otherwise it's an error anyways

            // language module stuff is automagically exported
View Full Code Here

            final Package emptyPackage = createPackage("", null);
            packageStack.addLast(emptyPackage);

            //build default module (module in which packages belong to when not explicitly under a module
            final List<String> defaultModuleName = Collections.singletonList(Module.DEFAULT_MODULE_NAME);
            final Module defaultModule = createModule(defaultModuleName, "unversioned");
            defaultModule.setDefault(true);
            defaultModule.setAvailable(true);
            bindPackageToModule(emptyPackage, defaultModule);
            modules.getListOfModules().add(defaultModule);
            modules.setDefaultModule(defaultModule);

            //create language module and add it as a dependency of defaultModule
            //since packages outside a module cannot declare dependencies
            final List<String> languageName = Arrays.asList("ceylon", "language");
            Module languageModule = createModule(languageName, TypeChecker.LANGUAGE_MODULE_VERSION);
            languageModule.setLanguageModule(languageModule);
            languageModule.setAvailable(false); //not available yet
            modules.setLanguageModule(languageModule);
            modules.getListOfModules().add(languageModule);
            defaultModule.addImport(new ModuleImport(languageModule, false, false));
            defaultModule.setLanguageModule(languageModule);
        }
View Full Code Here

            packageStack.addLast( modules.getDefaultModule().getPackages().get(0) );
        }
    }

    protected Module createModule(List<String> moduleName, String version) {
    Module module = new Module();
    module.setName(moduleName);
    module.setVersion(version);
    return module;
  }
View Full Code Here

     */
    public Module getOrCreateModule(List<String> moduleName, String version) {
        if (moduleName.size() == 0) {
            return null;
        }
        Module module = null;
        final Set<Module> moduleList = context.getModules().getListOfModules();
        for (Module current : moduleList) {
            final List<String> names = current.getName();
            if (moduleName.equals(names)
                    && compareVersions(current, version, current.getVersion())) {
                module = current;
                break;
            }
        }
        if (module == null) {
            module = createModule(moduleName, version);
            module.setLanguageModule(modules.getLanguageModule());
            moduleList.add(module);
        }
        return module;
    }
View Full Code Here

        if (!attachErrorToDependencyDeclaration(moduleImport, error)) {
            //This probably can happen if the missing dependency is found deep in the dependency structure (ie the binary version of a module)
            // in theory the first item in the dependency tree is the compiled module, and the second one is the import we have to add
            // the error to
            if(dependencyTree.size() >= 2){
                Module rootModule = dependencyTree.get(0);
                Module originalImportedModule = dependencyTree.get(1);
                // find the original import
                for(ModuleImport imp : rootModule.getImports()){
                    if(imp.getModule() == originalImportedModule){
                        // found it, try to attach the error
                        if(attachErrorToDependencyDeclaration(imp, error)){
View Full Code Here

                if (that.getImportPath()!=null) {
                    node.addError("the language module is imported implicitly");
                }
            }
            else {
                Module importedModule = moduleManager.getOrCreateModule(name,version);
                if (that.getImportPath()!=null) {
                  that.getImportPath().setModel(importedModule);
                }
                if (!completeOnlyAST) {
                    if (mainModule != null) {
                        if (importedModule.getVersion() == null) {
                            importedModule.setVersion(version);
                        }
                        ModuleImport moduleImport = moduleManager.findImport(mainModule, importedModule);
                        if (moduleImport == null) {
                            Tree.AnnotationList al = that.getAnnotationList();
                            boolean optional = hasAnnotation(al, "optional", unit.getUnit());
View Full Code Here

    }
   
    public static Module getModule(Tree.ImportPath path) {
        if (path!=null && !path.getIdentifiers().isEmpty()) {
            String nameToImport = formatPath(path.getIdentifiers());
            Module module = path.getUnit().getPackage().getModule();
            Package pkg = module.getPackage(nameToImport);
            if (pkg != null) {
                Module mod = pkg.getModule();
                if (!pkg.getNameAsString().equals(mod.getNameAsString())) {
                    path.addError("not a module: '" + nameToImport + "'");
                    return null;
                }
                if (mod.equals(module)) {
                    return mod;
                }
                //check that the package really does belong to
                //an imported module, to work around bug where
                //default package thinks it can see stuff in
View Full Code Here

    }
   
    public static Package getPackage(Tree.ImportPath path) {
        if (path!=null && !path.getIdentifiers().isEmpty()) {
            String nameToImport = formatPath(path.getIdentifiers());
            Module module = path.getUnit().getPackage().getModule();
            Package pkg = module.getPackage(nameToImport);
            if (pkg != null) {
                if (pkg.getModule().equals(module)) {
                    return pkg;
                }
                if (!pkg.isShared()) {
                    path.addError("imported package is not shared: '" +
                            nameToImport + "'");
                }
//                if (module.isDefault() &&
//                        !pkg.getModule().isDefault() &&
//                        !pkg.getModule().getNameAsString()
//                            .equals(Module.LANGUAGE_MODULE_NAME)) {
//                    path.addError("package belongs to a module and may not be imported by default module: " +
//                            nameToImport);
//                }
                //check that the package really does belong to
                //an imported module, to work around bug where
                //default package thinks it can see stuff in
                //all modules in the same source dir
                Set<Module> visited = new HashSet<Module>();
                for (ModuleImport mi: module.getImports()) {
                    if (findModuleInTransitiveImports(mi.getModule(),
                            pkg.getModule(), visited)) {
                        return pkg;
                    }
                }
            }
            String help;
            if(module.isDefault())
                help = " (define a module and add module import to its module descriptor)";
            else
                help = " (add module import to module descriptor of '" +
                        module.getNameAsString() + "')";
            path.addError("package not found in imported modules: '" +
                    nameToImport + "'" + help, 7000);
        }
        return null;
    }
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.