[codeface] [PATCH v2 06/24] Add 'Base_Feature' analogous to 'File_Level'

  • From: Claus Hunsen <hunsen@xxxxxxxxxxxxxxxxx>
  • To: codeface@xxxxxxxxxxxxx
  • Date: Thu, 1 Dec 2016 17:11:00 +0100

For the 'feature' analysis, any change not occurring within an #ifdef
annotation is now mapped to the 'Base_Feature'. Accordingly, all changed
files of a commit are listed in the 'commit_dependency' table of the
database.

This change is in analogy to the 'File_Level' classification of the
'proximity' analysis, where any change not occurring within a function
is mapped to 'File_Level'.

Signed-off-by: Claus Hunsen <hunsen@xxxxxxxxxxxxxxxxx>
---
 codeface/VCS.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/codeface/VCS.py b/codeface/VCS.py
index abe7e8f..521b713 100644
--- a/codeface/VCS.py
+++ b/codeface/VCS.py
@@ -445,8 +445,20 @@ def get_feature_lines(parsed_lines, filename):
             # otherwise, add empty list
             fexpr_lines.add_line(line, [])
 
+    # Replace an empty list of features or an empty feature expression with
+    # the 'Base_Feature' constant
+    feature_lines_with_base = FileDict()
+    for line_nr in feature_lines:
+        features = feature_lines.get_line_info_raw(line_nr)
+        feature_lines_with_base.add_line(line_nr, features if bool(features) 
else ['Base_Feature'])
+
+    fexpr_lines_with_base = FileDict()
+    for line_nr in fexpr_lines:
+        fexpr = fexpr_lines.get_line_info_raw(line_nr)
+        fexpr_lines_with_base.add_line(line_nr, fexpr if bool(fexpr) else 
['Base_Feature'])
+
     # return feature lines and feature-expression lines
-    return (feature_lines, fexpr_lines)
+    return (feature_lines_with_base, fexpr_lines_with_base)
 
 
 def get_feature_lines_from_file(file_layout_src, filename):
-- 
2.10.2


Other related posts:

  • » [codeface] [PATCH v2 06/24] Add 'Base_Feature' analogous to 'File_Level' - Claus Hunsen