Package com.redhat.ceylon.compiler.typechecker

Examples of com.redhat.ceylon.compiler.typechecker.TypeChecker


        });
    }

    public TestAutocompletion(String path, int r, int c, String text, String found) {
        file = path.substring(path.lastIndexOf('/')+1);
        TypeChecker tc = new TypeCheckerBuilder().verbose(false).addSrcDirectory(new File(path)).getTypeChecker();
        tc.process();
        nodeText = text;
        checkCompletion = found;
        assist = new AutocompleteVisitor(r, c, tc);
    }
View Full Code Here


    @Test
    public void testJavaDependencies() throws IOException {
        final TypeCheckerBuilder builder = new TypeCheckerBuilder();
        builder.addSrcDirectory(new File("src/test/resources/javadeps"));
        final TypeChecker tc = builder.getTypeChecker();
        tc.process();
        final Options opts = new Options()
                .addSrcDir("src/test/resources/javadeps")
                .outRepo("./build")
                .indent(false)
                .comment(false)
View Full Code Here

        }
        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);
        }
    }
View Full Code Here

            .moduleManagerFactory(new JsModuleManagerFactory("UTF-8"));
        for (File sd : opts.getSrcDirs()) {
            builder.addSrcDirectory(sd);
        }
        builder.setRepositoryManager(repoman);
        final TypeChecker tc = builder.getTypeChecker();
        JsModuleManagerFactory.setVerbose(true);
        tc.process();
        return tc;
    }
View Full Code Here

    @Test @SuppressWarnings("unchecked")
    public void testSiteVariance() throws IOException {
        //Typecheck
        Options opts = options("src/test/resources/variance/phase1");
        TypeChecker tc = typeChecker(opts);
        //Compile
        JsCompiler jsc = new JsCompiler(tc, opts);
        jsc.generate();
        Map<String, Object> model = JSUtils.readJsonModel(new File("modules/phase1/0.1/phase1-0.1-model.js"));
        Assert.assertNotNull("Model not found", model);
        model = (Map<String,Object>)model.get("phase1");
        Assert.assertNotNull("Default package not found", model);
        model = (Map<String,Object>)model.get("m2");
        Assert.assertNotNull("Method m2 not found", model);
        Map<String,Object> type = (Map<String,Object>)model.get(MetamodelGenerator.KEY_TYPE);
        List<Map<String,Object>> targs = (List<Map<String,Object>>)type.get(MetamodelGenerator.KEY_TYPE_PARAMS);
        type = targs.get(0);
        List<List<Map<String,Object>>> paramLists = (List<List<Map<String,Object>>>)model.get(MetamodelGenerator.KEY_PARAMS);
        Map<String,Object> parm = paramLists.get(0).get(0);
        parm = (Map<String,Object>)parm.get(MetamodelGenerator.KEY_TYPE);
        targs = (List<Map<String,Object>>)parm.get(MetamodelGenerator.KEY_TYPE_PARAMS);
        parm = targs.get(0);
        Assert.assertEquals(SiteVariance.OUT.ordinal(), type.get(MetamodelGenerator.KEY_US_VARIANCE));
        Assert.assertEquals(SiteVariance.IN.ordinal(), parm.get(MetamodelGenerator.KEY_US_VARIANCE));

        //Typecheck phase2
        opts = options("src/test/resources/variance/phase2");
        tc = typeChecker(opts);
        Method m2 = (Method)tc.getPhasedUnits().getPhasedUnits().get(0).getPackage().getModule().getPackage("phase1").getDirectMember("m2", null, false);
        Assert.assertNotNull("phase1::m2 missing", m2);
        Assert.assertFalse("Missing variance overrides in return type",
                m2.getType().getVarianceOverrides().isEmpty());
        Assert.assertFalse("Missing variance overrides in parameter",
                m2.getParameterLists().get(0).getParameters().get(0).getType()
View Full Code Here

                tcb.addSrcDirectory(d);
                opts.addSrcDir(d);
            }
        }
        tcb.setRepositoryManager(repoman);
        TypeChecker typeChecker = tcb.getTypeChecker();
        for (File x : excludes) {
            String ap = x.getPath();
            //Fix for Windows
            if ('/' != File.separatorChar) {
                ap = ap.replace(File.separatorChar, '/');
            }
            for (PhasedUnit pu : typeChecker.getPhasedUnits().getPhasedUnits()) {
                if (pu.getUnit().getFullPath().startsWith(ap)) {
                    typeChecker.getPhasedUnits().removePhasedUnitForRelativePath(pu.getPathRelativeToSrcDir());
                }
            }
        }
        typeChecker.process();
        if (typeChecker.getErrors() > 0) {
            System.exit(1);
        }
        System.out.println("Compiling in prototype style");
        opts.resourceDirs(resdirs);
        JsCompiler jsc = new JsCompiler(typeChecker, opts).stopOnErrors(true);
View Full Code Here

                }
                mod2.deleteOnExit();
            } finally {
            }
        }
        final TypeChecker tc = langmodtc.getTypeChecker();
        tc.process();
        if (tc.getErrors() > 0) {
            return 1;
        }

        //Compile these files
        final List<File> includes = new ArrayList<File>();
View Full Code Here

        final File file = new File(moduleFile.getParentFile(),
                name.substring(0,name.length()-3)+ArtifactContext.JS_MODEL);
        System.out.println("Generating language module compile-time model in JSON...");
        TypeCheckerBuilder tcb = new TypeCheckerBuilder().usageWarnings(false);
        tcb.addSrcDirectory(clSrcDir.getParentFile().getParentFile());
        TypeChecker tc = tcb.getTypeChecker();
        tc.process();
        MetamodelVisitor mmg = null;
        for (PhasedUnit pu : tc.getPhasedUnits().getPhasedUnits()) {
            if (!pu.getCompilationUnit().getErrors().isEmpty()) {
                System.out.println("whoa, errors in the language module "
                        + pu.getCompilationUnit().getLocation());
                for (Message err : pu.getCompilationUnit().getErrors()) {
                    System.out.println(err.getMessage());
View Full Code Here

                .stdin(false)
                .generateSourceArchive(!skipSrc)
                .encoding(encoding)
                .diagnosticListener(diagnosticListener)
                .outWriter(writer);
        final TypeChecker typeChecker;
        if (opts.hasVerboseFlag("cmr")) {
            append("Using repositories: "+getRepositoryAsStrings());
            newline();
        }
        final RepositoryManager repoman = getRepositoryManager();
        long t0, t1, t2, t3, t4;
        final TypeCheckerBuilder tcb;
        List<File> onlySources = null;
        List<File> onlyResources = null;
        if (opts.isStdin()) {
            VirtualFile src = new VirtualFile() {
                @Override
                public boolean isFolder() {
                    return false;
                }
                @Override
                public String getName() {
                    return "SCRIPT.ceylon";
                }
                @Override
                public String getPath() {
                    return getName();
                }
                @Override
                public InputStream getInputStream() {
                    return System.in;
                }
                @Override
                public List<VirtualFile> getChildren() {
                    return Collections.emptyList();
                }
                @Override
                public int hashCode() {
                    return getPath().hashCode();
                }
                @Override
                public boolean equals(Object obj) {
                    if (obj instanceof VirtualFile) {
                        return ((VirtualFile) obj).getPath().equals(getPath());
                    }
                    else {
                        return super.equals(obj);
                    }
                }
            };
            t0 = System.nanoTime();
            tcb = new TypeCheckerBuilder()
                .addSrcDirectory(src);
        } else {
            t0=System.nanoTime();
            tcb = new TypeCheckerBuilder();
           
            SourceArgumentsResolver resolver = new SourceArgumentsResolver(roots, resources, Constants.CEYLON_SUFFIX, Constants.JS_SUFFIX);
            resolver
                .cwd(cwd)
                .expandAndParse(files);
            onlySources = resolver.getSourceFiles();
            onlyResources = resolver.getResourceFiles();
           
            if (opts.isVerbose()) {
                append("Adding source directories to typechecker:" + roots).newline();
            }
            for (File root : roots) {
                tcb.addSrcDirectory(root);
            }
            if (!resolver.getSourceModules().isEmpty()) {
                tcb.setModuleFilters(resolver.getSourceModules());
            }
            tcb.statistics(opts.isProfile());
            JsModuleManagerFactory.setVerbose(opts.isVerbose());
            tcb.moduleManagerFactory(new JsModuleManagerFactory(encoding));
        }
        //getting the type checker does process all types in the source directory
        tcb.verbose(opts.isVerbose()).setRepositoryManager(repoman);
        tcb.usageWarnings(false).encoding(encoding);

        typeChecker = tcb.getTypeChecker();
        if (onlySources != null) {
            for (PhasedUnit pu : typeChecker.getPhasedUnits().getPhasedUnits()) {
                File unitFile = new File(pu.getUnitFile().getPath());
                if (!FileUtil.containsFile(onlySources, unitFile)) {
                    if (opts.isVerbose()) {
                        append("Removing phased unit " + pu).newline();
                    }
                    typeChecker.getPhasedUnits().removePhasedUnitForRelativePath(pu.getPathRelativeToSrcDir());
                }
            }
        }
        t1=System.nanoTime();
        typeChecker.process(true);
       
        t2=System.nanoTime();
        JsCompiler jsc = new JsCompiler(typeChecker, opts);
        if (onlySources != null) {
            if (opts.isVerbose()) {
View Full Code Here

        //Compile module with 2 packages
        System.out.println("Compiling multi");
        TypeCheckerBuilder tcb = new TypeCheckerBuilder().usageWarnings(false);
        tcb.addSrcDirectory(new java.io.File("src/test/resources/multi/pass1"));
        tcb.setRepositoryManager(repoman);
        TypeChecker tc = tcb.getTypeChecker();
        tc.process();
        Options options = new Options().addRepo("build/test/test_modules").outRepo("build/test/test_modules")
                .addSrcDir("src/test/resources/multi/pass1");
        JsCompiler compiler = new JsCompiler(tc, options);
        compiler.stopOnErrors(false);
        compiler.generate();
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.TypeChecker

Copyright © 2018 www.massapicom. 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.