Commit 5beed1e
* fix(git): anchor deletion-only hunks to the enclosing symbol's line
`git diff --unified=0` emits a `+Z,0` hunk when lines are removed. These
deletion-only hunks contributed nothing to `changed_lines`, so downstream
symbol extraction in `core.rs` found no traceable symbol and skipped the
reference-traversal cascade entirely ("No traceable symbols found ...
skipping reference traversal"). The file's owning package was still marked
affected, but every *dependent* of the deleted symbol was missed.
Impact: any change whose diff is purely a deletion — removing a property
from an exported object, a case from a switch, an enum member, an overload —
under-reports affected projects to just the package the file lives in. In a
real monorepo, deleting one entry from an exported lookup object that 26
projects transitively consume reported `["@lama/selectors"]` (1 project)
instead of the 22 projects that actually reference it.
Fix: a `W == 0` deletion hunk now anchors to its new-side line `Z` — the
line just before the deletion point, which is still inside the enclosing
top-level symbol — so the AST lookup resolves that symbol and traces its
references normally. Clamped to 1 for deletions at the top of a file
(`+0,0`).
Known limitation (left for a follow-up): deleting an *entire* top-level
symbol leaves no enclosing node at the anchor line, so the AST lookup finds
nothing and behavior falls back to today's package-level marking. Catching
that requires parsing the base revision at the old-side range.
Adds a regression test and corrects two existing tests that had encoded the
buggy "deletion contributes nothing" assumption.
* fix(git): recover deleted symbols from the base revision
Reworks the deletion-only fix in response to review. The previous commit
anchored a `+Z,0` deletion hunk to its new-side line `Z` and fed that into
the current-file AST lookup. That heuristic is incorrect: after a deletion,
line `Z` belongs to whatever symbol now occupies it in the *new* file, so
deleting an entire top-level symbol either mis-attributes the change to the
next symbol or resolves nothing — the deleted symbol's real dependents were
still dropped.
Instead, capture the hunk's *old-side* range `-X,Y` in a new
`ChangedFile.deleted_lines` field and, downstream, re-parse the file at the
base revision (`git show <merge-base>:./path`) to resolve the top-level
symbol that enclosed each removed line. This handles both shapes uniformly:
- removing a member of a still-present declaration (object property, switch
case, interface field) resolves to the enclosing symbol, and
- removing an entire exported declaration resolves to that symbol itself —
the case the anchor heuristic could not solve.
The recovered symbols are traced through the *current* import graph, where
consumers still import them, so their projects are correctly reported
affected. Deletions whose lines resolve to no declaration contribute nothing
(no regression).
Also drops the now-unreachable `has_hunks` empty-`changed_lines` branch that
review flagged: every non-deletion hunk yields new-side lines and every
deletion yields `deleted_lines`, so a file with hunks is never empty on both.
analyzer: split the top-level-symbol resolution out of `find_node_at_line`
into `find_top_level_symbols(&FileSemanticData, ...)` so it can run against a
one-off base-revision parse (`parse_source`) that never enters `self.files`;
profiler timing now wraps the call in `find_node_at_line`.
Known limitation (unchanged from before): a whole-file deletion, and a
deleted symbol reachable only via a local reference from another symbol whose
binding the deletion breaks, still fall back to package-level marking.
Tests: rewrite the three git unit tests for `deleted_lines` semantics, add a
leading-symbol-deletion case, add analyzer unit tests for `find_deleted_symbols`,
and add integration tests for whole-symbol and member deletion tracing.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test: address CodeRabbit review on #79
- git.rs: fix stale symmetric-hunk test comment that referenced the old
greedy `.*` in `LINE_RE`; describe the current explicit capture groups.
- integration: assert the directly-changed package (`lib`) is also affected in
the member-deletion test, mirroring the whole-symbol-deletion test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix: address maintainer review on #79
- types.rs: drop the unused `Default` derive on `ChangedFile` — every
construction (src + tests) sets both fields explicitly.
- report.rs: deletion causes carry `line: 0` (no surviving new-side line);
render that as "(deleted)" instead of the odd "(line 0)", and omit the
locator entirely for the symbol-less whole-file/asset line-0 case.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Noam Aharon <noam.a@lama.ai>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 8b64617 commit 5beed1e
8 files changed
Lines changed: 575 additions & 83 deletions
File tree
- src
- semantic
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
225 | 258 | | |
226 | 259 | | |
227 | 260 | | |
| |||
255 | 288 | | |
256 | 289 | | |
257 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
258 | 304 | | |
259 | 305 | | |
260 | 306 | | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
265 | 312 | | |
266 | 313 | | |
267 | 314 | | |
| 315 | + | |
268 | 316 | | |
269 | 317 | | |
270 | 318 | | |
| |||
273 | 321 | | |
274 | 322 | | |
275 | 323 | | |
276 | | - | |
| 324 | + | |
277 | 325 | | |
278 | 326 | | |
| 327 | + | |
279 | 328 | | |
280 | 329 | | |
281 | 330 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
129 | 134 | | |
130 | 135 | | |
131 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
132 | 170 | | |
133 | 171 | | |
134 | 172 | | |
| |||
187 | 225 | | |
188 | 226 | | |
189 | 227 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
202 | 250 | | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
| 251 | + | |
| 252 | + | |
215 | 253 | | |
216 | | - | |
217 | | - | |
218 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
219 | 268 | | |
220 | 269 | | |
221 | 270 | | |
222 | 271 | | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
228 | 277 | | |
229 | 278 | | |
230 | 279 | | |
| |||
240 | 289 | | |
241 | 290 | | |
242 | 291 | | |
| 292 | + | |
243 | 293 | | |
244 | 294 | | |
245 | 295 | | |
| |||
522 | 572 | | |
523 | 573 | | |
524 | 574 | | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
529 | 580 | | |
530 | | - | |
| 581 | + | |
531 | 582 | | |
532 | 583 | | |
533 | 584 | | |
| |||
544 | 595 | | |
545 | 596 | | |
546 | 597 | | |
| 598 | + | |
547 | 599 | | |
548 | 600 | | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
555 | 608 | | |
556 | | - | |
| 609 | + | |
557 | 610 | | |
558 | 611 | | |
559 | 612 | | |
| |||
568 | 621 | | |
569 | 622 | | |
570 | 623 | | |
| 624 | + | |
571 | 625 | | |
572 | 626 | | |
573 | 627 | | |
574 | 628 | | |
575 | | - | |
576 | | - | |
577 | | - | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
578 | 632 | | |
579 | 633 | | |
580 | 634 | | |
| |||
594 | 648 | | |
595 | 649 | | |
596 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
597 | 703 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1257 | 1257 | | |
1258 | 1258 | | |
1259 | 1259 | | |
| 1260 | + | |
1260 | 1261 | | |
1261 | 1262 | | |
1262 | 1263 | | |
| |||
1266 | 1267 | | |
1267 | 1268 | | |
1268 | 1269 | | |
| 1270 | + | |
1269 | 1271 | | |
1270 | 1272 | | |
1271 | 1273 | | |
| |||
1275 | 1277 | | |
1276 | 1278 | | |
1277 | 1279 | | |
| 1280 | + | |
1278 | 1281 | | |
1279 | 1282 | | |
1280 | 1283 | | |
| |||
1284 | 1287 | | |
1285 | 1288 | | |
1286 | 1289 | | |
| 1290 | + | |
1287 | 1291 | | |
1288 | 1292 | | |
1289 | 1293 | | |
| |||
1293 | 1297 | | |
1294 | 1298 | | |
1295 | 1299 | | |
| 1300 | + | |
1296 | 1301 | | |
1297 | 1302 | | |
1298 | 1303 | | |
| |||
0 commit comments