use of org.eclipse.ceylon.compiler.typechecker.io.VFS in project ceylon by eclipse.
the class ModuleComplianceVisitor method main.
public static void main(String[] args) throws IOException {
System.out.println("Finding JS language module...");
File jsmod = findModule("build/runtime", "js");
if (jsmod == null && System.getenv("ceylon.repo") != null) {
jsmod = findModule(System.getenv("ceylon.repo"), "js");
}
if (jsmod == null && System.getProperty("user.home") != null) {
jsmod = findModule(System.getProperty("user.home"), "js");
}
if (jsmod == null) {
throw new IllegalStateException("Cannot find JS language module");
}
System.out.println("Finding Ceylon Language Module");
File mod = findModule("../language/build/dist", "src");
if (mod == null && System.getenv("ceylon.repo") != null) {
mod = findModule(System.getenv("ceylon.repo"), "src");
}
if (mod == null && System.getProperty("user.home") != null) {
mod = findModule(System.getProperty("user.home"), "src");
}
if (mod == null) {
throw new IllegalStateException("Cannot find JVM language module");
}
System.out.println("Reading JS language module into memory...");
FileReader reader = new FileReader(jsmod);
char[] buf = new char[16384];
StringWriter writer = new StringWriter();
while (reader.ready()) {
reader.read(buf);
writer.write(buf);
}
reader.close();
ModuleComplianceVisitor v = new ModuleComplianceVisitor(writer.toString());
System.out.println("Checking Ceylon vs JS modules...");
VFS vfs = new VFS();
TypeChecker tc = new TypeCheckerBuilder().verbose(false).addSrcDirectory(vfs.getFromZipFile(mod)).getTypeChecker();
tc.process();
for (PhasedUnit pu : tc.getPhasedUnits().getPhasedUnits()) {
pu.getCompilationUnit().visit(v);
}
}
use of org.eclipse.ceylon.compiler.typechecker.io.VFS 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.compiler.typechecker.io.VFS in project ceylon by eclipse.
the class ModelLoaderTests method verifyRuntimeClassLoading.
protected void verifyRuntimeClassLoading(RunnableTest test) {
RepositoryManager repoManager = CeylonUtils.repoManager().systemRepo(getSysRepPath()).buildManager();
VFS vfs = new VFS();
org.eclipse.ceylon.compiler.typechecker.context.Context context = new org.eclipse.ceylon.compiler.typechecker.context.Context(repoManager, vfs);
RuntimeModuleManager moduleManager = new RuntimeModuleManager(null);
context.setModules(new Modules());
moduleManager.initCoreModules(new Modules());
moduleManager.loadModule(AbstractModelLoader.CEYLON_LANGUAGE, Versions.CEYLON_VERSION_NUMBER, repoManager.getArtifactResult(null, "ceylon.language", Versions.CEYLON_VERSION_NUMBER), getClass().getClassLoader());
RuntimeModelLoader modelLoader = moduleManager.getModelLoader();
modelLoader.setupWithNoStandardModules();
modelLoader.loadStandardModules();
test.test(modelLoader);
}
use of org.eclipse.ceylon.compiler.typechecker.io.VFS in project ceylon by eclipse.
the class LanguageCompiler method getCeylonContextInstance.
/**
* Get the Ceylon context instance for this context.
*/
public static org.eclipse.ceylon.compiler.typechecker.context.Context getCeylonContextInstance(Context context) {
org.eclipse.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 org.eclipse.ceylon.compiler.typechecker.context.Context(fileManager.getRepositoryManager(), vfs);
context.put(ceylonContextKey, ceylonContext);
}
return ceylonContext;
}
use of org.eclipse.ceylon.compiler.typechecker.io.VFS in project ceylon by eclipse.
the class MainHelper method getLatestZippedLanguageSourceFile.
public static final ClosableVirtualFile getLatestZippedLanguageSourceFile() {
VFS vfs = new VFS();
File langDir = new File("../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"));
}
Aggregations