Skip to content

Establish complete source spans and diagnostics - #328

Merged
git-hulk merged 1 commit into
masterfrom
codex/source-spans-diagnostics
Sep 14, 2026
Merged

git-hulk merged 1 commit into
masterfrom
codex/source-spans-diagnostics

Conversation

@git-hulk

@git-hulk git-hulk commented Sep 14, 2026

Copy link
Copy Markdown
Member

Make token-backed AST spans complete half-open byte ranges for strings,
placeholders, stars, function calls, query parameters, and set-operation
queries. Improve caret rendering for tabs and Unicode while preserving
byte-based diagnostic columns.

Before applying this PR:

Several exported spans excluded delimiters or were empty, including string
literals, function calls, stars, placeholders, and query roots with set
operations. Caret indentation treated byte offsets as display columns.

After this PR:

These nodes cover their complete source syntax, query roots contain their
set-operation descendants, and diagnostic carets use terminal display width.
AST golden files record the intentional span migration.

Verification:

  • make test passed.
  • make update_test passed.
  • make lint remains blocked because golangci-lint v1.53.3 rejects the
    repository configuration format.

Migration note: consumers relying on historical string or function end
positions must adopt complete half-open byte spans.

Assistant-By GPT-5

@git-hulk git-hulk changed the title codex/source spans diagnostics Establish complete source spans and diagnostics Sep 14, 2026
@git-hulk
git-hulk force-pushed the codex/source-spans-diagnostics branch from 765a403 to 921c028 Compare September 14, 2026 10:19
Make token-backed AST spans complete half-open byte ranges for strings,
placeholders, stars, function calls, query parameters, and set-operation
queries. Improve caret rendering for tabs and Unicode while preserving
byte-based diagnostic columns.

Before applying this PR:

Several exported spans excluded delimiters or were empty, including string
literals, function calls, stars, placeholders, and query roots with set
operations. Caret indentation treated byte offsets as display columns.

After this PR:

These nodes cover their complete source syntax, query roots contain their
set-operation descendants, and diagnostic carets use terminal display width.
AST golden files record the intentional span migration.

Verification:

- make test passed.
- make update_test passed.
- make lint remains blocked because golangci-lint v1.53.3 rejects the
  repository configuration format.

Migration note: consumers relying on historical string or function end
positions must adopt complete half-open byte spans.

Assistant-By GPT-5
@git-hulk
git-hulk force-pushed the codex/source-spans-diagnostics branch from 921c028 to 1b3cc46 Compare September 14, 2026 10:19
@git-hulk
git-hulk marked this pull request as ready for review September 14, 2026 10:21
@git-hulk
git-hulk merged commit 7923712 into master Sep 14, 2026
4 of 5 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-14T10:26:22.941582Z 1b3cc46 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b3cc468b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread parser/ast.go
Comment on lines 3017 to +3018
func (f *FunctionExpr) End() Pos {
return f.Params.RightParenPos
return f.Params.RightParenPos + 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Extend function spans through parametric arguments

For parametric aggregate calls, Params.ColumnArgList contains the second argument list, but this end position still stops after the first list. For example, parsing SELECT quantile(0.9)(x) reports the function and root query ending after quantile(0.9), excluding (x), so source-rewriting consumers receive an incomplete span. Use the trailing ColumnArgList end when it is present.

Useful? React with 👍 / 👎.

Comment thread parser/error.go
Comment on lines +83 to +84
if e.Got != nil && displayWidth(e.Got.String) > width {
width = displayWidth(e.Got.String)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Size string-token carets from the complete source span

After string token positions were changed to include their quotes, Got.String still contains only the unquoted literal contents. Consequently, an error on 'abc' now starts the caret at the opening quote but emits only three carets instead of covering the five-character token; escaped or doubled quotes produce similarly inaccurate diagnostics. Compute the underline width from the token's source span, including delimiters.

Useful? React with 👍 / 👎.

Comment thread parser/source.go
Comment on lines +71 to +76
func eastAsianWide(r rune) bool {
return r >= 0x1100 && (r <= 0x115f || r == 0x2329 || r == 0x232a ||
(r >= 0x2e80 && r <= 0xa4cf) || (r >= 0xac00 && r <= 0xd7a3) ||
(r >= 0xf900 && r <= 0xfaff) || (r >= 0xfe10 && r <= 0xfe19) ||
(r >= 0xfe30 && r <= 0xfe6f) || (r >= 0xff00 && r <= 0xff60) ||
(r >= 0xffe0 && r <= 0xffe6))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include supplementary wide runes in caret widths

The new width table stops at BMP ranges, so supplementary characters that occupy two terminal cells—such as CJK Extension B rune 𠀀 and common emoji—fall through to width one. When such a rune appears before a later syntax error, for example in SELECT '𠀀' 123, the rendered caret is shifted one column left. Use a complete terminal-width implementation or include the applicable supplementary wide ranges.

Useful? React with 👍 / 👎.

@git-hulk
git-hulk deleted the codex/source-spans-diagnostics branch September 15, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant