Examples of PhasedUnits


Examples of com.redhat.ceylon.compiler.typechecker.context.PhasedUnits

        }
    }

    @Override
    protected PhasedUnits createPhasedUnits() {
      PhasedUnits units = super.createPhasedUnits();
        String fileEncoding = encoding;
        if (fileEncoding == null) {
            fileEncoding = CeylonConfig.get(DefaultToolOptions.DEFAULTS_ENCODING);
        }
        if (fileEncoding != null) {
        units.setEncoding(fileEncoding);
        }
      return units;
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.context.PhasedUnits

            List<String> moduleFilters, String encoding) {
        long start = System.nanoTime();
        this.verbose = verbose;
        this.statistics = statistics;
        this.context = new Context(repositoryManager, vfs);
        this.phasedUnits = new PhasedUnits(context, moduleManagerFactory);
        this.verifyDependencies = verifyDependencies;
        this.assertionVisitor = assertionVisitor;
        statsVisitor = new StatisticsVisitor();
        phasedUnits.setModuleFilters(moduleFilters);
        phasedUnits.setEncoding(encoding);
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.context.PhasedUnits

        if ( sourceArtifact == null ) {
            ModuleHelper.buildErrorOnMissingArtifact(artifactContext, module, moduleImport, dependencyTree, exceptionOnGetArtifact, this);
        }
        else {
           
            PhasedUnits modulePhasedUnits = createPhasedUnits();
            ClosableVirtualFile virtualArtifact= null;
            try {
                virtualArtifact = context.getVfs().getFromZipFile(sourceArtifact.artifact());
                modulePhasedUnits.parseUnit(virtualArtifact);
                //populate module.getDependencies()
                modulePhasedUnits.visitModules();
                addToPhasedUnitsOfDependencies(modulePhasedUnits, phasedUnitsOfDependencies, module);
            } catch (Exception e) {
                StringBuilder error = new StringBuilder("unable to read source artifact for ");
                error.append(artifactContext.toString());
                error.append( "\ndue to connection error: ").append(e.getMessage());
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.context.PhasedUnits

    protected void addToPhasedUnitsOfDependencies(PhasedUnits modulePhasedUnits, List<PhasedUnits> phasedUnitsOfDependencies, Module module) {
        phasedUnitsOfDependencies.add(modulePhasedUnits);
    }
   
    protected PhasedUnits createPhasedUnits() {
        return new PhasedUnits(getContext());
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.context.PhasedUnits

    public ModuleDescriptorReader(String moduleName, File srcDir) throws NoSuchModuleException {
        RepositoryManagerBuilder builder = new RepositoryManagerBuilder(new NullLogger(), DefaultToolOptions.getDefaultOffline(), (int)DefaultToolOptions.getDefaultTimeout());
        RepositoryManager repoManager = builder.buildRepository();
        VFS vfs = new VFS();
        Context context = new Context(repoManager, vfs);
        PhasedUnits pus = new PhasedUnits(context);
        List<String> name = ModuleManager.splitModuleName(moduleName);
        ModuleManager moduleManager = pus.getModuleManager();
        if(Module.DEFAULT_MODULE_NAME.equals(moduleName)){
            // visit every folder and skip modules
            boolean exists = findDefaultModuleSource(srcDir);
            if(!exists)
                throw new NoSuchModuleException("No source found for default module");
        }else{
            visitModule(vfs, pus, name, srcDir, vfs.getFromFile(srcDir), moduleManager);
        }
        for (PhasedUnit pu : pus.getPhasedUnits()) {
            pu.visitSrcModulePhase();
        }
        this.moduleDescriptor = moduleManager.getOrCreateModule(name, null);
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.context.PhasedUnits

        }
    }
   
    private void postCompile(Context context, ErrorCollector listener, String moduleName, File srcDir, String[] dependencies, Set<String> removeAtRuntime) throws Exception {
        // now fetch stuff from the context
        PhasedUnits phasedUnits = LanguageCompiler.getPhasedUnitsInstance(context);
       
        List<Runner> moduleRunners = new LinkedList<Runner>();

        // Get a class loader for the car
        // XXX Need to use CMR if the module has dependencies
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.context.PhasedUnits

        Boolean success = task.call();
       
        Assert.assertTrue(success);

        PhasedUnits phasedUnits = LanguageCompiler.getPhasedUnitsInstance(context);
       
        // find out what was in that file
        Assert.assertEquals(2, phasedUnits.getPhasedUnits().size());
        PhasedUnit one = phasedUnits.getPhasedUnits().get(0);
        PhasedUnit two = phasedUnits.getPhasedUnits().get(1);
        PhasedUnit phasedUnit = one.getUnitFile().getName().endsWith("module.ceylon")
                ? two : one;
        final Map<String,Declaration> decls = new HashMap<String,Declaration>();
        for(Declaration decl : phasedUnit.getUnit().getDeclarations()){
            if(decl.isToplevel()){
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.context.PhasedUnits

        TypeCheckerBuilder tcb = new TypeCheckerBuilder();
        for (File path: this.sourceFolders) {
            tcb.addSrcDirectory(applyCwd(path));
        }
        TypeChecker tc = tcb.getTypeChecker();
        PhasedUnits pus = tc.getPhasedUnits();
        pus.visitModules();
       
        ArrayList<Module> moduleList = new ArrayList<Module>(pus.getModuleManager().getCompiledModules());
        Collections.sort(moduleList, new Comparator<Module>() {
            @Override
            public int compare(Module m1, Module m2) {
                if (match(m1) && !match(m2)) {
                    return -1;
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.context.PhasedUnits

    private Map<String,CeylonFileObject> moduleNamesToFileObjects = new HashMap<String,CeylonFileObject>();
    private SourceLanguage sourceLanguage;

    /** Get the PhasedUnits instance for this context. */
    public static PhasedUnits getPhasedUnitsInstance(final Context context) {
        PhasedUnits phasedUnits = context.get(phasedUnitsKey);
        if (phasedUnits == null) {
            com.redhat.ceylon.compiler.typechecker.context.Context ceylonContext = getCeylonContextInstance(context);
            phasedUnits = new PhasedUnits(ceylonContext, new ModuleManagerFactory(){
                @Override
                public ModuleManager createModuleManager(com.redhat.ceylon.compiler.typechecker.context.Context ceylonContext) {
                    CompilerDelegate phasedUnitsManager = getCompilerDelegate(context);
                    return phasedUnitsManager.getModuleManager();
                }
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.context.PhasedUnits

        }
        RepositoryManagerBuilder builder = new RepositoryManagerBuilder(new NullLogger(), false, 20000);
        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.getModuleManager().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();
        
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.