Search in sources :

Example 11 with Module

use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.

the class CeylonVersionTool method run.

@Override
public void run() throws IOException, RecognitionException {
    // TODO if version is empty? Prompt? Or should --set have an optional argument? 
    TypeCheckerBuilder tcb = new TypeCheckerBuilder();
    for (File path : this.sourceFolders) {
        tcb.addSrcDirectory(applyCwd(path));
    }
    TypeChecker tc = tcb.getTypeChecker();
    PhasedUnits pus = tc.getPhasedUnits();
    pus.visitModules();
    ArrayList<Module> moduleList = new ArrayList<Module>(pus.getModuleSourceMapper().getCompiledModules());
    Collections.sort(moduleList, new Comparator<Module>() {

        @Override
        public int compare(Module m1, Module m2) {
            if (match(m1) && !match(m2)) {
                return -1;
            } else if (!match(m1) && match(m2)) {
                return +1;
            }
            int cmp = m1.getNameAsString().compareToIgnoreCase(m2.getNameAsString());
            if (cmp == 0) {
                cmp = m1.getVersion().compareTo(m2.getVersion());
            }
            return cmp;
        }
    });
    // first update all module versions and remember which version we assigned to which module
    // because the user can update every individual version
    Map<String, String> updatedModuleVersions = new HashMap<String, String>();
    for (Module module : moduleList) {
        boolean isMatch = match(module);
        if (newVersion == null) {
            output(module, isMatch);
        } else if (isMatch) {
            if (!updateModuleVersion(module, updatedModuleVersions)) {
                return;
            }
        }
    }
    // now do dependencies because we know which modules we did update
    if (newVersion != null && !noUpdateDependencies) {
        for (Module module : moduleList) {
            if (!updateModuleImports(module, updatedModuleVersions)) {
                return;
            }
        }
    }
}
Also used : TypeChecker(com.redhat.ceylon.compiler.typechecker.TypeChecker) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TypeCheckerBuilder(com.redhat.ceylon.compiler.typechecker.TypeCheckerBuilder) PhasedUnits(com.redhat.ceylon.compiler.typechecker.context.PhasedUnits) ImportModule(com.redhat.ceylon.compiler.typechecker.tree.Tree.ImportModule) Module(com.redhat.ceylon.model.typechecker.model.Module) File(java.io.File)

Example 12 with Module

use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.

the class CeylonDocToolTests method moduleA.

private void moduleA(boolean includeNonShared) throws Exception {
    String pathname = "test/ceylondoc";
    String docname = "test/ceylondoc-doc";
    String moduleName = "com.redhat.ceylon.ceylondoc.test.modules.single";
    CeylonDocTool tool = tool(pathname, docname, moduleName, true, false);
    tool.setIncludeNonShared(includeNonShared);
    tool.setIncludeSourceCode(true);
    tool.setHeader("<div class='navbar-inverse navbar-static-top'>" + "<div class='navbar-inner' style='color:white; font-style: italic; text-align: center'>" + "documentation under construction" + "</div>" + "</div>");
    tool.setFooter("<p style='text-align: right;'>" + "Copyright © 2010-2013, Red Hat, Inc. or third-party contributors" + "</p>");
    tool.run();
    Module module = new Module();
    module.setName(Arrays.asList(moduleName));
    module.setVersion("3.1.4");
    File destDir = getOutputDir(tool, module);
    assertFileExists(destDir, includeNonShared);
    assertBasicContent(destDir, includeNonShared);
    assertConstructors(destDir, includeNonShared);
    assertBy(destDir);
    assertLicense(destDir);
    assertParametersDocumentation(destDir);
    assertParametersAssertions(destDir);
    assertParametersLinks(destDir);
    assertThrows(destDir);
    assertSee(destDir);
    assertIcons(destDir);
    assertInnerTypesDoc(destDir);
    assertDeprecated(destDir);
    assertTagged(destDir);
    assertDocumentationOfRefinedMember(destDir);
    assertSequencedParameter(destDir);
    assertCallableParameter(destDir);
    assertTupleParameter(destDir);
    assertDefaultedParametres(destDir);
    assertAnythingReturnType(destDir);
    assertFencedCodeBlockWithSyntaxHighlighter(destDir);
    assertWikiStyleLinkSyntax(destDir, includeNonShared);
    assertConstants(destDir);
    assertLinksToRefinedDeclaration(destDir);
    assertGenericTypeParams(destDir);
    assertObjectPageDifferences(destDir);
    assertSharedParameterOfClass(destDir);
    assertAliases(destDir);
    assertPackageNavigation(destDir);
    assertSubpackages(destDir);
    assertAnnotations(destDir);
    assertAbstractClassModifier(destDir);
    assertFinalClassModifier(destDir);
    assertHeaderAndFooter(destDir);
    assertExceptions(destDir);
    assertNameAliases(destDir);
    assertBug659ShowInheritedMembers(destDir);
    assertBug691AbbreviatedOptionalType(destDir);
    assertBug839(destDir);
    assertBug927LoadingAndSortingInheritedMembers(destDir);
    assertBug968(destDir);
    assertBug1619BrokenLinkFromInheritedDoc(destDir);
    assertBug1619BrokenLinkWithNewLine(destDir);
    assertBug2307AliasedName(destDir);
}
Also used : CeylonDocTool(com.redhat.ceylon.ceylondoc.CeylonDocTool) Module(com.redhat.ceylon.model.typechecker.model.Module) File(java.io.File)

Example 13 with Module

use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.

the class CeylonDocToolTests method externalLinks.

private File externalLinks(String repoUrl, String... linkArgs) throws Exception {
    compile("test/ceylondoc", "com.redhat.ceylon.ceylondoc.test.modules.dependency.b");
    compile("test/ceylondoc", "com.redhat.ceylon.ceylondoc.test.modules.dependency.c");
    List<String> modules = new ArrayList<String>();
    modules.add("com.redhat.ceylon.ceylondoc.test.modules.dependency.b");
    modules.add("com.redhat.ceylon.ceylondoc.test.modules.dependency.c");
    modules.add("com.redhat.ceylon.ceylondoc.test.modules.externallinks");
    CeylonDocTool tool = tool(Arrays.asList(new File("test/ceylondoc")), Collections.<File>emptyList(), modules, true, true, false, "build/ceylon-cars");
    tool.setLinks(Arrays.asList(linkArgs));
    tool.run();
    Module module = new Module();
    module.setName(Arrays.asList("com.redhat.ceylon.ceylondoc.test.modules.externallinks"));
    module.setVersion("1.0");
    File destDir = getOutputDir(tool, module);
    assertExternalLinks(destDir, repoUrl);
    return destDir;
}
Also used : CeylonDocTool(com.redhat.ceylon.ceylondoc.CeylonDocTool) ArrayList(java.util.ArrayList) Module(com.redhat.ceylon.model.typechecker.model.Module) File(java.io.File)

Example 14 with Module

use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.

the class CeylonDocToolTests method makeDefaultModule.

private Module makeDefaultModule() {
    Module module = new Module();
    module.setName(Arrays.asList(Module.DEFAULT_MODULE_NAME));
    module.setDefault(true);
    return module;
}
Also used : Module(com.redhat.ceylon.model.typechecker.model.Module)

Example 15 with Module

use of com.redhat.ceylon.model.typechecker.model.Module in project ceylon-compiler by ceylon.

the class CeylonDocToolTests method documentDefaultModule.

@Test
public void documentDefaultModule() throws Exception {
    String pathname = "test/ceylondoc";
    String moduleName = "default";
    CeylonDocTool tool = tool(pathname, moduleName, true, "build/ceylon-cars");
    tool.setIncludeNonShared(true);
    tool.run();
    Module a = makeModule("com.redhat.ceylon.ceylondoc.test.modules.multi.a", "1");
    File destDirA = getOutputDir(tool, a);
    Module b = makeModule("com.redhat.ceylon.ceylondoc.test.modules.multi.b", "1");
    File destDirB = getOutputDir(tool, b);
    Module def = makeDefaultModule();
    File destDirDef = getOutputDir(tool, def);
    assertFileNotExists(destDirA, "index.html");
    assertFileNotExists(destDirB, "index.html");
    assertFileExists(destDirDef, "index.html");
    assertFileExists(destDirDef, "com/redhat/ceylon/ceylondoc/test/modules/multi/goes/into/bar.object.html");
    assertFileExists(destDirDef, "com/redhat/ceylon/ceylondoc/test/modules/multi/goes/into/defaultmodule/foo.object.html");
}
Also used : CeylonDocTool(com.redhat.ceylon.ceylondoc.CeylonDocTool) Module(com.redhat.ceylon.model.typechecker.model.Module) File(java.io.File) Test(org.junit.Test)

Aggregations

Module (com.redhat.ceylon.model.typechecker.model.Module)50 Package (com.redhat.ceylon.model.typechecker.model.Package)16 File (java.io.File)14 Test (org.junit.Test)12 TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)10 CeylonDocTool (com.redhat.ceylon.ceylondoc.CeylonDocTool)9 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)9 ArrayList (java.util.ArrayList)6 ClassOrInterface (com.redhat.ceylon.model.typechecker.model.ClassOrInterface)5 ModuleImport (com.redhat.ceylon.model.typechecker.model.ModuleImport)5 ImportModule (com.redhat.ceylon.compiler.typechecker.tree.Tree.ImportModule)4 Class (com.redhat.ceylon.model.typechecker.model.Class)4 TypedDeclaration (com.redhat.ceylon.model.typechecker.model.TypedDeclaration)4 ErrorCollector (com.redhat.ceylon.compiler.java.test.ErrorCollector)3 CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)3 PhasedUnit (com.redhat.ceylon.compiler.typechecker.context.PhasedUnit)3 LazyModule (com.redhat.ceylon.model.loader.model.LazyModule)3 Function (com.redhat.ceylon.model.typechecker.model.Function)3 FunctionOrValue (com.redhat.ceylon.model.typechecker.model.FunctionOrValue)3 Type (com.redhat.ceylon.model.typechecker.model.Type)3