public DocumentAnalysisStatus GetDocumentStatus(SourceCode sourceCode)
 {
     DocumentAnalysisStatus status;
     if (!this.sourceCodeInstanceStatus.TryGetValue(sourceCode, out status))
     {
         status = new DocumentAnalysisStatus();
         this.sourceCodeInstanceStatus.Add(sourceCode, status);
     }
     return status;
 }
        /// <summary>
        /// Parses and analyzes the given document.
        /// </summary>
        /// <param name="sourceCode">The document to parse and analyze.</param>
        /// <param name="documentStatus">The current status of the documents.</param>
        private void ParseAndAnalyzeDocument(SourceCode sourceCode, DocumentAnalysisStatus documentStatus)
        {
            Param.AssertNotNull(sourceCode, "sourceCode");
            Param.AssertNotNull(documentStatus, "documentStatus");

            // Signal the output for this document.
            this.data.Core.SignalOutput(
                MessageImportance.Low,
                string.Format(CultureInfo.CurrentCulture, "Pass {0}: {1}...\n", this.data.PassNumber + 1, sourceCode.Name));

            // Extract the document to parse.
            CodeDocument parsedDocument = documentStatus.Document;

            // Get or load the analyzer list.
            IEnumerable<SourceAnalyzer> analyzers = sourceCode.Settings.EnabledAnalyzers;

            // Parse the document.
            bool parsingCompleted;
            try
            {
                parsingCompleted = !sourceCode.Parser.ParseFile(sourceCode, this.data.PassNumber, ref parsedDocument);
            }
            catch (System.Exception)
            {
                string details = string.Format(
                        CultureInfo.CurrentCulture,
                        "Exception thrown by parser '{0}' while processing '{1}'.",
                        sourceCode.Parser.Name,
                        sourceCode.Path);

                this.data.Core.SignalOutput(MessageImportance.High, details);
                throw;
            }

            if (parsingCompleted)
            {
                if (parsedDocument == null)
                {
                    documentStatus.Complete = true;
                }
                else if (this.TestAndRunAnalyzers(parsedDocument, sourceCode.Parser, analyzers, this.data.PassNumber))
                {
                    // Analysis of this document is completed.
                    documentStatus.Complete = true;

                    // Save the cache for this document and dispose it.
                    if (parsedDocument != null)
                    {
                        if (this.data.ResultsCache != null && sourceCode.Project.WriteCache)
                        {
                            this.data.ResultsCache.SaveDocumentResults(parsedDocument, sourceCode.Parser, sourceCode.Settings.WriteTime);
                        }

                        parsedDocument.Dispose();
                        parsedDocument = null;
                    }
                }
            }

            if (!documentStatus.Complete)
            {
                // Analysis of this document is not complete, so we will need to
                // perform another round of analysis after this one is finished.
                this.complete = false;

                // Cache the document if there is one.
                if (parsedDocument != null)
                {
                    documentStatus.Document = parsedDocument;
                }
            }
        }
 private void ParseAndAnalyzeDocument(SourceCode sourceCode, DocumentAnalysisStatus documentStatus)
 {
     bool flag;
     this.data.Core.SignalOutput(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Pass {0}: {1}...\n", new object[] { this.data.PassNumber + 1, sourceCode.Name }));
     CodeDocument document = documentStatus.Document;
     ICollection<SourceAnalyzer> analyzers = this.GetAnalyzersForProjectFile(sourceCode.Project, sourceCode, this.data.Core.Parsers);
     try
     {
         flag = !sourceCode.Parser.ParseFile(sourceCode, this.data.PassNumber, ref document);
     }
     catch (Exception)
     {
         string output = string.Format(CultureInfo.CurrentCulture, "Exception thrown by parser '{0}' while processing '{1}'.", new object[] { sourceCode.Parser.Name, sourceCode.Path });
         this.data.Core.SignalOutput(MessageImportance.High, output);
         throw;
     }
     if (flag)
     {
         if (document == null)
         {
             documentStatus.Complete = true;
         }
         else if (this.TestAndRunAnalyzers(document, sourceCode.Parser, analyzers, this.data.PassNumber))
         {
             documentStatus.Complete = true;
             if (document != null)
             {
                 if ((this.data.ResultsCache != null) && sourceCode.Project.WriteCache)
                 {
                     this.data.ResultsCache.SaveDocumentResults(document, sourceCode.Parser, sourceCode.Project.Settings.WriteTime);
                 }
                 document.Dispose();
                 document = null;
             }
         }
     }
     if (!documentStatus.Complete)
     {
         this.complete = false;
         if (document != null)
         {
             documentStatus.Document = document;
         }
     }
 }
            /// <summary>
            /// Gets the analysis status for the given source code document.
            /// </summary>
            /// <param name="sourceCode">The source code to retrieve status for.</param>
            /// <returns>Returns the analysis status for the source code.</returns>
            public DocumentAnalysisStatus GetDocumentStatus(SourceCode sourceCode)
            {
                Param.AssertNotNull(sourceCode, "sourceCode");

                DocumentAnalysisStatus status;
                if (!this.sourceCodeInstanceStatus.TryGetValue(sourceCode, out status))
                {
                    // Create a new status object and add add it to the dictionary.
                    status = new DocumentAnalysisStatus();
                    this.sourceCodeInstanceStatus.Add(sourceCode, status);
                }

                return status;
            }