use of com.redhat.ceylon.compiler.typechecker.io.VFS in project ceylon-compiler by ceylon.
the class ModelLoaderTests method getLatestZippedLanguageSourceFile.
private static final ClosableVirtualFile getLatestZippedLanguageSourceFile() {
VFS vfs = new VFS();
File langDir = new File("../ceylon-dist/dist/repo/ceylon/language");
if (!langDir.exists()) {
System.err.println("Unable to test language module, not found in repository: " + langDir);
System.exit(-1);
}
String[] versions = langDir.list();
Arrays.sort(versions);
// last
String version = versions[versions.length - 1];
return vfs.getFromZipFile(new File(langDir, version + "/ceylon.language-" + version + ".src"));
}
use of com.redhat.ceylon.compiler.typechecker.io.VFS in project ceylon-compiler by ceylon.
the class ModelLoaderTests method verifyRuntimeClassLoading.
protected void verifyRuntimeClassLoading(RunnableTest test) {
RepositoryManager repoManager = CeylonUtils.repoManager().buildManager();
VFS vfs = new VFS();
com.redhat.ceylon.compiler.typechecker.context.Context context = new com.redhat.ceylon.compiler.typechecker.context.Context(repoManager, vfs);
RuntimeModuleManager moduleManager = new RuntimeModuleManager();
context.setModules(new Modules());
moduleManager.initCoreModules(new Modules());
moduleManager.loadModule(AbstractModelLoader.CEYLON_LANGUAGE, Versions.CEYLON_VERSION_NUMBER, repoManager.getArtifactResult("ceylon.language", Versions.CEYLON_VERSION_NUMBER), getClass().getClassLoader());
RuntimeModelLoader modelLoader = moduleManager.getModelLoader();
modelLoader.setupWithNoStandardModules();
modelLoader.loadStandardModules();
test.test(modelLoader);
}
use of com.redhat.ceylon.compiler.typechecker.io.VFS in project ceylon-compiler by ceylon.
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 com.redhat.ceylon.compiler.typechecker.io.VFS in project ceylon-compiler by ceylon.
the class LanguageCompiler method getCeylonContextInstance.
/**
* Get the Ceylon context instance for this context.
*/
public static com.redhat.ceylon.compiler.typechecker.context.Context getCeylonContextInstance(Context context) {
com.redhat.ceylon.compiler.typechecker.context.Context ceylonContext = context.get(ceylonContextKey);
if (ceylonContext == null) {
CeyloncFileManager fileManager = (CeyloncFileManager) context.get(JavaFileManager.class);
VFS vfs = new VFS();
ceylonContext = new com.redhat.ceylon.compiler.typechecker.context.Context(fileManager.getRepositoryManager(), vfs);
context.put(ceylonContextKey, ceylonContext);
}
return ceylonContext;
}
Aggregations