Repository navigation
refactor: share SQL analysis and enforce type safety - #238
Conversation
Coverage Report
File Coverage |
Light2Dark
left a comment
There was a problem hiding this comment.
🤖 Automated comment by Shahmir's Code Review agent running gpt-6.1-sol on Codex
✅ Approve — Three independent specialist subagent reviews found five P2 issues, addressed in 80af6a5. A fourth independent review of the fixes found no remaining actionable issues. This is an automated review conclusion, posted as a comment because the PR author cannot approve their own PR.
Additional review evidence
- Nested arrays and arrays containing
]or semicolons in strings now preserve statement boundaries. Statement splitting retains the original array/subscript interpretation of brackets. - Cursor and focus changes reuse pending/completed gutter analysis; document and configuration changes still refresh it. The original review benchmark found 300 extra parses per cursor movement, which the new parse-count checks prevent.
- Comment stripping on a 960 KB comment-heavy input improved from approximately 1,941 ms to 35 ms locally.
- Under-qualified completion again finds a nested table when a same-named namespace has no columns, while ambiguous table matches remain unresolved.
- CAST type names no longer count as binding declarations; nested declaration collisions still cause conservative refusal.
The security review found no additional introduced XSS or tooltip trust-boundary defect. Existing parser limitations for dialect-specific casts remain.
Performance follow-up is pushed in bd3b0c3 and 2bd8c69. Reference highlighting now reuses pending/completed analysis across cursor-only states, including the full editor path with linting and gutter effects. Built-in parser option changes still invalidate all analysis caches. Custom parsers and subclasses retain exact-state caching unless they explicitly provide a configuration key. Benchmark and review evidenceLocal Node v26.13.0 microbenchmarks: 20 alternating measured runs after five warmups. These measure individual operations rather than end-to-end editor latency.
Comment stripping retains roughly 1.1 ms of overhead versus main on this stress input; it also preserves token separators that the original stripper removed. An independent cache review found no actionable issues. The scanner review caught an unbounded speculative regex scan in the rewrite; that was fixed by restricting each scan to its own gap. A 128,000-literal case now runs in about 10 ms locally. The reviewer independently matched 335,923 short inputs against the previous scanner, and an additional 20,000 generated inputs matched tokenization in three modes and comment-stripping output. All 696 tests pass, including 14 Chromium tests. Strict typecheck, lint, package build, and demo build pass. The new browser test verifies that keyboard cursor movement updates reference highlights without reparsing the document. |
Light2Dark
left a comment
There was a problem hiding this comment.
🤖 Automated comment by Shahmir's Code Review agent running gpt-6.1-sol on Codex
✅ Approve — All confirmed findings from three independent reviews (two Astra specialists and Claude Fable 5.2) are addressed. Posted as a comment because the PR author cannot approve their own PR.
Findings, resolutions, and verification limits
ignoreBracketsskipped placeholders inside arrays/subscripts. Fixed in e9d2cb7, with PostgreSQL, DuckDB, and BigQuery coverage plus original-source error-offset checks.- Doubled closing brackets caused masking to swallow later literals/comments, making rename unsafe. Fixed in 76169d7 by preserving the original first-closing-bracket behavior. Tests cover CTE references, fallback table extraction, completion suppression inside literals, and actual Chromium F2 rename/undo that preserves string/comment contents.
- Nested block-comment handling could swallow all subsequent SQL for inputs accepted by MySQL, BigQuery, and SQLite. Fixed in 76169d7 by preserving the original non-nested scanner semantics, with syntax-error and statement-count coverage for all three dialects.
- Asynchronous parsing cleared gutter markers after every edit. Fixed in fe63832 by mapping existing statement ranges through edits while analysis is pending; tests cover insertion, deletion, eventual replacement, and stale-result suppression.
Fable also verified that a consumer shaped like marimo's integration typechecks against built declarations. The real downstream marimo application was not built. Browser verification is Chromium only. No review or test run establishes universal regression-freedom.
Custom parsers and NodeSqlParser subclasses remain state-scoped unless they implement getCacheKey(state), so cursor moves can reparse in those integrations. The concise README now points custom-parser users to that opt-in. The previously disclosed small comment-stress overhead remains. Legacy integrations must adopt shared analysis to receive its cross-feature savings.
Latest local verification on the final code: 712 tests pass, including 14 Chromium tests; strict typecheck, non-mutating lint, package build, and demo build pass. CI is rerunning for 98aac68.
any, casts, non-null assertions, and TypeScript suppressions. Validate external ASTs into stricter internal representations while preserving extensible public parser/result and namespace interfaces.Existing sanitizer subclass hooks, per-feature parser defaults, and peer dependency requirements remain compatible. A parser configured through
linterConfigstill applies to syntax linting, semantic linting, and navigation, while hover and gutter retain independent defaults. Sharing a custom parser across all features is opt-in through the new top-level analysis options.createSqlAnalysisshares dependencies across extension and completion bundles.needsRefreshrefreshes linting and gutter state when parser configuration changes without an edit. The unused hoverdialectoption is deprecated for compatibility.The demo normalizes all six dialect choices, updates parser state and SQL language together, and re-registers schema-aware completion sources when switching languages.
Review follow-up preserves array and subscript statement boundaries, restores column-completion fallback when namespace names collide, and distinguishes CAST types from binding declarations. Gutter selection and focus updates reuse analysis; comment stripping avoids repeatedly processing accumulated output.
The built-in parser now reuses parse, structure, and query-context analysis across cursor-only states with the same document and options. Dialect and parser-option changes still invalidate results. Custom parsers and subclasses remain state-scoped unless they provide
getCacheKey(state). Document caches use weak ownership and bound configuration variants. Comment stripping walks quoted/comment spans without constructing the full token list.The scanner preserves the original first-closing-bracket and non-nested block-comment behavior. Pending gutter markers map through edits until fresh analysis arrives, so asynchronous parsers do not clear the gutter on each keystroke.
User-visible dialect correction:
BigQueryDialectnow inherits PostgreSQL keyword and type definitions fromPostgreSQL.spec, fixing its base dialect configuration.