Package org.openquark.cal.services

Examples of org.openquark.cal.services.Status


            int nErrorsBefore = msgLogger.getNErrors();

            // The compiled module source has passed the initial quick check of validity. 
            // Now we want to open it and read its import list.  This will allow us to do
            // a deeper validity check against the modules it depends on.
            Status status = new Status("Compiled definition input stream status.");
            try {
                // Get the set of imported modules. 
                // This is needed to check the validity of the current compiled module source.
                Set<ModuleName> importedModules = compiledDefinitionInfo.getImportedModuleNames();
View Full Code Here


                   
                    if (!loadedImports) {
                        // Was unable to load imports from compiled module definition parse them out
                        // of the module source.
                       
                        Reader moduleReader = sourceDef.getSourceReader(new Status("Read module status."));
                        if (moduleReader == null) {
                            logMessage(new CompilerMessage(new SourceRange(moduleSourceName),
                                                           new MessageKind.Error.CouldNotReadModuleSource(moduleSourceName)));                   
                            continue;
                        }
View Full Code Here

            moduleDefnNode = ((SourceModelModuleSource)sourceDef).getParseTreeNode();
            moduleDefnSourceModel = ((SourceModelModuleSource)sourceDef).getModuleDefn();
           
        } else {
           
            Reader moduleReader = sourceDef.getSourceReader(new Status("Read module status."));
            if (moduleReader == null) {
                logMessage(new CompilerMessage(new SourceRange(moduleSourceName), new MessageKind.Error.CouldNotReadModuleSource(moduleSourceName)));                   
                return null;
            }
            moduleReader = new BufferedReader(moduleReader);
           
            setInputStream(moduleReader, moduleSourceName);
           
            try {
                // Call the parser to parse the module definition
                parser.module();
               
                moduleDefnNode = (ParseTreeNode)parser.getAST();
               
            } catch (antlr.RecognitionException e) {          
                // Recognition (syntax) error
                final SourceRange sourceRange = CALParser.makeSourceRangeFromException(e);
                logMessage(new CompilerMessage(sourceRange, new MessageKind.Error.SyntaxError(), e));
               
            } catch (antlr.TokenStreamException e) {
                // Bad token stream.  Maybe a bad token (eg. a stray "$" sign)
                logMessage(new CompilerMessage(new SourceRange(moduleSourceName), new MessageKind.Error.BadTokenStream(), e));
               
            } finally {
                // close the reader if any.
                if (moduleReader != null) {
                    try {
                        moduleReader.close();
                    } catch (IOException ioe) {
                        COMPILER_LOGGER.log(Level.FINE, "Problem closing file for module \"" + moduleSourceName + "\"");
                    }
                }
            }
           
            // Only try to create a source model if the parse was successful
            if (moduleDefnNode != null && msgLogger.getNErrors() == nOldErrors) {
                moduleDefnSourceModel = SourceModelBuilder.buildModuleDefn(moduleDefnNode);
            }
        }
       
        // If parsing succeeded to produce an AST, continue with this module node..
        // Note: only invoke the tree parser if there are no errors when parsing the module.
        //   Otherwise the tree parser is sure to fail (in a fatal error) and so there is no point doing this.
        if (moduleDefnNode != null && msgLogger.getNErrors() == nOldErrors) {  
           
            // Debug..
           
            if (DEBUG_SOURCE_MODEL || inUnitTestDebugSourceModelMode) {
                //use the generated ParseTree to create a SourceModel.ModuleDefn.
                SourceModel.ModuleDefn moduleDefn = SourceModelBuilder.buildModuleDefn(moduleDefnNode);
               
                if (DEBUG_SOURCE_MODEL_VISITOR || inUnitTestDebugSourceModelMode) {
                    SourceModel.ModuleDefn newModuleDefn = (SourceModel.ModuleDefn)moduleDefn.accept(new SourceModelCopier<Void>(), null);
                   
                    moduleDefn = newModuleDefn;
                    moduleDefn.accept(new SourceModelTraverser<Void, Void>(), null);
                }
               
                if (DEBUG_SOURCE_MODEL_TEXT || inUnitTestDebugSourceModelMode) {
                    // ...then create module text from the source model. It should work when parsed again
                    // i.e. the source model should represent the same CAL as the original CAL text.
                   
                    ModuleSourceDefinition sourceBuilderModuleSource = new SourceModelModuleSource(moduleDefn);
                    Reader sourceBuilderModuleReader = sourceBuilderModuleSource.getSourceReader(new Status("Read module status."));
                    if (sourceBuilderModuleReader == null) {
                        logMessage(new CompilerMessage(new SourceRange(moduleSourceName), new MessageKind.Error.CouldNotReadModuleSource(moduleSourceName)));                   
                        return null;
                    }
                    sourceBuilderModuleReader = new BufferedReader(sourceBuilderModuleReader);
View Full Code Here

     * @return List the name and position of renamings encountered in
     *  the expression. Returns null if the expression does not parse.
     */
    List<SourceModification> findRenamingsInModule(ModuleSourceDefinition source, QualifiedName oldName, QualifiedName newName, SourceIdentifier.Category category) {
       
        Reader moduleReader = source.getSourceReader(new Status("Read module status."));
        if (moduleReader == null) {
            return Collections.emptyList();
        }
        moduleReader = new BufferedReader(moduleReader);
       
View Full Code Here

            // Check whether initialization has already occurred.
            if (importedModuleNames != null) {
                return;
            }
           
            Status status = new Status("get imports status");
            InputStream is = cmsd.getInputStream(status);
           
            if (is == null) {
                throw new IOException ("Error reading compiled definition for module " + cmsd.getModuleName() + " : " + status.getMessage());
            }
           
            RecordInputStream ris = new RecordInputStream(is);

            try {
View Full Code Here

           
            // Check for a value in the map.
            Boolean bool = sourceDefinitionToEmptyMap.get(msd);
           
            if (bool == null) {
                InputStream is = msd.getInputStream(new Status("Getting module source input stream"));
                boolean isEmpty = false;
                try {
                    try {
                        if (is.read() == -1) {
                            isEmpty = true;
View Full Code Here

         * @param logger
         * @param fromName QualifiedName to change from
         * @param toName QualifiedName to change to
         */
        private void updateMetadata(CompilerMessageLogger logger, QualifiedName fromName, QualifiedName toName) {
            Status updateMetadataStatus = new Status("Update metadata status");               
            MetadataRenameUpdater metadataRenamer = new MetadataRenameUpdater(updateMetadataStatus, typeChecker, toName, fromName, category);
           
            MetadataRenameUpdater.StatusListener refactoringStatusListener = new MetadataRenameUpdater.StatusListener() {
                public void willUseResource(WorkspaceResource resource) {}
                public void doneUsingResource(WorkspaceResource resource) {
View Full Code Here

                // toCALFeatureName will have already logged an error for us
                return;
            }
           
           
            Status renameResourceStatus = new Status("Rename resource status");
            super.moduleContainer.renameFeature(fromFeatureName, toFeatureName, renameResourceStatus);
            addStatusMessagesToCompilerMessageLogger(renameResourceStatus, Status.Severity.ERROR, logger);
        }
View Full Code Here

     * @param messageLogger CompilerMessageLogger to log failures to
     */
    private void saveModuleText(ModuleName moduleName, String moduleText, CompilerMessageLogger messageLogger) {
        ModuleContainer.ISourceManager sourceManager = moduleContainer.getSourceManager(moduleName);

        Status saveStatus = new Status("Saving refactored module text");
        sourceManager.saveSource(moduleName, moduleText, saveStatus);
        if(!saveStatus.isOK()) {
            MessageKind messageKind = new MessageKind.Error.ModuleNotWriteable(moduleName);
            messageLogger.logMessage(new CompilerMessage(messageKind));
        }
    }
View Full Code Here

            if(oldNameAsModuleName == null) {
                iceLogger.log(Level.INFO, "Invalid module name '" + oldNameString + "'");
                return;
            }
           
            getWorkspaceManager().removeModule(oldNameAsModuleName, false, new Status("removing old module"));
        }
           
        iceLogger.log(Level.INFO, "done");
    }
View Full Code Here

TOP

Related Classes of org.openquark.cal.services.Status

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.