MCPcopy Index your code
hub / github.com/Persper/code-analytics / parse

Method parse

persper/graphs/c.py:49–83  ·  view source on GitHub ↗

Return None if there is an error

(self, old_filename, old_src, new_filename, new_src, patch)

Source from the content-addressed store, hash-verified

47 return {**new_func, **modified_func}, {}
48
49 def parse(self, old_filename, old_src, new_filename, new_src, patch):
50 """Return None if there is an error"""
51 forward_stats = {}
52 bckward_stats = {}
53
54 adds, dels = self._parse_patch(patch)
55 if adds is None or dels is None:
56 return None, {}
57
58 if old_src is not None:
59 old_root = transform_src_to_tree(old_src)
60 if old_root is None:
61 return None, {}
62
63 forward_stats = get_changed_functions(
64 *get_func_ranges_c(old_root), adds, dels)
65
66 if new_src is not None:
67 inv_adds, inv_dels = inverse_diff(adds, dels)
68 new_root = transform_src_to_tree(new_src)
69 if new_root is None:
70 return None, {}
71
72 bckward_stats = get_changed_functions(
73 *get_func_ranges_c(new_root), inv_adds, inv_dels)
74
75 """
76 forward_stats and bckward_stats might have different values
77 for the same function, as an example, please refer to
78 `str_equals` function in the following link. In this case,
79 we'll stick with forward_stats (override bckward_stats).
80 https://github.com/UltimateBeaver/test_feature_branch/commit/364d5cc49aeb2e354da458924ce84c0ab731ac77
81 """
82 bckward_stats.update(forward_stats)
83 return bckward_stats, {}
84
85 def get_graph(self):
86 return self.graph

Callers 5

build_call_graphFunction · 0.45
generate_datasetMethod · 0.45
_parse_patchMethod · 0.45
parse_patchMethod · 0.45
transform_src_to_treeFunction · 0.45

Calls 5

_parse_patchMethod · 0.95
transform_src_to_treeFunction · 0.90
get_changed_functionsFunction · 0.90
get_func_ranges_cFunction · 0.90
inverse_diffFunction · 0.90

Tested by

no test coverage detected