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

Function function_change_stats

persper/analytics/c.py:11–37  ·  view source on GitHub ↗

Parse old/new source files and extract the change info for all functions

(old_ast, new_ast, patch, patch_parser, ranges_func)

Source from the content-addressed store, hash-verified

9
10
11def function_change_stats(old_ast, new_ast, patch, patch_parser, ranges_func):
12 """
13 Parse old/new source files and extract the change info for all functions
14 """
15 adds, dels = patch_parser(patch)
16
17 forward_stats = {}
18 bckward_stats = {}
19
20 if old_ast is not None:
21 forward_stats = get_changed_functions(
22 *ranges_func(old_ast), adds, dels, separate=True)
23
24 if new_ast is not None:
25 inv_adds, inv_dels = inverse_diff(adds, dels)
26 bckward_stats = get_changed_functions(
27 *ranges_func(new_ast), inv_adds, inv_dels, separate=True)
28
29 # merge forward and backward stats
30 for func, fstat in bckward_stats.items():
31 if func not in forward_stats:
32 forward_stats[func] = {
33 'adds': fstat['dels'],
34 'dels': fstat['adds']
35 }
36
37 return forward_stats
38
39
40class CGraphServer(GraphServer):

Callers 1

update_graphMethod · 0.85

Calls 3

get_changed_functionsFunction · 0.90
inverse_diffFunction · 0.90
itemsMethod · 0.80

Tested by

no test coverage detected