Search in sources :

Example 1 with RepositoryManagerBuilder

use of org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder in project ceylon by eclipse.

the class NamingTests method getDecls.

protected List<Declaration> getDecls(String resource) throws Exception {
    final String name = PKGNAME.replace('.', '/') + "/" + resource;
    File file = new File("test/src", name);
    if (!file.exists()) {
        throw new RuntimeException("Unable to find resource " + name);
    }
    RepositoryManagerBuilder builder = new RepositoryManagerBuilder(new NullLogger(), false, 20000, java.net.Proxy.NO_PROXY);
    RepositoryManager repoManager = builder.buildRepository();
    VFS vfs = new VFS();
    Context context = new Context(repoManager, vfs);
    PhasedUnits pus = new PhasedUnits(context);
    // Make the module manager think we're looking at this package
    // even though there's no module descriptor
    pus.getModuleSourceMapper().push(PKGNAME);
    pus.parseUnit(vfs.getFromFile(file), vfs.getFromFile(new File("test-src")));
    final java.util.List<PhasedUnit> listOfUnits = pus.getPhasedUnits();
    PhasedUnit pu = listOfUnits.get(0);
    pu.validateTree();
    pu.scanDeclarations();
    pu.scanTypeDeclarations();
    pu.validateRefinement();
    pu.analyseTypes();
    pu.analyseFlow();
    return pu.getDeclarations();
}
Also used : Context(org.eclipse.ceylon.compiler.typechecker.context.Context) VFS(org.eclipse.ceylon.compiler.typechecker.io.VFS) RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder) PhasedUnits(org.eclipse.ceylon.compiler.typechecker.context.PhasedUnits) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) File(java.io.File) PhasedUnit(org.eclipse.ceylon.compiler.typechecker.context.PhasedUnit)

Example 2 with RepositoryManagerBuilder

use of org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder in project ceylon by eclipse.

the class AbstractTest method getRepositoryManagerBuilder.

protected RepositoryManagerBuilder getRepositoryManagerBuilder(File root, boolean offline, int timeout, Proxy proxy, String overrideFileName) throws Exception {
    RepositoryManagerBuilder builder = new RepositoryManagerBuilder(temp.toFile(), log, offline, timeout, proxy, RepositoryManagerBuilder.parseOverrides(overrideFileName));
    builder.addRepository(new DefaultRepository(new FileContentStore(root).createRoot()));
    return builder;
}
Also used : RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder) DefaultRepository(org.eclipse.ceylon.cmr.impl.DefaultRepository) FileContentStore(org.eclipse.ceylon.cmr.impl.FileContentStore)

Example 3 with RepositoryManagerBuilder

use of org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder in project ceylon by eclipse.

the class BuilderTestCase method assertBuilder.

private void assertBuilder(RepositoryManagerBuilder builder, Class<? extends RepositoryManagerBuilder> expectedType) throws Exception {
    RepositoryManagerBuilder delegate = getDelegate(builder);
    Assert.assertTrue(expectedType.isInstance(delegate));
}
Also used : RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder)

Example 4 with RepositoryManagerBuilder

use of org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder in project ceylon by eclipse.

the class BuilderTestCase method testNotAnInstance.

@Test(expected = Exception.class)
public void testNotAnInstance() throws Exception {
    try {
        // invalid name
        System.setProperty("ceylon.module.resolver.builder", BuilderTestCase.class.getName());
        RepositoryManagerBuilder builder = getRepositoryManagerBuilder(false, 60000, java.net.Proxy.NO_PROXY);
        assertBuilder(builder, RepositoryManagerBuilderImpl.class);
    } finally {
        System.clearProperty("ceylon.module.resolver.builder");
    }
}
Also used : RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder) Test(org.junit.Test)

Example 5 with RepositoryManagerBuilder

use of org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder in project ceylon by eclipse.

the class BuilderTestCase method getDelegate.

private RepositoryManagerBuilder getDelegate(RepositoryManagerBuilder builder) throws Exception {
    Assert.assertNotNull(builder);
    Field f = builder.getClass().getDeclaredField("delegate");
    f.setAccessible(true);
    return (RepositoryManagerBuilder) f.get(builder);
}
Also used : Field(java.lang.reflect.Field) RepositoryManagerBuilder(org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder)

Aggregations

RepositoryManagerBuilder (org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder)17 Test (org.junit.Test)10 File (java.io.File)8 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)8 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)8 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)6 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)5 DefaultRepository (org.eclipse.ceylon.cmr.impl.DefaultRepository)5 URL (java.net.URL)2 RemoteContentStore (org.eclipse.ceylon.cmr.impl.RemoteContentStore)2 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)2 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 ModuleSearchResult (org.eclipse.ceylon.cmr.api.ModuleSearchResult)1 RepositoryBuilder (org.eclipse.ceylon.cmr.api.RepositoryBuilder)1 CMRJULLogger (org.eclipse.ceylon.cmr.impl.CMRJULLogger)1 FileContentStore (org.eclipse.ceylon.cmr.impl.FileContentStore)1