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

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


    /** Tells whether a declaration is in the specified package. */
    boolean isImported(final Package p2, final Declaration d) {
        if (d == null) {
            return false;
        }
        Package p1 = d.getUnit().getPackage();
        if (p2 == null)return p1 != null;
        if (p1.getModule()== null)return p2.getModule()!=null;
        return !p1.getModule().equals(p2.getModule());
    }
View Full Code Here


    @Override
    public Package getPackage(String name) {
        if ("default".equals(name)) {
            name = "";
        }
        Package p = getDirectPackage(name);
        if (p != null) {
            return p;
        }
        for (ModuleImport imp : getImports()) {
            final Module mod = imp.getModule();
View Full Code Here

                base = that.getScope().getMemberOrParameter(that.getUnit(),
                    names[0], null, false);
            }
        }
        else {
            Package pack = that.getUnit().getPackage().getModule().getPackage(packageName);
            if (pack == null) {
                if (DOC_LINK_MODULE.equals(kind)) {
                    that.addUsageWarning(Warning.doclink,
                                "module does not exist: '" + packageName + "'");
                } else {
                    that.addUsageWarning(Warning.doclink,
                                "package does not exist: '" + packageName + "'");
                }
            }
            else {
                that.setPkg(pack);
                if (DOC_LINK_MODULE.equals(kind)) {
                    Package rootPack = pack.getModule().getRootPackage();
                    if (pack.equals(rootPack)) {
                        that.setModule(pack.getModule());
                    } else {
                        that.addUsageWarning(Warning.doclink,
                                    "module does not exist: '" + packageName + "'");
View Full Code Here

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

    }
   
    private boolean checkModuleFilters(boolean definesModule) {
        if(moduleFilters == null || moduleFilters.isEmpty())
            return true;
        Package pkg = moduleManager.getCurrentPackage();
        String pkgName = pkg.getNameAsString();
        /*
            ; filter example syntax:
            module-list+ (wanted-modules+) -> allowed-paths*
       
            ; Filter unwanted modules
            a, a.b, aa, b (a) -> a, a.b
       
            ; Filter unwanted longer-named modules
            a.b.c, a.b.d (a.b) ->
       
            ; Allow going to the module we're looking for
            a, a.b, a.b.c (a.b.c) -> a, a.b, a.b.c
       
            ; Allow any package in the default module
            a, b, c (default) -> a, b, c
        */
        for(String module : moduleFilters){
            // Are we looking for the default module?
            if(module.equals(Module.DEFAULT_MODULE_NAME)){
                // Allow anything for the default module if it's not owned by another module
                // and we're not defining a new module.
                if(pkg.getModule().isDefault() && !definesModule){
                    return true;
                }
                // None of the other rules apply to the default module.
                continue;
            }
            // Allow module folder.
            // We don't check for the presence of a module declaration here, we asked for this module so
            // if we're not defining it we will just have to deal with the error elsewhere (its absence).
            if(pkgName.equals(module)){
                return true;
            }
            // Allow sub-packages, but only if they are actually contained by the module itself
            // and not accidental modules with longer names.
            // We don't check for the presence of a module declaration here since that will generate
            // an error later because a module can't contain another module
            if(pkgName.startsWith(module + ".") && pkg.getModule().getNameAsString().equals(module)){
                return true;
            }
            // Allow the path that leads to the modules we're looking for, as long as they are in the default module
            // and we're not defining a new module
            if(module.startsWith(pkgName + ".") && pkg.getModule().isDefault() && !definesModule){
                return true;
            }
        }
        return false;
    }
View Full Code Here

    private static boolean inExportedScope(Declaration decl) {
        // if it has a visible scope it's not exported outside the module
        if(decl.getVisibleScope() != null)
            return false;
        // now perhaps its package is not shared
        Package p = decl.getUnit().getPackage();
        return p != null && p.isShared();
    }
View Full Code Here

        }
        return false;
    }
   
    private static Module getModule(Element element){
        Package typePackage = element.getUnit().getPackage();
        return typePackage != null ? typePackage.getModule() : null;
    }
View Full Code Here

    public ModuleManager(Context context) {
        this.context = context;
    }
   
    protected Package createPackage(String pkgName, Module module) {
        final Package pkg = new Package();
        List<String> name = pkgName.isEmpty() ? Arrays.asList("") : splitModuleName(pkgName);
        pkg.setName(name);
        if (module != null) {
            module.getPackages().add(pkg);
            pkg.setModule(module);
        }
        return pkg;
    }
View Full Code Here

        modules = context.getModules();
        if ( modules == null ) {
            modules = new Modules();
            context.setModules(modules);
            //build empty package
            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");
View Full Code Here

        return currentVersion == null || version == null || currentVersion.equals(version);
    }

    public void visitModuleFile() {
        if ( currentModule == null ) {
            final Package currentPkg = packageStack.peekLast();
            final List<String> moduleName = currentPkg.getName();
            //we don't know the version at this stage, will be filled later
            currentModule = getOrCreateModule(moduleName, null);
            if ( currentModule != null ) {
                currentModule.setAvailable(true); // TODO : not necessary anymore ? the phasedUnit will be added. And the buildModuleImport()
                                                  //        function (which calls module.setAvailable()) will be called by the typeChecker
View Full Code Here

TOP

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

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.