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();
}
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;
}
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));
}
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");
}
}
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);
}
Aggregations