Search in sources :

Example 46 with Module

use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.

the class CeylonDocToolTests method bug2285.

@Test
public void bug2285() throws Exception {
    String pathname = "test/ceylondoc-doesnotexist";
    String moduleName = "org.eclipse.ceylon.ceylondoc.test.modules.bug2285";
    Module module = new Module();
    module.setName(Arrays.asList(moduleName));
    module.setVersion("1");
    try {
        CeylonDocTool tool = tool(Arrays.asList(new File(pathname)), Arrays.asList(new File("doc")), Arrays.asList(moduleName), true, false, false);
        tool.run();
        Assert.fail();
    } catch (RuntimeException x) {
        Assert.assertEquals("Can't find module: org.eclipse.ceylon.ceylondoc.test.modules.bug2285", x.getMessage());
    }
}
Also used : CeylonDocTool(org.eclipse.ceylon.ceylondoc.CeylonDocTool) Module(org.eclipse.ceylon.model.typechecker.model.Module) File(java.io.File) Test(org.junit.Test)

Example 47 with Module

use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.

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(org.eclipse.ceylon.model.typechecker.model.Module)

Example 48 with Module

use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.

the class CeylonDocToolTests method ceylonSdk.

@Test
public void ceylonSdk() throws Exception {
    Assume.assumeTrue(CompilerTests.allowSdkTests());
    File sdkDir = new File("../../ceylon-sdk");
    if (!sdkDir.exists() || !sdkDir.isDirectory()) {
        Assert.fail("You don't have ceylon-sdk checked out at " + sdkDir.getAbsolutePath() + " so this test doesn't apply");
    }
    String[] fullModuleNames = { "ceylon.buffer", "ceylon.collection", "ceylon.dbc", "ceylon.decimal", "ceylon.file", "ceylon.html", "ceylon.http.client", "ceylon.http.common", "ceylon.http.server", "ceylon.interop.browser", "ceylon.interop.java", "ceylon.io", "ceylon.json", "ceylon.locale", "ceylon.logging", "ceylon.math", "ceylon.numeric", "ceylon.process", "ceylon.promise", "ceylon.random", "ceylon.regex", "ceylon.test", "ceylon.time", "ceylon.unicode", "ceylon.uri", "ceylon.whole", "org.eclipse.ceylon.war" };
    compileSdkJavaFiles();
    CeylonDocTool tool = tool(Arrays.asList(new File("../../ceylon-sdk/source")), new String[0], null, Collections.<File>emptyList(), Arrays.asList(fullModuleNames), true, false, false);
    tool.setIncludeNonShared(false);
    tool.setIncludeSourceCode(true);
    tool.run();
    Map<String, String> nameToVersion = new HashMap<String, String>();
    for (Module module : tool.getDocumentedModules()) {
        nameToVersion.put(module.getNameAsString(), module.getVersion());
    }
    for (String moduleName : fullModuleNames) {
        File destDir = getOutputDir(tool, moduleName, nameToVersion.get(moduleName));
        assertFileExists(destDir, "index.html");
    }
}
Also used : CeylonDocTool(org.eclipse.ceylon.ceylondoc.CeylonDocTool) HashMap(java.util.HashMap) Module(org.eclipse.ceylon.model.typechecker.model.Module) File(java.io.File) Test(org.junit.Test)

Example 49 with Module

use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.

the class AbstractModelLoader method addLocalDeclarations.

private void addLocalDeclarations(LocalDeclarationContainer container, ClassMirror classContainerMirror, AnnotatedMirror annotatedMirror) {
    if (!needsLocalDeclarations())
        return;
    AnnotationMirror annotation = annotatedMirror.getAnnotation(CEYLON_LOCAL_DECLARATIONS_ANNOTATION);
    if (annotation == null)
        return;
    List<String> values = getAnnotationStringValues(annotation, "value");
    String parentClassName = classContainerMirror.getQualifiedName();
    Package pkg = ModelUtil.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
            name = pkg.getNameAsString() + "." + scope.substring(2);
        } else {
            name = parentClassName;
            name += "$" + scope;
        }
        Declaration innerDecl = convertToDeclaration(module, (Declaration) container, name, DeclarationType.TYPE);
        if (innerDecl == null)
            throw new ModelResolutionException("Failed to load local type " + name + " for outer type " + container.getQualifiedNameString());
    }
}
Also used : AnnotationMirror(org.eclipse.ceylon.model.loader.mirror.AnnotationMirror) LazyPackage(org.eclipse.ceylon.model.loader.model.LazyPackage) Package(org.eclipse.ceylon.model.typechecker.model.Package) TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) Declaration(org.eclipse.ceylon.model.typechecker.model.Declaration) Module(org.eclipse.ceylon.model.typechecker.model.Module) LazyModule(org.eclipse.ceylon.model.loader.model.LazyModule)

Example 50 with Module

use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.

the class AbstractModelLoader method findModuleForFile.

public Module findModuleForFile(File file) {
    File path = file.getParentFile();
    while (path != null) {
        String name = path.getPath().replaceAll("[\\\\/]", ".");
        // FIXME: this would load any version of this module
        Module m = getLoadedModule(name, null);
        if (m != null) {
            return m;
        }
        path = path.getParentFile();
    }
    return modules.getDefaultModule();
}
Also used : Module(org.eclipse.ceylon.model.typechecker.model.Module) LazyModule(org.eclipse.ceylon.model.loader.model.LazyModule) File(java.io.File)

Aggregations

Module (org.eclipse.ceylon.model.typechecker.model.Module)113 LazyModule (org.eclipse.ceylon.model.loader.model.LazyModule)37 Package (org.eclipse.ceylon.model.typechecker.model.Package)26 ModuleImport (org.eclipse.ceylon.model.typechecker.model.ModuleImport)25 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)20 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)19 ArrayList (java.util.ArrayList)18 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)16 File (java.io.File)14 Type (org.eclipse.ceylon.model.typechecker.model.Type)14 HashMap (java.util.HashMap)9 HashSet (java.util.HashSet)9 FunctionalInterfaceType (org.eclipse.ceylon.model.loader.mirror.FunctionalInterfaceType)9 UnknownType (org.eclipse.ceylon.model.typechecker.model.UnknownType)9 Test (org.junit.Test)9 Value (org.eclipse.ceylon.model.typechecker.model.Value)8 LinkedList (java.util.LinkedList)7 List (java.util.List)7 Backends (org.eclipse.ceylon.common.Backends)7 ClassMirror (org.eclipse.ceylon.model.loader.mirror.ClassMirror)7