Package com.redhat.ceylon.compiler.typechecker

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


                .userRepos(options.getRepos())
                .outRepo(options.getOutRepo())
                .buildManager();
        //Create a typechecker to compile the test module
        System.out.println("Compiling pass 1");
        TypeCheckerBuilder tcb = new TypeCheckerBuilder().usageWarnings(false);
        tcb.addSrcDirectory(new java.io.File("src/test/resources/loader/pass1"));
        tcb.setRepositoryManager(repoman);
        tc = tcb.getTypeChecker();
        tc.process();
        JsCompiler compiler = new JsCompiler(tc, options);
        compiler.stopOnErrors(false);
        compiler.generate();
        loadJsModel();
View Full Code Here


                    .cwd(options.getCwd())
                    .systemRepo(options.getSystemRepo())
                    .userRepos(options.getRepos())
                    .outRepo(options.getOutRepo())
                    .buildManager();
            TypeCheckerBuilder tcb = new TypeCheckerBuilder().usageWarnings(false);//.verbose(true);
            tcb.moduleManagerFactory(new JsModuleManagerFactory((String)null));
            tcb.addSrcDirectory(new java.io.File("src/test/resources/loader/pass2"));
            tcb.setRepositoryManager(repoman);
            jstc = tcb.getTypeChecker();
            jstc.process();
        }
    }
View Full Code Here

    private static TypeChecker tc;

    @BeforeClass
    public static void setup() {
        final TypeCheckerBuilder tcb = new TypeCheckerBuilder().statistics(true).encoding("UTF-8");
        tcb.addSrcDirectory(new File("../ceylon.language/src"));
        tc = tcb.getTypeChecker();
        tc.process();
    }
View Full Code Here

    @Before
    public void setup() throws IOException {
        //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);
View Full Code Here

    @Test
    public void test() throws IOException {
        //Compile module with 2 packages
        System.out.println("Compiling usemulti");
        TypeCheckerBuilder tcb = new TypeCheckerBuilder().usageWarnings(false);
        tcb.moduleManagerFactory(new JsModuleManagerFactory("UTF-8"));
        tcb.addSrcDirectory(new java.io.File("src/test/resources/multi/pass2"));
        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/pass2").verbose("");
        JsCompiler compiler = new JsCompiler(tc, options);
        compiler.stopOnErrors(false);
View Full Code Here

     * Files that are not under a proper module structure are
     * placed under a <nomodule> module.
     */
    public static void main(String[] args) throws Exception {
        long start = System.nanoTime();
        TypeChecker typeChecker = new TypeCheckerBuilder()
                .statistics(true)
                .verbose(false)
                .addSrcDirectory( new File("test/main") )
                .getTypeChecker();
        typeChecker.process();
        Tree.CompilationUnit compilationUnit = typeChecker.getPhasedUnitFromRelativePath("ceylon/language/Object.ceylon").getCompilationUnit();
        if ( compilationUnit == null ) {
            throw new RuntimeException("Failed to pass getCompilationUnitFromRelativePath for files in .src");
        }
        compilationUnit = typeChecker.getPhasedUnitFromRelativePath("capture/Capture.ceylon").getCompilationUnit();
        if ( compilationUnit == null ) {
            throw new RuntimeException("Failed to pass getCompilationUnitFromRelativePath for files in real src dir");
        }
        compilationUnit = typeChecker.getPhasedUnitFromRelativePath("com/redhat/sample/multisource/Boo.ceylon").getCompilationUnit();
        Module module = compilationUnit.getUnit().getPackage().getModule();
        if ( !"com.redhat.sample.multisource".equals( module.getNameAsString() ) ) {
            throw new RuntimeException("Unable to extract module name");
        }
        if ( !"0.2".equals( module.getVersion() ) ) {
            throw new RuntimeException("Unable to extract module version");
        }
        typeChecker = new TypeCheckerBuilder()
                .verbose(false)
                .addSrcDirectory( new File("test/main/capture") )
                .getTypeChecker();
        typeChecker.process();
        compilationUnit = typeChecker.getPhasedUnitFromRelativePath("Capture.ceylon").getCompilationUnit();
        if ( compilationUnit == null ) {
            throw new RuntimeException("Failed to pass getCompilationUnitFromRelativePath for top level files (no package) in real src dir");
        }

        typeChecker = new TypeCheckerBuilder()
                .verbose(false)
                .addSrcDirectory( new File("test/moduledep1") )
                .addSrcDirectory( new File("test/moduledep2") )
                .addSrcDirectory( new File("test/moduletest") )
                .getTypeChecker();
        typeChecker.process();

        ClosableVirtualFile latestZippedLanguageSourceFile = MainHelper.getLatestZippedLanguageSourceFile();
        typeChecker = new TypeCheckerBuilder()
                .verbose(false)
                .addSrcDirectory( latestZippedLanguageSourceFile )
                .getTypeChecker();
        typeChecker.process();
        latestZippedLanguageSourceFile.close();
View Full Code Here

            return;
        }
       
        boolean noisy = "true".equals(System.getProperties().getProperty("verbose"));
        //ClosableVirtualFile latestZippedLanguageSourceFile = MainHelper.getLatestZippedLanguageSourceFile();
        TypeCheckerBuilder tcb = new TypeCheckerBuilder()
                .verbose(noisy)
                .statistics(true);
                //.addSrcDirectory(latestZippedLanguageSourceFile);
        for (String path: args) {
            tcb.addSrcDirectory(new File(path));
        }
        tcb.getTypeChecker().process();
        //latestZippedLanguageSourceFile.close();
    }
View Full Code Here

     * Files that are not under a proper module structure are
     * placed under a <nomodule> module.
     */
    public static void main(String[] args) throws Exception {
        ClosableVirtualFile latestZippedLanguageSourceFile = MainHelper.getLatestZippedLanguageSourceFile();
        new TypeCheckerBuilder()
                .verbose(false)
                .addSrcDirectory(latestZippedLanguageSourceFile)
                .getTypeChecker()
                .process();
        latestZippedLanguageSourceFile.close();
View Full Code Here

    }

    @Override
    public void initialize() {
        setSystemProperties();
        TypeCheckerBuilder builder = new TypeCheckerBuilder();
        for(File src : sourceFolders){
            builder.addSrcDirectory(src);
        }
       
        // set up the artifact repository
        RepositoryManager repository = getRepositoryManager();
       
        builder.setRepositoryManager(repository);
       
        // make a destination repo
        outputRepositoryManager = getOutputRepositoryManager();

        // create the actual list of modules to process
        List<File> srcs = FileUtil.applyCwd(cwd, sourceFolders);
        List<String> expandedModules = ModuleWildcardsHelper.expandWildcards(srcs , moduleSpecs);
        final List<ModuleSpec> modules = ModuleSpec.parseEachList(expandedModules);
       
        // we need to plug in the module manager which can load from .cars
        builder.moduleManagerFactory(new ModuleManagerFactory(){
            @Override
            public ModuleManager createModuleManager(Context context) {
                return new CeylonDocModuleManager(CeylonDocTool.this, context, modules, outputRepositoryManager, log);
            }
        });
       
        // only parse what we asked for
        List<String> moduleFilters = new LinkedList<String>();
        for(ModuleSpec spec : modules){
            moduleFilters.add(spec.getName());
        }
        builder.setModuleFilters(moduleFilters);
        String fileEncoding  = getEncoding();
        if (fileEncoding == null) {
            fileEncoding = CeylonConfig.get(DefaultToolOptions.DEFAULTS_ENCODING);
        }
        if (fileEncoding != null) {
            builder.encoding(fileEncoding);
        }
       
        typeChecker = builder.getTypeChecker();
        // collect all units we are typechecking
        initTypeCheckedUnits(typeChecker);
        typeChecker.process();
        if (haltOnError && typeChecker.getErrors() > 0) {
            throw new CeylondException("error.failedParsing", new Object[] { typeChecker.getErrors() }, null);
View Full Code Here

        // build a map of all the native declarations
        final Map<String, Declaration> nativeFromSource = new HashMap<String, Declaration>();
       
        ClosableVirtualFile latestZippedLanguageSourceFile = getLatestZippedLanguageSourceFile();
        try {
            TypeCheckerBuilder typeCheckerBuilder = new TypeCheckerBuilder()
                    .verbose(false)
                    .addSrcDirectory(latestZippedLanguageSourceFile);
            TypeChecker typeChecker = typeCheckerBuilder.getTypeChecker();
            typeChecker.process();
            for (PhasedUnit pu : typeChecker.getPhasedUnits().getPhasedUnits()) {
                for (Declaration d : pu.getDeclarations()) {
                    if (d.isNative() && d.isToplevel()) {
                        String qualifiedNameString = d.getQualifiedNameString();
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.