Parse old/new source files and extract the change info for all functions
(old_ast, new_ast, patch, patch_parser, ranges_func)
| 9 | |
| 10 | |
| 11 | def 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 | |
| 40 | class CGraphServer(GraphServer): |
no test coverage detected