Commits

Anonymous committed 240023c

Fixed Total Parsed being too high. Should only count lines in translation units.

Comments (0)

Files changed (3)

header_hero/Data/SourceFile.cs

             Lines = 0;
             Touched = false;
         }
+		
+		static public bool IsTranslationUnitExtension(string ext)
+		{
+			return (ext == @".cpp" || ext == @".c" || ext == @".cc" || ext == @".cxx");
+		}
+		
+		static public bool IsTranslationUnitPath(string path)
+		{
+			return IsTranslationUnitExtension( System.IO.Path.GetExtension(path) );
+		}
     }
 }

header_hero/Parser/Analytics.cs

         public HashSet<string> AllIncludes;
         public int TotalIncludeLines;
         public HashSet<string> AllIncludedBy;
+		public HashSet<string> TranslationUnitsIncludedBy;
         public bool Analyzed;
 
         public ItemAnalytics()
             AllIncludes = new HashSet<string>();
             TotalIncludeLines = 0;
             AllIncludedBy = new HashSet<string>();
+			TranslationUnitsIncludedBy = new HashSet<string>();
             Analyzed = false;
         }
     }
             {
                 if (include == path)
                     continue;
-
+				
+				bool is_tu = Data.SourceFile.IsTranslationUnitPath(path);
+				
                 ItemAnalytics ai = Analyze(include, project);
                 a.AllIncludes.Add(include);
                 ai.AllIncludedBy.Add(path);
+				if (is_tu)
+					ai.TranslationUnitsIncludedBy.Add (path);
+				
 
                 a.AllIncludes.UnionWith(ai.AllIncludes);
-                foreach (string inc in ai.AllIncludes)
+                foreach (string inc in ai.AllIncludes) {
                     Items[inc].AllIncludedBy.Add(path);
+					if (is_tu)
+						Items[inc].TranslationUnitsIncludedBy.Add (path);
+				}
             }
 
             a.TotalIncludeLines = a.AllIncludes.Sum(f => project.Files[f].Lines);

header_hero/Parser/Report.cs

             // Summary
             {
                 int total_lines = _project.Files.Sum(kvp => kvp.Value.Lines);
-                int total_parsed = _analytics.Items.Sum(kvp => kvp.Value.TotalIncludeLines + _project.Files[kvp.Key].Lines);
+                int total_parsed = _analytics.Items
+					.Where (kvp => Data.SourceFile.IsTranslationUnitPath(kvp.Key))
+					.Sum(kvp => kvp.Value.TotalIncludeLines + _project.Files[kvp.Key].Lines);
                 float factor = (float)total_parsed / (float)total_lines;
                 Dictionary<string, string> table = new Dictionary<string, string> {
                     {"Files", string.Format("{0:### ### ###}", _project.Files.Count)},
 
             {
                 var most = _analytics.Items
-                    .ToDictionary(kvp => kvp.Key, kvp => _project.Files[kvp.Key].Lines * kvp.Value.AllIncludedBy.Count)
+                    .ToDictionary(kvp => kvp.Key, kvp => _project.Files[kvp.Key].Lines *
+						kvp.Value.TranslationUnitsIncludedBy.Count)
                     .Where(kvp => kvp.Value > 0)
                     .OrderByDescending(kvp => kvp.Value);
                 AppendFileList(sb, "Biggest Contributors", most);
 
             {
                 var hubs = _analytics.Items
-                    .ToDictionary(kvp => kvp.Key, kvp => kvp.Value.AllIncludes.Count * kvp.Value.AllIncludedBy.Count)
+                    .ToDictionary(kvp => kvp.Key, kvp => kvp.Value.AllIncludes.Count * kvp.Value.TranslationUnitsIncludedBy.Count)
                     .Where(kvp => kvp.Value > 0)
                     .OrderByDescending(kvp => kvp.Value);
                 AppendFileList(sb, "Header Hubs", hubs);