Search in sources :

Example 6 with PhasedUnits

use of com.redhat.ceylon.compiler.typechecker.context.PhasedUnits 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)

Aggregations

PhasedUnits (com.redhat.ceylon.compiler.typechecker.context.PhasedUnits)6 PhasedUnit (com.redhat.ceylon.compiler.typechecker.context.PhasedUnit)2 Context (com.sun.tools.javac.util.Context)2 File (java.io.File)2 URLClassLoader (java.net.URLClassLoader)2 HashMap (java.util.HashMap)2 RepositoryManager (com.redhat.ceylon.cmr.api.RepositoryManager)1 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 CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)1 TypeChecker (com.redhat.ceylon.compiler.typechecker.TypeChecker)1 TypeCheckerBuilder (com.redhat.ceylon.compiler.typechecker.TypeCheckerBuilder)1 Context (com.redhat.ceylon.compiler.typechecker.context.Context)1 VFS (com.redhat.ceylon.compiler.typechecker.io.VFS)1 ImportModule (com.redhat.ceylon.compiler.typechecker.tree.Tree.ImportModule)1 ModuleManagerFactory (com.redhat.ceylon.compiler.typechecker.util.ModuleManagerFactory)1 AbstractModelLoader (com.redhat.ceylon.model.loader.AbstractModelLoader)1 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)1 Module (com.redhat.ceylon.model.typechecker.model.Module)1