Package com.redhat.ceylon.compiler.typechecker

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


        });
    }

    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


public class TestJavaDeps {

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

        });
    }

    public TestDocVisitor(String path, Map<String, List<String>> locations) {
        file = path.substring(path.lastIndexOf('/')+1);
        tc = new TypeCheckerBuilder().verbose(false).addSrcDirectory(new File(path)).getTypeChecker();
        tc.process();
        for (PhasedUnit pu : tc.getPhasedUnits().getPhasedUnits()) {
            pu.getCompilationUnit().visit(doccer);
        }
        this.locations = locations;
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

    private TypeChecker typeChecker(Options opts) {
        final RepositoryManager repoman = CeylonUtils.repoManager()
                .userRepos(opts.getRepos())
                .outRepo(opts.getOutRepo())
                .buildManager();
        final TypeCheckerBuilder builder = new TypeCheckerBuilder()
            .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

                .userRepos(opts.getRepos())
                .outRepo(opts.getOutRepo())
                .buildManager();
        System.out.println("Typechecking Ceylon test code...");
        JsModuleManagerFactory.setVerbose(true);
        TypeCheckerBuilder tcb = new TypeCheckerBuilder().verbose(false)
            .moduleManagerFactory(new JsModuleManagerFactory(null))
            .usageWarnings(false);
        final ArrayList<File> excludes = new ArrayList<>();
        final ArrayList<File> resfiles = new ArrayList<>();
        final ArrayList<File> resdirs = new ArrayList<>();
        for (String dir : args) {
            final File d = new File(dir.charAt(1)==':'?dir.substring(2):dir);
            if (dir.startsWith("X:")) {
                excludes.add(d);
            } else if (dir.startsWith("R:")) {
                resdirs.add(d);
            } else if (dir.startsWith("r:")) {
                resfiles.add(d);
            } else {
                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, '/');
View Full Code Here

        final Options opts = new Options().addRepo("build/runtime").comment(false).optimize(true)
                .outRepo(tmpout.getAbsolutePath()).modulify(false).minify(true);

        //Typecheck the whole language module
        if (langmodtc == null) {
            langmodtc = new TypeCheckerBuilder().addSrcDirectory(clSrcDir.getParentFile().getParentFile())
                    .addSrcDirectory(LANGMOD_JS_SRC)
                    .encoding("UTF-8");
            langmodtc.setRepositoryManager(CeylonUtils.repoManager().systemRepo(opts.getSystemRepo())
                    .userRepos(opts.getRepos()).outRepo(opts.getOutRepo()).buildManager());
        }
View Full Code Here

    private static int encodeModel(final File moduleFile) throws IOException {
        final String name = moduleFile.getName();
        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 "
View Full Code Here

            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()) {
View Full Code Here

    private static Map<String, Object> topLevelModel;
    private static Map<String, Object> model;

    public static void initTypechecker() {
        if (model == null) {
            TypeCheckerBuilder builder = new TypeCheckerBuilder();
            builder.addSrcDirectory(new File("src/test/resources/modeltests"));
            tc = builder.getTypeChecker();
            tc.process();
        }
    }
View Full Code Here

TOP

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

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.