MCPcopy Create free account
hub / github.com/Persper/code-analytics / update_graph

Method update_graph

persper/graphs/c.py:17–47  ·  view source on GitHub ↗
(self, old_filename, old_src, new_filename, new_src, patch)

Source from the content-addressed store, hash-verified

15 self._pparser = PatchParser()
16
17 def update_graph(self, old_filename, old_src, new_filename, new_src, patch):
18 # on add, rename, modify: update_roots = [new_root]
19 # on delete: update_roots = []
20 update_root = []
21
22 # on add: modified_func = {}
23 # on rename, modify, delete: modified_func is computed by
24 # parsing patch and call get_changed_functions
25 modified_func = {}
26
27 if old_src is not None:
28 old_root = transform_src_to_tree(old_src)
29 if old_root is None:
30 return {}, {}
31
32 modified_func = get_changed_functions(
33 *get_func_ranges_c(old_root),
34 *self._parse_patch(patch))
35
36 if new_src is not None:
37 new_root = transform_src_to_tree(new_src)
38 if new_root is None:
39 return {}, {}
40 update_root = [new_root]
41
42 # update call graph
43 # if on delete, then new_func is expected to be an empty dict
44 new_func = update_call_graph_c(self.graph, update_root, modified_func)
45
46 # return history
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"""

Callers

nothing calls this directly

Calls 5

_parse_patchMethod · 0.95
transform_src_to_treeFunction · 0.90
get_changed_functionsFunction · 0.90
get_func_ranges_cFunction · 0.90
update_call_graph_cFunction · 0.90

Tested by

no test coverage detected