Commit b0a76da
authored
feat(vnext): expose statement boundaries (#201)
## Summary
- expose synchronous, revision-stamped `statementBoundaryAt` and
`statementBoundariesIntersecting` session queries
- preserve exact/no-code/opaque lexical states without leaking the
private statement index
- add scanner-owned `code` spans that exclude separator trivia and form
a strict `hasCode` discriminated union
- validate request envelopes as own data properties without invoking
host accessors
- retain incremental index reuse and shift code spans with exact UTF-16
coordinates
- add public type, package smoke, hostile-input, affinity, opacity,
masking, intersection, and documentation coverage
## Verification
- 43 test files; 2,045 passed and 1 expected failure
- changed coverage: 97.92% statements, 96.12% branches, 100% functions,
98.07% lines
- all source/test/strict/loose/demo TypeScript configurations pass
- oxlint, test integrity, build, and runtime export smoke pass
- cold point lookup measured 3.59 ms at 1 MiB and 42.67 ms at the 16 MiB
source ceiling; warm viewport intersection measured 0.075–0.096 ms
- two independent exact-head adversarial reviews approve
`c901544ff41480bb1e7ea2ddcab3af477dc8103f`
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Expose synchronous, revision-stamped statement boundary queries in the
vNext session API so editors and runners can locate executable SQL
without re-lexing. Adds an exact/opaque boundary model with precise
UTF-16 ranges and a `code` span for execution.
- **New Features**
- Added `session.statementBoundaryAt({ affinity, position })` and
`session.statementBoundariesIntersecting({ from, to })`; results are
frozen and include the current `revision`.
- Exact boundaries expose `extent`, `source`, optional `terminator`,
lexical `endState`, and a `code` span that excludes separator trivia;
discriminated by `hasCode`.
- Opaque boundaries report a `reason` for non-executable regions
(procedural blocks, custom delimiters, resource limits).
- All ranges map to the original document’s UTF-16 positions and respect
masked embedded regions.
- Inputs are strictly validated (own data properties only); invalid
requests throw `SqlSessionError` with
`invalid-statement-boundary-request`.
- Exported new types via `@marimo-team/codemirror-sql/vnext`:
`SqlStatementBoundary*`, `SqlStatementAffinity`,
`SqlStatementLexicalEnd`, and related request/result shapes.
<sup>Written for commit c901544.
Summary will update on new commits.</sup>
<a
href="https://cubic.dev/pr/marimo-team/codemirror-sql/pull/201?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->1 parent e052af6 commit b0a76da
10 files changed
Lines changed: 838 additions & 12 deletions
File tree
- docs/vnext
- scripts
- src/vnext
- __tests__
- codemirror/__tests__
- test/vnext-types
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
17 | 58 | | |
18 | 59 | | |
19 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
210 | 217 | | |
211 | 218 | | |
212 | 219 | | |
| |||
229 | 236 | | |
230 | 237 | | |
231 | 238 | | |
| 239 | + | |
232 | 240 | | |
233 | 241 | | |
234 | 242 | | |
| |||
265 | 273 | | |
266 | 274 | | |
267 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
268 | 280 | | |
269 | 281 | | |
270 | 282 | | |
271 | 283 | | |
272 | 284 | | |
273 | 285 | | |
| 286 | + | |
274 | 287 | | |
275 | 288 | | |
276 | 289 | | |
| |||
349 | 362 | | |
350 | 363 | | |
351 | 364 | | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
352 | 379 | | |
353 | 380 | | |
354 | 381 | | |
| |||
0 commit comments