Examples of WorkspaceManager


Examples of org.openquark.cal.services.WorkspaceManager

    private boolean compileWorkspace(boolean dirtyOnly, boolean forceCodeRegen) {

        jfitLogger.info("Compiling CAL workspace..");
       
        String clientID = WorkspaceConfiguration.getDiscreteWorkspaceID(DEFAULT_WORKSPACE_CLIENT_ID);
        WorkspaceManager workspaceManager = WorkspaceManager.getWorkspaceManager(clientID);
       
        // Add a status listener to log when modules are loaded.
        workspaceManager.addStatusListener(new StatusListener.StatusListenerAdapter() {
            public void setModuleStatus(StatusListener.Status.Module moduleStatus, ModuleName moduleName) {
                if (moduleStatus == StatusListener.SM_LOADED) {
                    jfitLogger.fine("  Module loaded: " + moduleName);
                }
            }
        });

       
        CompilerMessageLogger ml = new MessageLogger();
       
        // Init and compile the workspace.
        Status initStatus = new Status("Init status.");
        workspaceManager.initWorkspace(streamProvider, initStatus);
       
        if (initStatus.getSeverity() != Status.Severity.OK) {
            ml.logMessage(initStatus.asCompilerMessage());
        }
       
        long startCompile = System.currentTimeMillis();
       
        // If there are no errors go ahead and compile the workspace.
        if (ml.getMaxSeverity().compareTo(CompilerMessage.Severity.ERROR) < 0) {
            WorkspaceManager.CompilationOptions options = new WorkspaceManager.CompilationOptions();
            options.setForceCodeRegeneration(forceCodeRegen);
            workspaceManager.compile(ml, dirtyOnly, null, options);
        }
       
        long compileTime = System.currentTimeMillis() - startCompile;
       
        boolean compilationSucceeded;
        if (ml.getMaxSeverity().compareTo(CompilerMessage.Severity.ERROR) >= 0) {
            // Errors
            jfitLogger.severe("Compilation unsuccessful because of errors:");
            compilationSucceeded = false;
        } else {
            // Compilation successful
            jfitLogger.fine("Compilation successful");
            compilationSucceeded = true;
        }
       
        // Write out compiler messages
        java.util.List<CompilerMessage> errs = ml.getCompilerMessages();
        int errsSize = errs.size();
        for (int i = 0; i < errsSize; i++) {
            CompilerMessage err = errs.get(i);
            jfitLogger.info("  " + err.toString());
        }
       
        jfitLogger.fine("CAL: Finished compiling in " + compileTime + "ms");
       
        this.calWorkspace = workspaceManager.getWorkspace();
       
        return compilationSucceeded;
    }
View Full Code Here

Examples of org.openquark.cal.services.WorkspaceManager

     * @param topLevelSourceElements the top-level source elements to include.
     * @return a logger which logged the results of the compile.
     */
    private static CompilerMessageLogger compileAndRemoveModuleForTopLevelSourceElements(ModuleName moduleName, SourceModel.TopLevelSourceElement[] topLevelSourceElements) {
        // Get the workspace manager and the logger.
        WorkspaceManager workspaceManager = leccCALServices.getWorkspaceManager();
        CompilerMessageLogger logger = new MessageLogger();

        // Get the module defn.
        SourceModel.ModuleDefn moduleDefnWithoutImports = SourceModel.ModuleDefn.make(moduleName, new SourceModel.Import[0], topLevelSourceElements);
        SourceModel.ModuleDefn moduleDefn = SourceModelUtilities.ImportAugmenter.augmentWithImports(moduleDefnWithoutImports);

        // Compile the module.
        SourceModelModuleSource moduleSource = new SourceModelModuleSource(moduleDefn);
        workspaceManager.makeModule(moduleSource, logger);

        // Remove the module.
        leccCALServices.getWorkspaceManager().removeModule(DEFAULT_TEST_MODULE_NAME, new Status("Remove module status."));

        return logger;
View Full Code Here

Examples of org.openquark.cal.services.WorkspaceManager

    /**
     * Test that a data constructor argument without a field name gives an error.
     */
    public void testUnnamedDCArgError() {
        // Get the workspace manager and the logger.
        WorkspaceManager workspaceManager = leccCALServices.getWorkspaceManager();
        CompilerMessageLogger logger = new MessageLogger();

        ModuleName moduleName = DEFAULT_TEST_MODULE_NAME;
        final String moduleCode =
            "module " + DEFAULT_TEST_MODULE_NAME + ";" +
            "import " + Prelude + ";" +
           
            "data Foo = Foo " + Prelude + ".Int;";

        // Compile the module.
        ModuleSourceDefinition moduleSourceDef = new StringModuleSourceDefinition(moduleName, moduleCode);
        workspaceManager.makeModule(moduleSourceDef, logger);

        // Remove the module.
        leccCALServices.getWorkspaceManager().removeModule(DEFAULT_TEST_MODULE_NAME, new Status("Remove module status."));
       
        // Check that we got an error message of the expected type.
View Full Code Here

Examples of org.openquark.cal.services.WorkspaceManager

           
            if (logger.getNErrors() > 0) {
                Assert.fail("Parsing of module definition failed: " + logger.getCompilerMessages());
            }
           
            WorkspaceManager workspaceManager = privateCopyLeccServices.getWorkspaceManager();
           
            workspaceManager.makeModule(new SourceModelModuleSource(moduleDefn), logger);
            if (logger.getNErrors() > 0) {
                Assert.fail("Compilation of test module (before adding instances) failed: " + logger.getCompilerMessages());
            }
           
            String[] typeNames = new String[] {
                "Unary", "Binary", "Ternary", "MyWrap", "MyBottomMiddleTop", "MyFooBarBaz", "MyTuple3B"
            };
           
            SourceModel.Expr[][] correspTestValues = new SourceModel.Expr[][] {
                parseExprs(new String[] {"U1"}),
                parseExprs(new String[] {"B1", "B2"}),
                parseExprs(new String[] {"T1", "T2", "T3"}),
                parseExprs(new String[] {"MyWrap 'a'", "MyWrap 'b'", "MyWrap 'c'"}),
                parseExprs(new String[] {"Bottom", "Middle 'a'", "Middle 'b'", "Middle 'c'", "Top"}),
                parseExprs(new String[] {"MyFoo 'a'", "MyFoo 'b'", "MyFoo 'c'", "MyBar", "MyBaz 'a'", "MyBaz 'b'", "MyBaz 'c'"}),
                parseExprs(new String[] {
                    "MyTuple3B 'a' 'a' 'a'",
                    "MyTuple3B 'a' 'a' 'b'",
                    "MyTuple3B 'a' 'b' 'a'",
                    "MyTuple3B 'a' 'b' 'b'",
                    "MyTuple3B 'b' 'a' 'a'",
                    "MyTuple3B 'b' 'a' 'b'",
                    "MyTuple3B 'b' 'b' 'a'",
                    "MyTuple3B 'b' 'b' 'b'"})
            };
           
            SourceModel.ModuleDefn compactImplModuleDefn = addInstancesAndTests(moduleDefn, workspaceManager, typeNames, correspTestValues, true, "testAllCompact");
           
            if (SHOW_DEBUGGING_OUTPUT) {
                System.out.println("Module with compact instance implementations:");
                System.out.println(compactImplModuleDefn);
            }
           
            workspaceManager.makeModule(new SourceModelModuleSource(compactImplModuleDefn), logger);
            if (logger.getNErrors() > 0) {
                Assert.fail("Compilation of compact instance implementations failed: " + logger.getCompilerMessages());
            }
           
            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(moduleName, "testAllCompact"), privateCopyLeccServices);
           
            SourceModel.ModuleDefn efficientImplModuleDefn = addInstancesAndTests(moduleDefn, workspaceManager, typeNames, correspTestValues, false, "testAllEfficient");
           
            if (SHOW_DEBUGGING_OUTPUT) {
                System.out.println("Module with efficient instance implementations:");
                System.out.println(efficientImplModuleDefn);
            }
           
            workspaceManager.makeModule(new SourceModelModuleSource(efficientImplModuleDefn), logger);
            if (logger.getNErrors() > 0) {
                Assert.fail("Compilation of efficient instance implementations failed: " + logger.getCompilerMessages());
            }

            CALServicesTestUtilities.runNamedFunction(QualifiedName.make(moduleName, "testAllEfficient"), privateCopyLeccServices);
View Full Code Here

Examples of org.openquark.cal.services.WorkspaceManager

            "unqualifiedFooReference = foo;\n" +
            "boundBarReference bar =\n" +
            "   foo bar;\n" +
            "intToOrderingReference = intToOrdering;";
       
        WorkspaceManager workspaceManager = leccServices.getWorkspaceManager();
        CompilerMessageLogger logger = new MessageLogger();
       
        ModuleTypeInfo moduleTypeInfo1 = workspaceManager.getModuleTypeInfo(CALRenaming_Test_Support1);
        ModuleTypeInfo moduleTypeInfo2 = workspaceManager.getModuleTypeInfo(CALRenaming_Test_Support2);
       
        QualifiedName oldName = QualifiedName.make(CALRenaming_Test_Support1, "foo");
        QualifiedName newName = QualifiedName.make(CALRenaming_Test_Support1, "bar");
       
        SourceModifier renamer1 = IdentifierRenamer.getSourceModifier(moduleTypeInfo1, sourceText1, oldName, newName, Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD, logger);
View Full Code Here

Examples of org.openquark.cal.services.WorkspaceManager

            "unqualifiedFooReference = foo;\n" +
            "boundBarReference bar =\n" +
            "   foo bar;\n" +
            "intToOrderingReference = intToOrdering;";
       
        WorkspaceManager workspaceManager = leccServices.getWorkspaceManager();
        CompilerMessageLogger logger = new MessageLogger();
       
        ModuleTypeInfo moduleTypeInfo = workspaceManager.getModuleTypeInfo(CALRenaming_Test_Support2);
       
        QualifiedName oldName = QualifiedName.make(CALRenaming_Test_Support1, "foo");
        QualifiedName newName = QualifiedName.make(CALRenaming_Test_Support1, "intToOrdering");
       
        SourceModifier renamer = IdentifierRenamer.getSourceModifier(moduleTypeInfo, sourceText, oldName, newName, Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD, logger);
View Full Code Here

Examples of org.openquark.cal.services.WorkspaceManager

            "    ;\n" +
            "foo :: " + Prelude + ".Num a => a -> a -> a;\n" +
            "public foo x = " + Prelude + ".add x;\n" +
            "refIntToOrdering = intToOrdering;";

        WorkspaceManager workspaceManager = leccServices.getWorkspaceManager();
        CompilerMessageLogger logger = new MessageLogger();
       
        ModuleTypeInfo moduleTypeInfo = workspaceManager.getModuleTypeInfo(CALRenaming_Test_Support1);
       
        QualifiedName oldName = QualifiedName.make(CALRenaming_Test_Support1, "foo");
        QualifiedName newName = QualifiedName.make(CALRenaming_Test_Support1, "intToOrdering");
       
        SourceModifier renamer = IdentifierRenamer.getSourceModifier(moduleTypeInfo, sourceText, oldName, newName, Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD, logger);
View Full Code Here

Examples of org.openquark.cal.services.WorkspaceManager

            "    ;\n" +
            "foo :: " + Prelude + ".Num a => a -> a -> a;\n" +
            "public foo x = " + Prelude + ".add x;\n" +
            "refIntToOrdering = intToOrdering;";

        WorkspaceManager workspaceManager = leccServices.getWorkspaceManager();
        CompilerMessageLogger logger = new MessageLogger();
       
        ModuleTypeInfo moduleTypeInfo = workspaceManager.getModuleTypeInfo(CALRenaming_Test_Support1);
       
        QualifiedName oldName = CAL_Prelude.Functions.intToOrdering;
        QualifiedName newName = QualifiedName.make(Prelude, "foo");
       
        SourceModifier renamer = IdentifierRenamer.getSourceModifier(moduleTypeInfo, sourceText, oldName, newName, Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD, logger);
View Full Code Here

Examples of org.openquark.cal.services.WorkspaceManager

            " * @see Alpha, Beta, Gamma, Cons, foobar\n" +
            " */\n" +
            "data Beta =\n" +
            "    Gamma;\n";       

        WorkspaceManager workspaceManager = leccServices.getWorkspaceManager();
        CompilerMessageLogger logger = new MessageLogger();
       
        ModuleTypeInfo moduleTypeInfo = workspaceManager.getModuleTypeInfo(CALRenaming_Test_Support1);
       
        QualifiedName oldName = QualifiedName.make(CALRenaming_Test_Support1, "Gamma");
        QualifiedName newName = QualifiedName.make(CALRenaming_Test_Support1, "Alpha");
       
        SourceModifier renamer = IdentifierRenamer.getSourceModifier(moduleTypeInfo, sourceText, oldName, newName, Category.DATA_CONSTRUCTOR, logger);
View Full Code Here

Examples of org.openquark.cal.services.WorkspaceManager

            " * @see Alpha, Beta, Gamma, Cons, foobar\n" +
            " */\n" +
            "data Beta =\n" +
            "    Gamma;\n";       

        WorkspaceManager workspaceManager = leccServices.getWorkspaceManager();
        CompilerMessageLogger logger = new MessageLogger();
       
        ModuleTypeInfo moduleTypeInfo = workspaceManager.getModuleTypeInfo(CALRenaming_Test_Support1);
       
        QualifiedName oldName = QualifiedName.make(CALRenaming_Test_Support1, "Gamma");
        QualifiedName newName = QualifiedName.make(CALRenaming_Test_Support1, "Cons");
       
        SourceModifier renamer = IdentifierRenamer.getSourceModifier(moduleTypeInfo, sourceText, oldName, newName, Category.DATA_CONSTRUCTOR, logger);
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.