Apply the 7-strategy resolution chain to all call references. Returns a list of CALLS GraphRelationship objects.
(
call_infos: list[CallInfo],
registries: Registries,
)
| 98 | |
| 99 | |
| 100 | def resolve_calls( |
| 101 | call_infos: list[CallInfo], |
| 102 | registries: Registries, |
| 103 | ) -> list[GraphRelationship]: |
| 104 | """Apply the 7-strategy resolution chain to all call references. |
| 105 | |
| 106 | Returns a list of CALLS GraphRelationship objects. |
| 107 | """ |
| 108 | results: list[GraphRelationship] = [] |
| 109 | |
| 110 | for ci in call_infos: |
| 111 | seen: set[str] = set() |
| 112 | for name, receiver, kind in ci.calls: |
| 113 | dedup_key = f"{receiver or ''}:{name}" |
| 114 | if dedup_key in seen: |
| 115 | continue |
| 116 | if name == ci.caller_name and receiver is None: |
| 117 | continue |
| 118 | |
| 119 | target_id, confidence = _resolve_single_call( |
| 120 | name=name, |
| 121 | receiver=receiver, |
| 122 | kind=kind, |
| 123 | caller_id=ci.caller_id, |
| 124 | file_id=ci.file_id, |
| 125 | caller_receiver_var=ci.receiver_var, |
| 126 | caller_receiver_type=ci.receiver_type, |
| 127 | caller_param_types=ci.param_types, |
| 128 | registries=registries, |
| 129 | ) |
| 130 | if target_id is None: |
| 131 | continue |
| 132 | |
| 133 | seen.add(dedup_key) |
| 134 | results.append( |
| 135 | GraphRelationship( |
| 136 | id=f"{ci.caller_id}->CALLS->{target_id}", |
| 137 | type="CALLS", |
| 138 | source_id=ci.caller_id, |
| 139 | target_id=target_id, |
| 140 | properties={"confidence": confidence}, |
| 141 | ) |
| 142 | ) |
| 143 | |
| 144 | return results |
| 145 | |
| 146 | |
| 147 | def _resolve_single_call( |