コード例 #1
0
 private void RunAnalyzers(CodeDocument document, SourceParser parser, ICollection<SourceAnalyzer> analyzers)
 {
     if (analyzers != null)
     {
         if (parser.SkipAnalysisForDocument(document))
         {
             this.data.Core.SignalOutput(MessageImportance.Normal, string.Format(CultureInfo.CurrentCulture, "Skipping {0}...", new object[] { document.SourceCode.Name }));
         }
         else
         {
             foreach (SourceAnalyzer analyzer in analyzers)
             {
                 if (this.data.Core.Cancel)
                 {
                     return;
                 }
                 SourceParser.ClearAnalyzerTags(document);
                 try
                 {
                     analyzer.AnalyzeDocument(document);
                     continue;
                 }
                 catch (Exception)
                 {
                     string output = string.Format(CultureInfo.CurrentCulture, "Exception thrown by analyzer '{0}' while processing '{1}'.", new object[] { analyzer.Name, document.SourceCode.Path });
                     this.data.Core.SignalOutput(MessageImportance.High, output);
                     throw;
                 }
             }
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Runs the list of analyzers against the given document.
        /// </summary>
        /// <param name="document">The document to analyze.</param>
        /// <param name="parser">The parser that created the document.</param>
        /// <param name="analyzers">The list of analyzsers to run against the document.</param>
        private void RunAnalyzers(
            CodeDocument document, SourceParser parser, IEnumerable<SourceAnalyzer> analyzers)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertNotNull(parser, "parser");
            Param.Ignore(analyzers, "analyzers");

            if (analyzers != null)
            {
                if (parser.SkipAnalysisForDocument(document))
                {
                    this.data.Core.SignalOutput(
                        MessageImportance.Normal,
                        string.Format(CultureInfo.CurrentCulture, "Skipping {0}...", document.SourceCode.Name));
                }
                else
                {
                    // Loop through each of the analyzers attached to the parser.
                    foreach (SourceAnalyzer analyzer in analyzers)
                    {
                        // Make sure the user hasn't cancelled us.
                        if (this.data.Core.Cancel)
                        {
                            break;
                        }

                        SourceParser.ClearAnalyzerTags(document);
                        try
                        {
                            analyzer.AnalyzeDocument(document);
                        }
                        catch (System.Exception)
                        {
                            string details = string.Format(
                                    CultureInfo.CurrentCulture,
                                    "Exception thrown by analyzer '{0}' while processing '{1}'.",
                                    analyzer.Name,
                                    document.SourceCode.Path);

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