fix: harden parser edge cases - #11
Conversation
GabrielBBaldez
left a comment
There was a problem hiding this comment.
Verified: buildPlugin produces the zip, 7/7 in :core, and I ran the parser against the authoritative golden fixtures in the main repo —
full-report.txt -> 1 report, culprit=OrderService.java:87
no-throwable.txt -> 1 report, culprit=null
rich-report.txt -> 1 report, culprit=PaymentService.java:44
That middle line is the one I care about, and it composes with your #10: no-throwable now honestly reports no culprit instead of picking an unrelated frame, and the message you made reachable last time is what the user sees. Two PRs, one working behaviour.
The part that does the real work is markedFrameFound. Dropping the frame was the easy half; not falling back to frames.get(0) when a marked frame existed but was unusable is what stops the silent jump to the wrong file, and it's easy to miss that those are separate conditions.
Also noticed kts is ordered before kt in the alternation. That has to be that way — with kt first the engine matches .kt, needs :, finds s, and the whole frame fails. Your test covers it, so it can't silently regress.
Two notes:
The two parsers are deliberate twins and this lands the fix on one side. stacktale-vscode#5 is the same three bugs in TypeScript and is still open — the VS Code side still does if (!culprit && frames.length) culprit = frames[0] with no guard. If you want it, this implementation is the reference; if not I'll point whoever takes it here.
Whitespace: the blank lines between methods came out in both files, in the source and the test. I'll put them back on merge rather than send you round again.
Merging.
Summary
st/1blocks until their closingENDdelimiter is present.ktsframesWhy
The parser previously emitted incomplete reports caught mid-write, ignored negative frame line numbers and silently navigated to a different frame, and failed to recognize non-ASCII filenames. Oversized line numbers could also throw and stop parsing.
Validation
./gradlew.bat :core:test./gradlew.bat test./gradlew.bat buildPlugingit diff --checkCloses #7