mz-deploy: report statement offsets in raw-file coordinates (DEX-60) - #37377
mz-deploy: report statement offsets in raw-file coordinates (DEX-60)#37377sjwiesman wants to merge 3 commits into
Conversation
Statement byte offsets were computed against the variable-resolved SQL, but every consumer (the CLI diagnostic renderer and the LSP) reads the raw file. A `:var` whose value differs in length from the reference shifted all later offsets, so diagnostics pointed at the wrong span and could miss the token entirely. Map each offset back to the raw file with the substitution table at parse time, fixing both consumers at the source. Ticket: DEX-60 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
One follow-up worth adding: the clamp branch in It's reachable when a variable's value contains a Lower priority, also uncovered: multiple substitutions before a statement (cumulative delta), and a resolved + unresolved variable interleaved (delta staying correct across a reference that isn't recorded as a substitution). |
|
@tonydu-mz pushed a fix |
Add end-to-end coverage for the clamp branch in `resolved_to_original`, which was only exercised by unit tests with hand-built substitutions. A variable value containing `;` injects a statement separator absent from the raw file, so the following statement begins inside the substitution's resolved span. The new test asserts its offset clamps back to the reference and stays within the raw file's bounds. A second test covers cumulative delta across multiple substitutions before a statement. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
will look into this tonight |
Statement byte offsets were computed against the variable-resolved SQL,
but every consumer (the CLI diagnostic renderer and the LSP) reads the
raw file. A
:varwhose value differs in length from the referenceshifted all later offsets, so diagnostics pointed at the wrong span and
could miss the token entirely. Map each offset back to the raw file with
the substitution table at parse time, fixing both consumers at the
source.
Ticket: DEX-60
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
🤖 Generated with Claude Code
https://claude.ai/code/session_01VAcnVpSQi8ZgF5LekQRwvw