Search in sources :

Example 1 with VFS

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"));
}
Also used : VFS(com.redhat.ceylon.compiler.typechecker.io.VFS) ClosableVirtualFile(com.redhat.ceylon.compiler.typechecker.io.ClosableVirtualFile) File(java.io.File)

Example 2 with VFS

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);
}
Also used : Context(com.sun.tools.javac.util.Context) VFS(com.redhat.ceylon.compiler.typechecker.io.VFS) RuntimeModuleManager(com.redhat.ceylon.compiler.java.runtime.model.RuntimeModuleManager) Modules(com.redhat.ceylon.model.typechecker.model.Modules) RuntimeModelLoader(com.redhat.ceylon.compiler.java.runtime.model.RuntimeModelLoader) RepositoryManager(com.redhat.ceylon.cmr.api.RepositoryManager)

Example 3 with VFS

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();
}
Also used : Context(com.redhat.ceylon.compiler.typechecker.context.Context) VFS(com.redhat.ceylon.compiler.typechecker.io.VFS) RepositoryManagerBuilder(com.redhat.ceylon.cmr.api.RepositoryManagerBuilder) PhasedUnits(com.redhat.ceylon.compiler.typechecker.context.PhasedUnits) RepositoryManager(com.redhat.ceylon.cmr.api.RepositoryManager) File(java.io.File) PhasedUnit(com.redhat.ceylon.compiler.typechecker.context.PhasedUnit)

Example 4 with VFS

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;
}
Also used : VFS(com.redhat.ceylon.compiler.typechecker.io.VFS) JavaFileManager(javax.tools.JavaFileManager)

Aggregations

VFS (com.redhat.ceylon.compiler.typechecker.io.VFS)4 RepositoryManager (com.redhat.ceylon.cmr.api.RepositoryManager)2 File (java.io.File)2 RepositoryManagerBuilder (com.redhat.ceylon.cmr.api.RepositoryManagerBuilder)1 RuntimeModelLoader (com.redhat.ceylon.compiler.java.runtime.model.RuntimeModelLoader)1 RuntimeModuleManager (com.redhat.ceylon.compiler.java.runtime.model.RuntimeModuleManager)1 Context (com.redhat.ceylon.compiler.typechecker.context.Context)1 PhasedUnit (com.redhat.ceylon.compiler.typechecker.context.PhasedUnit)1 PhasedUnits (com.redhat.ceylon.compiler.typechecker.context.PhasedUnits)1 ClosableVirtualFile (com.redhat.ceylon.compiler.typechecker.io.ClosableVirtualFile)1 Modules (com.redhat.ceylon.model.typechecker.model.Modules)1 Context (com.sun.tools.javac.util.Context)1 JavaFileManager (javax.tools.JavaFileManager)1