Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.MessageLogger


     * @return true if compilation was successful, false otherwise
     */
    private boolean makeProgram(WorkspaceManager workspaceManager, CompilerMessageLogger logger, StatusListener statusListener) {
   
        if (logger == null) {
            logger = new MessageLogger ();
        }
        int nErrorsBefore = logger.getNErrors();
   
        // Compile.
        workspaceManager.compile(logger, false, statusListener);
View Full Code Here


        //compute the necessary imports
        if (imports == null) {
            newModule = SourceModelUtilities.ImportAugmenter.augmentWithImports(newModule);
        }
       
        CompilerMessageLogger logger = new MessageLogger();
       
        //add the module to the workspace
        CompilerMessage.Severity errorLevel = addNewModule(new SourceModelModuleSource(newModule), logger);
       
        if (errorLevel.compareTo(CompilerMessage.Severity.ERROR) >= 0) {
View Full Code Here

        pendingSearchThread = new Thread("search thread") {
            @Override
            public void run() {
               
                List<SearchResult> newResults = Collections.<SearchResult>emptyList();
                final MessageLogger messageLogger = new MessageLogger();
                try {
                    if(searchType == SearchType.ALL) {
                        newResults = workspaceSourceMetrics.findAllOccurrences(searchString, messageLogger);
                    } else if(searchType == SearchType.REFERENCES) {
                        newResults = workspaceSourceMetrics.findReferences(searchString, messageLogger);
View Full Code Here

    /**
     * Compile the workspace.
     * @return whether the workspace compiled successfully.
     */
    private boolean compileWorkspace() {
        CompilerMessageLogger ml = new MessageLogger();

        calLogger.fine("Compiling workspace..");
       
        // Init and compile the workspace.
        Status initStatus = new Status("Init status.");
        workspaceManager.initWorkspace(getStreamProvider(), false, 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.compile(ml, true, null);
        }

        long compileTime = System.currentTimeMillis() - startCompile;

        // Write out compiler messages
        writeOutCompileResult(ml);

        int nModules = workspaceManager.getModuleNamesInProgram().length;
        calLogger.fine("CAL: Finished compiling " + nModules + " modules in " + compileTime + "ms\n");

        return ml.getNErrors() == 0;
    }
View Full Code Here

            WorkspaceManager workspaceManager = calServices.getWorkspaceManager();
           
            try {
                HTMLDocumentationGeneratorConfiguration config = CALDocTool.makeConfiguration(workspaceManager, args, logger);
               
                MessageLogger msgLogger = new MessageLogger();
               
                StatusListener.StatusListenerAdapter statusListener = new StatusListener.StatusListenerAdapter() {
                    /**
                     * {@inheritDoc}
                     */
                    @Override
                    public void setModuleStatus(StatusListener.Status.Module moduleStatus, ModuleName moduleName) {
                        if (moduleStatus == StatusListener.SM_GENCODE) {
                            logger.fine("Compiling " + moduleName);
                        }
                    }
                };
               
                logger.info("Compiling CAL workspace..");
                calServices.compileWorkspace(statusListener, msgLogger);
               
                if (msgLogger.getNErrors() == 0) {
                    logger.info("Compilation successful");
                   
                    ////
                    /// We only generate the documentation if everything compiled properly without errors
                    //
                    CALDocTool.run(workspaceManager, config);
                   
                } else {
                    logger.severe("Compilation failed:");
                    List<CompilerMessage> messages = msgLogger.getCompilerMessages();
                    for (int i = 0, n = messages.size(); i < n; i++) {
                        logger.info("  " + messages.get(i).toString());
                    }
                }
               
View Full Code Here

         * CALServicesHelper constructor.
         */
        public CALServicesHelper() throws BusinessObjectsException {
            boolean compilationSuccessful = false;
           
            CompilerMessageLogger messageLogger = new MessageLogger();
           
            BasicCALServices newCalServices = null;
            try {
                newCalServices = BasicCALServices.make (WORKSPACE_FILE_PROPERTY,
                        DEFAULT_WORKSPACE_FILE, DEFAULT_WORKSPACE_CLIENT_ID);
               
                if (newCalServices != null) {
                    // If there's a local cache, the workspace will use it, rather than the modules in the repo
                    // ...so if the cache is out of date, now's the time to synch
                    compilationSuccessful = newCalServices.compileWorkspace(null, messageLogger);
                }
            }
            catch (Throwable t) {
                t.printStackTrace();
               
                newCalServices = null;
            }
           
            if ((newCalServices == null) || !compilationSuccessful){
                String message = "";
                if (messageLogger.getNErrors() > 0) {
                    StringBuffer msg = new StringBuffer("Failed to compile workspace:");
                    for (final CompilerMessage cm : messageLogger.getCompilerMessages()) {
                        msg.append("\n");
                        msg.append(cm);
                    }
   
                    message = msg.toString();
View Full Code Here

    public static void main(String[] args) {
       
        System.out.println("Source Model Demo");
        System.out.println("-------------------------------------------------------------------------------------");
       
        MessageLogger messageLogger = new MessageLogger();       
       
        // We need to set up the BasicCALServices instance that is required for the demo.
        // We get an instance through the getInstance() method, and compile the modules in the workspace via
        // the compileWorkspace() method.
       
        BasicCALServices calServices = BasicCALServices.make(
            WORKSPACE_FILE_NAME);
       
        if (!calServices.compileWorkspace(null, messageLogger)) {
            System.err.println(messageLogger.toString());
        }
       
        System.out.println();
        System.out.println("The CAL source of the demo gems defined using the source model:");
        System.out.println("=====================================================================================");
View Full Code Here

     * @see #runDemoMapDemo
     */
    public static void runSourceModelDemo(BasicCALServices services) {
       
        // First, we add the source-model based module definition as a new module to the workspace
        MessageLogger logger = new MessageLogger();
       
        //Create functions for factorial, outlier detection and map and add them to the program
        services.addNewModule(new SourceModelModuleSource(makeGemDemoModule()), logger);
           
        //run the factorial function
View Full Code Here

    public static void main(String[] args) {
       
        System.out.println("Gem Model Demo");
        System.out.println("-------------------------------------------------------------------------------------");
       
        MessageLogger messageLogger = new MessageLogger();       
       
        // We need to set up the calServices instance that is required for the demo.
        BasicCALServices calServices =
            BasicCALServices.makeCompiled(WORKSPACE_FILE_NAME, messageLogger);
       
        if (calServices == null) {
            System.err.println(messageLogger.toString());
            System.exit(1);
        }
       
        System.out.println();
        System.out.println("The CAL source of the demo gems defined using gem graphs:");
View Full Code Here

     * @param expressionText the text of the cal expression to qualify
     * @return the qualified code expression, if qualification was performed successfully.  Null if qualification failed.
     */
    public String qualifyCodeExpression(ModuleName moduleName, String expressionText) {
        // Qualify unqualified symbols in code, if unambiguous
        CompilerMessageLogger logger = new MessageLogger();
        CodeAnalyser analyser = new CodeAnalyser(getProgramModelManager().getTypeChecker(), getProgramModelManager().getModuleTypeInfo(moduleName), false, false);
        CodeAnalyser.QualificationResults qualificationResults = analyser.qualifyExpression(expressionText, null, null, logger, true);
       
        if (qualificationResults == null) {
            calLogger.severe("Attempt to qualify expression has failed because of errors: ");
            for (final CompilerMessage message : logger.getCompilerMessages()) {
                calLogger.info("  " + message.toString());
            }
            return null;
        }
        return qualificationResults.getQualifiedCode();
View Full Code Here

TOP

Related Classes of org.openquark.cal.compiler.MessageLogger

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.