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

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


        compilationUnit = typeChecker.getPhasedUnitFromRelativePath("capture/Capture.ceylon").getCompilationUnit();
        if ( compilationUnit == null ) {
            throw new RuntimeException("Failed to pass getCompilationUnitFromRelativePath for files in real src dir");
        }
        compilationUnit = typeChecker.getPhasedUnitFromRelativePath("com/redhat/sample/multisource/Boo.ceylon").getCompilationUnit();
        Module module = compilationUnit.getUnit().getPackage().getModule();
        if ( !"com.redhat.sample.multisource".equals( module.getNameAsString() ) ) {
            throw new RuntimeException("Unable to extract module name");
        }
        if ( !"0.2".equals( module.getVersion() ) ) {
            throw new RuntimeException("Unable to extract module version");
        }
        typeChecker = new TypeCheckerBuilder()
                .verbose(false)
                .addSrcDirectory( new File("test/main/capture") )
View Full Code Here


                // Check if the class is accessible according to Ceylon's access rules
                String scopePackageName = pkgSymbol(env.info.scope.owner).toString();
                Package scopePackage = modelLoader.findPackage(scopePackageName);
                // Don't check if we failed to find it
                if(scopePackage != null){
                    Module scopeModule = scopePackage.getModule();
                    // Ugly special case where we skip the test when we're compiling the language module itself
                    if (scopeModule != modelLoader.getLanguageModule()) {
                        String nameString = name.toString();
                        String importedPackageName = modelLoader.getPackageNameForQualifiedClassName(pkgName(nameString), nameString);
                        Package importedPackage = scopeModule.getPackage(importedPackageName);
                        // Don't check if we failed to find it
                        if(importedPackage == null){
                            return new ImportError(c, scopeModule);
                        }
                    }
View Full Code Here

            return null;
        }
    }

    private boolean isInCurrentModule(Object obj) {
        Module objModule = null;
        if (obj instanceof Module) {
            objModule = (Module) obj;
        } else if (obj instanceof Scope) {
            objModule = getPackage((Scope) obj).getModule();
        } else if (obj instanceof Element) {
            objModule = getPackage(((Element) obj).getScope()).getModule();
        }
       
        Module currentModule = ceylonDocTool.getCurrentModule();
        if (currentModule != null && objModule != null) {
            return currentModule.equals(objModule);
        }
       
        return false;
    }
View Full Code Here

       
        return link;
    }

    private boolean canLinkToCeylonLanguageModule() {
        Module currentModule = ceylonDocTool.getCurrentModule();
        if (currentModule.getNameAsString().equals(Module.LANGUAGE_MODULE_NAME)) {
            return true;
        } else {
            Module languageModule = currentModule.getLanguageModule();
            String languageModuleUrl = getExternalModuleUrl(languageModule);
            return languageModuleUrl != null;
        }
    }
View Full Code Here

        }
    }

    private void initModules(List<ModuleSpec> moduleSpecs) {
        for (ModuleSpec moduleSpec : moduleSpecs) {
            Module foundModule = null;
            for (Module module : typeChecker.getContext().getModules().getListOfModules()) {
                if (module.getNameAsString().equals(moduleSpec.getName())) {
                    if (!moduleSpec.isVersioned() || moduleSpec.getVersion().equals(module.getVersion()))
                        foundModule = module;
                }
View Full Code Here

        return join(".", names) + postfix + ".html";
    }

    private File getFolder(Package pkg) {
        Module module = pkg.getModule();
        List<String> unprefixedName;
        if(module.isDefault())
            unprefixedName = pkg.getName();
        else{
            // remove the leading module name part
            unprefixedName = pkg.getName().subList(module.getName().size(), pkg.getName().size());
        }
        File dir = new File(getApiOutputFolder(module), join("/", unprefixedName));
        if(shouldInclude(module))
            dir.mkdirs();
        return dir;
View Full Code Here

    protected String getObjectUrl(Object from, Object to) throws IOException {
        return getObjectUrl(from, to, true);
    }
   
    protected String getObjectUrl(Object from, Object to, boolean withFragment) throws IOException {
        Module module = getModule(from);
        URI fromUrl = getAbsoluteObjectUrl(from);
        URI toUrl = getAbsoluteObjectUrl(to);
        String result = relativize(module, fromUrl, toUrl).toString();
        if (withFragment
                && to instanceof Package
View Full Code Here

        }
        return result;
    }
   
    protected String getResourceUrl(Object from, String to) throws IOException {
        Module module = getModule(from);
        URI fromUrl = getAbsoluteObjectUrl(from);
        URI toUrl = getBaseUrl(module).resolve(".resources/" + to);
        String result = relativize(module, fromUrl, toUrl).toString();
        return result;
    }
View Full Code Here

     * package or a module without a descriptor)
     * @throws IOException
     */
    protected String getSrcUrl(Object from, Object modPkgOrDecl) throws IOException {
        URI fromUrl = getAbsoluteObjectUrl(from);
        Module module = getModule(from);
        String filename;
        File folder;
        if (modPkgOrDecl instanceof Element) {
            Unit unit = ((Element)modPkgOrDecl).getUnit();
            filename = unit.getFilename();
            folder = getFolder(unit.getPackage());
        } else if (modPkgOrDecl instanceof Package) {
            filename = "package.ceylon";
            folder = getFolder((Package)modPkgOrDecl);
        } else if (modPkgOrDecl instanceof Module) {
            Module moduleDecl = (Module)modPkgOrDecl;
            folder = getApiOutputFolder(moduleDecl);
            filename = Constants.MODULE_DESCRIPTOR;
        } else {
            throw new RuntimeException(CeylondMessages.msg("error.unexpected", modPkgOrDecl));
        }
View Full Code Here

            }
        }
    }

    private void compareDeclarations(final ModelComparison modelCompare, final Map<String, Declaration> decls, AbstractModelLoader modelLoader, Modules modules) {
        Module testModule = getTestModule(modules);
        for(Entry<String, Declaration> entry : decls.entrySet()){
            String quotedQualifiedName = entry.getKey().substring(1);
            Declaration modelDeclaration = modelLoader.getDeclaration(testModule, quotedQualifiedName,
                    Decl.isValue(entry.getValue()) ? DeclarationType.VALUE : DeclarationType.TYPE);
            Assert.assertNotNull(modelDeclaration);
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.