sqllens 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -74
- package/THIRD-PARTY-NOTICES.md +75 -5
- package/dist/api.d.ts +7 -3
- package/dist/api.js +13 -4
- package/dist/bigquery/behavior.d.ts +2 -0
- package/dist/bigquery/behavior.js +20 -0
- package/dist/bigquery/dot-path.d.ts +0 -2
- package/dist/bigquery/dot-path.js +0 -1
- package/dist/bigquery/fn-docs.generated.d.ts +2 -0
- package/dist/bigquery/fn-docs.generated.js +1704 -0
- package/dist/bigquery/fold.d.ts +8 -0
- package/dist/bigquery/fold.js +39 -0
- package/dist/bigquery/index.d.ts +7 -0
- package/dist/bigquery/index.js +10 -0
- package/dist/{infer/bigquery.d.ts → bigquery/infer.d.ts} +2 -2
- package/dist/{infer/bigquery.js → bigquery/infer.js} +4 -3
- package/dist/bigquery/lower.js +35 -12
- package/dist/bigquery/signatures.generated.d.ts +6 -0
- package/dist/bigquery/signatures.generated.js +1068 -0
- package/dist/completion/atn-walk.d.ts +13 -2
- package/dist/completion/atn-walk.js +13 -10
- package/dist/completion/complete.d.ts +4 -3
- package/dist/completion/complete.js +101 -45
- package/dist/completion/jinja-slot.d.ts +24 -0
- package/dist/completion/jinja-slot.js +131 -0
- package/dist/completion/parser-factory.d.ts +13 -1
- package/dist/completion/parser-factory.js +12 -0
- package/dist/databricks/behavior.d.ts +2 -0
- package/dist/databricks/behavior.js +19 -0
- package/dist/databricks/fn-docs.generated.d.ts +2 -0
- package/dist/databricks/fn-docs.generated.js +3257 -0
- package/dist/databricks/fold.d.ts +8 -0
- package/dist/databricks/fold.js +27 -0
- package/dist/databricks/index.d.ts +7 -0
- package/dist/databricks/index.js +10 -0
- package/dist/databricks/infer.d.ts +6 -0
- package/dist/databricks/infer.js +638 -0
- package/dist/databricks/signatures.generated.d.ts +6 -0
- package/dist/databricks/signatures.generated.js +1745 -0
- package/dist/dialect-behavior/behavior.d.ts +26 -0
- package/dist/dialect-behavior/behavior.js +1 -0
- package/dist/dialect-behavior/carrier.d.ts +5 -0
- package/dist/dialect-behavior/carrier.js +5 -0
- package/dist/dialect-behavior/coerce-rules.d.ts +7 -0
- package/dist/dialect-behavior/coerce-rules.js +69 -0
- package/dist/dialect-behavior/public-fold.d.ts +6 -0
- package/dist/dialect-behavior/public-fold.js +9 -0
- package/dist/dialect-behavior/registry.d.ts +6 -0
- package/dist/dialect-behavior/registry.js +34 -0
- package/dist/dialect-symbols.js +16 -19
- package/dist/document/document.d.ts +1 -1
- package/dist/document/document.js +8 -7
- package/dist/duckdb/behavior.d.ts +2 -0
- package/dist/duckdb/behavior.js +21 -0
- package/dist/duckdb/fn-docs.generated.d.ts +2 -0
- package/dist/duckdb/fn-docs.generated.js +2051 -0
- package/dist/duckdb/fold.d.ts +8 -0
- package/dist/duckdb/fold.js +31 -0
- package/dist/duckdb/index.d.ts +7 -0
- package/dist/duckdb/index.js +10 -0
- package/dist/{infer/duckdb.d.ts → duckdb/infer.d.ts} +2 -2
- package/dist/{infer/duckdb.js → duckdb/infer.js} +4 -3
- package/dist/duckdb/lower.js +47 -15
- package/dist/duckdb/signatures.generated.d.ts +6 -0
- package/dist/duckdb/signatures.generated.js +1072 -0
- package/dist/generated/bigquery/GoogleSQLParser.js +0 -7060
- package/dist/generated/databricks/DatabricksParser.js +0 -4800
- package/dist/generated/duckdb/DuckdbParser.js +0 -9100
- package/dist/generated/minijinja/MinijinjaParser.js +0 -380
- package/dist/generated/mysql/MysqlParser.js +0 -6330
- package/dist/generated/postgres/PostgresParser.js +0 -8530
- package/dist/generated/redshift/RedshiftParser.js +0 -10970
- package/dist/generated/snowflake/SnowflakeParser.js +0 -7320
- package/dist/generated/sqlite/SqliteParser.js +0 -1150
- package/dist/generated/trino/TrinoParser.js +0 -3770
- package/dist/generated/tsql/TSqlParser.js +0 -8420
- package/dist/ident/fold.d.ts +27 -15
- package/dist/ident/fold.js +14 -194
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -8
- package/dist/infer/functions.d.ts +22 -11
- package/dist/infer/functions.js +26 -888
- package/dist/infer/infer.js +16 -14
- package/dist/infer/nullability.js +3 -4
- package/dist/infer/types.d.ts +1 -1
- package/dist/infer/types.js +10 -7
- package/dist/ir/ir.d.ts +26 -17
- package/dist/ir/span.js +0 -2
- package/dist/ir/walk.js +3 -3
- package/dist/lineage/hops.js +13 -10
- package/dist/lineage/lineage.js +10 -7
- package/dist/minijinja/apply-tags.d.ts +14 -7
- package/dist/minijinja/apply-tags.js +66 -121
- package/dist/minijinja/parse.js +5 -5
- package/dist/minijinja/tag-ast.d.ts +29 -36
- package/dist/minijinja/tag-ast.js +210 -90
- package/dist/mysql/behavior.d.ts +2 -0
- package/dist/mysql/behavior.js +21 -0
- package/dist/mysql/fn-docs.generated.d.ts +2 -0
- package/dist/mysql/fn-docs.generated.js +1204 -0
- package/dist/mysql/fold.d.ts +8 -0
- package/dist/mysql/fold.js +49 -0
- package/dist/mysql/index.d.ts +7 -0
- package/dist/mysql/index.js +10 -0
- package/dist/{infer/mysql.d.ts → mysql/infer.d.ts} +2 -2
- package/dist/{infer/mysql.js → mysql/infer.js} +3 -2
- package/dist/mysql/signatures.generated.d.ts +6 -0
- package/dist/mysql/signatures.generated.js +508 -0
- package/dist/parse-diagnostics.js +33 -1
- package/dist/postgres/behavior.d.ts +2 -0
- package/dist/postgres/behavior.js +19 -0
- package/dist/postgres/fn-docs.generated.d.ts +2 -0
- package/dist/postgres/fn-docs.generated.js +2818 -0
- package/dist/postgres/fold.d.ts +8 -0
- package/dist/postgres/fold.js +36 -0
- package/dist/postgres/index.d.ts +7 -0
- package/dist/postgres/index.js +10 -0
- package/dist/{infer/postgres.d.ts → postgres/infer.d.ts} +2 -2
- package/dist/{infer/postgres.js → postgres/infer.js} +4 -3
- package/dist/postgres/lower.js +2 -2
- package/dist/postgres/signatures.generated.d.ts +6 -0
- package/dist/postgres/signatures.generated.js +2973 -0
- package/dist/qualify/check-calls.js +80 -161
- package/dist/qualify/qualify.js +16 -14
- package/dist/qualify/schema-provider.js +2 -2
- package/dist/qualify/schema.js +3 -3
- package/dist/qualify/template-provider.d.ts +45 -12
- package/dist/qualify/template-provider.js +69 -38
- package/dist/redshift/behavior.d.ts +2 -0
- package/dist/redshift/behavior.js +19 -0
- package/dist/redshift/fn-docs.generated.d.ts +2 -0
- package/dist/redshift/fn-docs.generated.js +1457 -0
- package/dist/redshift/fold.d.ts +8 -0
- package/dist/redshift/fold.js +33 -0
- package/dist/redshift/index.d.ts +7 -0
- package/dist/redshift/index.js +10 -0
- package/dist/{infer/redshift.d.ts → redshift/infer.d.ts} +2 -2
- package/dist/{infer/redshift.js → redshift/infer.js} +4 -3
- package/dist/redshift/lower.js +2 -2
- package/dist/redshift/signatures.generated.d.ts +6 -0
- package/dist/redshift/signatures.generated.js +757 -0
- package/dist/references/references.js +17 -12
- package/dist/scope/like-pattern.d.ts +2 -0
- package/dist/scope/like-pattern.js +15 -0
- package/dist/scope/scope.d.ts +5 -5
- package/dist/scope/scope.js +48 -42
- package/dist/sema/resolve.js +19 -12
- package/dist/session.d.ts +2 -2
- package/dist/signature/docs.d.ts +16 -0
- package/dist/signature/docs.js +47 -0
- package/dist/signature/render.d.ts +7 -0
- package/dist/signature/render.js +40 -0
- package/dist/signature/signature.d.ts +14 -6
- package/dist/signature/signature.js +33 -25
- package/dist/signature/signatures.d.ts +14 -12
- package/dist/signature/signatures.js +42 -721
- package/dist/snowflake/behavior.d.ts +2 -0
- package/dist/snowflake/behavior.js +22 -0
- package/dist/snowflake/fn-docs.generated.d.ts +2 -0
- package/dist/snowflake/fn-docs.generated.js +2461 -0
- package/dist/snowflake/fold.d.ts +8 -0
- package/dist/snowflake/fold.js +25 -0
- package/dist/snowflake/index.d.ts +7 -0
- package/dist/snowflake/index.js +10 -0
- package/dist/{infer/snowflake.d.ts → snowflake/infer.d.ts} +2 -2
- package/dist/{infer/snowflake.js → snowflake/infer.js} +4 -3
- package/dist/snowflake/lower.js +59 -19
- package/dist/snowflake/signatures.generated.d.ts +6 -0
- package/dist/snowflake/signatures.generated.js +2080 -0
- package/dist/sqlite/behavior.d.ts +2 -0
- package/dist/sqlite/behavior.js +19 -0
- package/dist/sqlite/fn-docs.generated.d.ts +2 -0
- package/dist/sqlite/fn-docs.generated.js +609 -0
- package/dist/sqlite/fold.d.ts +8 -0
- package/dist/sqlite/fold.js +39 -0
- package/dist/sqlite/index.d.ts +7 -0
- package/dist/sqlite/index.js +10 -0
- package/dist/{infer/sqlite.d.ts → sqlite/infer.d.ts} +2 -2
- package/dist/{infer/sqlite.js → sqlite/infer.js} +4 -3
- package/dist/sqlite/signatures.generated.d.ts +6 -0
- package/dist/sqlite/signatures.generated.js +277 -0
- package/dist/symbols/symbols.js +14 -12
- package/dist/trino/behavior.d.ts +2 -0
- package/dist/trino/behavior.js +21 -0
- package/dist/trino/fn-docs.generated.d.ts +2 -0
- package/dist/trino/fn-docs.generated.js +1932 -0
- package/dist/trino/fold.d.ts +8 -0
- package/dist/trino/fold.js +39 -0
- package/dist/trino/index.d.ts +7 -0
- package/dist/trino/index.js +10 -0
- package/dist/{infer/trino.d.ts → trino/infer.d.ts} +2 -2
- package/dist/{infer/trino.js → trino/infer.js} +4 -3
- package/dist/trino/lower.js +5 -5
- package/dist/trino/signatures.generated.d.ts +6 -0
- package/dist/trino/signatures.generated.js +968 -0
- package/dist/tsql/behavior.d.ts +2 -0
- package/dist/tsql/behavior.js +20 -0
- package/dist/tsql/fn-docs.generated.d.ts +2 -0
- package/dist/tsql/fn-docs.generated.js +1017 -0
- package/dist/tsql/fold.d.ts +8 -0
- package/dist/tsql/fold.js +34 -0
- package/dist/tsql/index.d.ts +7 -0
- package/dist/tsql/index.js +10 -0
- package/dist/tsql/infer.d.ts +16 -0
- package/dist/tsql/infer.js +289 -0
- package/dist/tsql/lower.js +4 -4
- package/dist/tsql/signatures.generated.d.ts +6 -0
- package/dist/tsql/signatures.generated.js +640 -0
- package/package.json +5 -10
- package/dist/generated/bigquery/GoogleSQLLexer.d.ts +0 -407
- package/dist/generated/bigquery/GoogleSQLParser.d.ts +0 -9558
- package/dist/generated/bigquery/GoogleSQLParserListener.d.ts +0 -7777
- package/dist/generated/bigquery/GoogleSQLParserListener.js +0 -7070
- package/dist/generated/databricks/DatabricksLexer.d.ts +0 -566
- package/dist/generated/databricks/DatabricksParser.d.ts +0 -7771
- package/dist/generated/databricks/DatabricksParserListener.d.ts +0 -5737
- package/dist/generated/databricks/DatabricksParserListener.js +0 -5256
- package/dist/generated/duckdb/DuckdbLexer.d.ts +0 -691
- package/dist/generated/duckdb/DuckdbParser.d.ts +0 -13932
- package/dist/generated/duckdb/DuckdbParserListener.d.ts +0 -10049
- package/dist/generated/duckdb/DuckdbParserListener.js +0 -9138
- package/dist/generated/minijinja/MinijinjaLexer.d.ts +0 -108
- package/dist/generated/minijinja/MinijinjaParser.d.ts +0 -604
- package/dist/generated/minijinja/MinijinjaParserListener.d.ts +0 -449
- package/dist/generated/minijinja/MinijinjaParserListener.js +0 -410
- package/dist/generated/mysql/MysqlLexer.d.ts +0 -1198
- package/dist/generated/mysql/MysqlParser.d.ts +0 -10992
- package/dist/generated/mysql/MysqlParserListener.d.ts +0 -7592
- package/dist/generated/mysql/MysqlParserListener.js +0 -6958
- package/dist/generated/postgres/PostgresLexer.d.ts +0 -663
- package/dist/generated/postgres/PostgresParser.d.ts +0 -12963
- package/dist/generated/postgres/PostgresParserListener.d.ts +0 -9408
- package/dist/generated/postgres/PostgresParserListener.js +0 -8554
- package/dist/generated/redshift/RedshiftLexer.d.ts +0 -954
- package/dist/generated/redshift/RedshiftParser.d.ts +0 -16939
- package/dist/generated/redshift/RedshiftParserListener.d.ts +0 -12092
- package/dist/generated/redshift/RedshiftParserListener.js +0 -10994
- package/dist/generated/snowflake/SnowflakeLexer.d.ts +0 -1046
- package/dist/generated/snowflake/SnowflakeParser.d.ts +0 -14196
- package/dist/generated/snowflake/SnowflakeParserListener.d.ts +0 -8063
- package/dist/generated/snowflake/SnowflakeParserListener.js +0 -7330
- package/dist/generated/sqlite/SqliteLexer.d.ts +0 -210
- package/dist/generated/sqlite/SqliteParser.d.ts +0 -2115
- package/dist/generated/sqlite/SqliteParserListener.d.ts +0 -1276
- package/dist/generated/sqlite/SqliteParserListener.js +0 -1160
- package/dist/generated/trino/TrinoLexer.d.ts +0 -381
- package/dist/generated/trino/TrinoParser.d.ts +0 -5340
- package/dist/generated/trino/TrinoParserListener.d.ts +0 -4704
- package/dist/generated/trino/TrinoParserListener.js +0 -4326
- package/dist/generated/tsql/TSqlLexer.d.ts +0 -1278
- package/dist/generated/tsql/TSqlParser.d.ts +0 -17267
- package/dist/generated/tsql/TSqlParserListener.d.ts +0 -9697
- package/dist/generated/tsql/TSqlParserListener.js +0 -8854
- package/dist/infer/dialect.d.ts +0 -21
- package/dist/infer/dialect.js +0 -100
- package/dist/infer/literals.d.ts +0 -6
- package/dist/infer/literals.js +0 -44
- package/dist/signature/generated/tsql.d.ts +0 -3
- package/dist/signature/generated/tsql.js +0 -260
package/README.md
CHANGED
|
@@ -15,9 +15,7 @@ Athena, Fabric, and MariaDB (see [Dialects](#dialects)).
|
|
|
15
15
|
|
|
16
16
|
The front end is error-tolerant and token-first, so the library drives editor
|
|
17
17
|
features (completion, hover, diagnostics, go-to-definition) over incomplete,
|
|
18
|
-
mid-edit text. See [Editor / language tooling](#editor--language-tooling).
|
|
19
|
-
(Language Server Protocol) server built on it lives in the repo, but it is
|
|
20
|
-
experimental and not part of the published package.
|
|
18
|
+
mid-edit text. See [Editor / language tooling](#editor--language-tooling).
|
|
21
19
|
|
|
22
20
|
```bash
|
|
23
21
|
npm install sqllens
|
|
@@ -208,7 +206,7 @@ import { parse, qualify, lineage, deriveSymbols, toScopes, Schema } from "sqllen
|
|
|
208
206
|
const { ast, errors, cst } = parse("SELECT a, b FROM t", "snowflake");
|
|
209
207
|
// ast = dialect-neutral IR (frozen); cst = the raw antlr tree (escape hatch)
|
|
210
208
|
|
|
211
|
-
const scopes = toScopes(ast
|
|
209
|
+
const scopes = toScopes(ast); // idempotent lift
|
|
212
210
|
qualify(scopes, schema); // reuses scopes — never re-parses or re-resolves
|
|
213
211
|
lineage(scopes, schema); // safe on the same scopes, in any order
|
|
214
212
|
deriveSymbols(scopes); // independent results
|
|
@@ -381,76 +379,6 @@ doc.tokenAt(7); // token under an offset
|
|
|
381
379
|
const next = doc.withText("SELECT amount, id FROM sales", 2); // immutable edit → new doc
|
|
382
380
|
```
|
|
383
381
|
|
|
384
|
-
## Language server (experimental)
|
|
385
|
-
|
|
386
|
-
An LSP (Language Server Protocol) server built on the library lives in `src/lsp/`.
|
|
387
|
-
It is experimental and **not part of the published npm package**: the package ships
|
|
388
|
-
the library only, and the server is source you run from the repo. It holds one
|
|
389
|
-
`SqlDocument` per open file (rebuilt on edit) and reaches the library only through
|
|
390
|
-
the public API, and adds no analysis of its own beyond protocol translation.
|
|
391
|
-
|
|
392
|
-
A SQL server needs only a subset of LSP's ~30 request types: some don't apply to
|
|
393
|
-
SQL (type hierarchy, document color, monikers), and a few are deferred (formatting,
|
|
394
|
-
project-wide navigation). Where the server stands today, feature by feature:
|
|
395
|
-
|
|
396
|
-
### Language features
|
|
397
|
-
|
|
398
|
-
| Feature | Status |
|
|
399
|
-
| --- | --- |
|
|
400
|
-
| Completion (+ resolve) | ✅ |
|
|
401
|
-
| Hover | ✅ |
|
|
402
|
-
| Hover — nullability | ✅ (` — not null` / ` — nullable` suffix when provable) |
|
|
403
|
-
| Signature help | ✅ |
|
|
404
|
-
| Go to definition | ✅ |
|
|
405
|
-
| Find references | ✅ |
|
|
406
|
-
| Document highlight | ✅ |
|
|
407
|
-
| Document symbols | ✅ |
|
|
408
|
-
| Folding range | ✅ |
|
|
409
|
-
| Selection range | ✅ |
|
|
410
|
-
| Semantic tokens (full / range / delta) | ✅ all three |
|
|
411
|
-
| Inlay hints | ✅ (no resolve) |
|
|
412
|
-
| Code lens | ✅ (no resolve) |
|
|
413
|
-
| Go to declaration | ◻️ not yet |
|
|
414
|
-
| Go to type definition | ◻️ not yet |
|
|
415
|
-
| Go to implementation | ◻️ not yet — name → its defining query (view / model); needs the project model |
|
|
416
|
-
| Call hierarchy | ◻️ not yet — the CTE / view / model dependency graph |
|
|
417
|
-
| Document link | ◻️ not yet |
|
|
418
|
-
| Linked editing range | ◻️ not yet — live alias / name sync-edit |
|
|
419
|
-
| Code action (quick fixes) | ◻️ next phase |
|
|
420
|
-
| Rename (+ prepare) | ◻️ next phase |
|
|
421
|
-
| Formatting / range / on-type | ◻️ deferred (external formatter) |
|
|
422
|
-
| Inline values | ◻️ debugger surface |
|
|
423
|
-
| Type hierarchy | — n/a — SQL has no type-inheritance relation |
|
|
424
|
-
| Document color | — n/a — no color literals |
|
|
425
|
-
| Moniker | — n/a — LSIF / cross-repo indexing concern |
|
|
426
|
-
|
|
427
|
-
### Diagnostics & document sync
|
|
428
|
-
|
|
429
|
-
| Feature | Status |
|
|
430
|
-
| --- | --- |
|
|
431
|
-
| Diagnostics — push (`publishDiagnostics`) | ✅ |
|
|
432
|
-
| Diagnostics — call signature (arity / argument type) | ✅ (curated tables; never-wrong, per-dialect coercion) |
|
|
433
|
-
| Diagnostics — pull (document) | ✅ |
|
|
434
|
-
| Diagnostics — pull (workspace) | ◻️ not yet |
|
|
435
|
-
| Text sync — open / change / close | ✅ (full-document) |
|
|
436
|
-
| Incremental sync | ◻️ full-document only (fine at SQL file sizes) |
|
|
437
|
-
| Save notifications (`didSave` / `willSave`) | ◻️ not yet |
|
|
438
|
-
| Notebook document sync | ◻️ not yet |
|
|
439
|
-
|
|
440
|
-
### Workspace features
|
|
441
|
-
|
|
442
|
-
| Feature | Status |
|
|
443
|
-
| --- | --- |
|
|
444
|
-
| Workspace symbols | ◻️ needs a project / multi-file model |
|
|
445
|
-
| Execute command | ◻️ not yet |
|
|
446
|
-
| Configuration / watched-files | ◻️ not yet (protocol config; file-based `.sqllens.json` config exists) |
|
|
447
|
-
| File operations (create / rename / delete) | ◻️ not yet |
|
|
448
|
-
|
|
449
|
-
Legend: ✅ implemented · ◻️ not yet / deferred · — not applicable to SQL. The
|
|
450
|
-
deferred items are tracked work: rename and
|
|
451
|
-
code actions are the next LSP phase, workspace symbols need the project model,
|
|
452
|
-
and formatting is expected to wrap an existing external formatter.
|
|
453
|
-
|
|
454
382
|
## How sqllens compares
|
|
455
383
|
|
|
456
384
|
The SQL-parser field splits into parse-only libraries and semantic tools bound
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -120,14 +120,84 @@ Forked from [antlr/grammars-v4](https://github.com/antlr/grammars-v4)
|
|
|
120
120
|
Positive Technologies; (c) 2017 Ivan Khudyashev. Licensed under the MIT License
|
|
121
121
|
(full text retained in the file headers).
|
|
122
122
|
|
|
123
|
+
## Doc-derived function-signature and function-docs tables (distributed in this repository)
|
|
124
|
+
|
|
125
|
+
The generated per-dialect function-signature tables and their per-name docs
|
|
126
|
+
companions (`signatures.generated.ts` / `fn-docs.generated.ts`, produced by
|
|
127
|
+
`tools/harvest-signatures.mjs`, committed under `src/`) carry factual API-surface
|
|
128
|
+
data (function names, parameter names, arity, optionality) and links to each
|
|
129
|
+
dialect's reference documentation. For the permissively licensed sources listed
|
|
130
|
+
below, the docs tables additionally reproduce one descriptive sentence per
|
|
131
|
+
function, extracted verbatim from the source and marked `origin: "vendor-docs"`.
|
|
132
|
+
Sources and their licenses:
|
|
133
|
+
|
|
134
|
+
### T-SQL signatures, from MicrosoftDocs/sql-docs (CC BY 4.0)
|
|
135
|
+
|
|
136
|
+
Derived from the Transact-SQL reference markdown in
|
|
137
|
+
[MicrosoftDocs/sql-docs](https://github.com/MicrosoftDocs/sql-docs), (c) Microsoft
|
|
138
|
+
Corporation, licensed [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
|
|
139
|
+
Changes were made: the documented syntax notation was mechanically parsed and
|
|
140
|
+
transformed into TypeScript signature tables, and the docs table reproduces each
|
|
141
|
+
function page's first descriptive sentence (truncated to one sentence, whitespace
|
|
142
|
+
collapsed); no other documentation prose is reproduced.
|
|
143
|
+
|
|
144
|
+
### DuckDB signatures, from duckdb/duckdb-web (MIT)
|
|
145
|
+
|
|
146
|
+
Derived from the function reference markdown in
|
|
147
|
+
[duckdb/duckdb-web](https://github.com/duckdb/duckdb-web), Copyright 2018-2025
|
|
148
|
+
Stichting DuckDB Foundation, MIT License.
|
|
149
|
+
|
|
150
|
+
### PostgreSQL signatures, from the PostgreSQL documentation (PostgreSQL License)
|
|
151
|
+
|
|
152
|
+
Derived from `doc/src/sgml/func.sgml` of
|
|
153
|
+
[postgres/postgres](https://github.com/postgres/postgres) (REL_18_STABLE),
|
|
154
|
+
Copyright (c) 1996-2025, PostgreSQL Global Development Group, PostgreSQL License.
|
|
155
|
+
|
|
156
|
+
### Trino signatures, from trinodb/trino docs (Apache License 2.0)
|
|
157
|
+
|
|
158
|
+
Derived from the sphinx function reference in
|
|
159
|
+
[trinodb/trino](https://github.com/trinodb/trino) `docs/src/main/sphinx/functions`
|
|
160
|
+
(release 482), Apache License 2.0. trinodb/trino ships no `NOTICE` file, so there
|
|
161
|
+
is no 4(d) attribution to reproduce.
|
|
162
|
+
|
|
163
|
+
### BigQuery / GoogleSQL signatures, from google/googlesql docs (Apache License 2.0)
|
|
164
|
+
|
|
165
|
+
Derived from the function reference markdown in
|
|
166
|
+
[google/googlesql](https://github.com/google/googlesql) `docs/`, (c) Google LLC,
|
|
167
|
+
Apache License 2.0.
|
|
168
|
+
|
|
169
|
+
### Databricks descriptions, from Apache Spark's Built-in Functions reference (Apache License 2.0)
|
|
170
|
+
|
|
171
|
+
The databricks docs table's descriptions (origin `"spark-docs"`) are reproduced
|
|
172
|
+
from [Apache Spark](https://spark.apache.org)'s generated SQL Built-in Functions
|
|
173
|
+
reference (4.0.1), (c) The Apache Software Foundation, Apache License 2.0 —
|
|
174
|
+
Spark-authored prose describing the Spark SQL surface Databricks shares.
|
|
175
|
+
Databricks-only functions carry no Spark description.
|
|
176
|
+
|
|
177
|
+
### SQLite signatures and descriptions, from the sqlite.org documentation (public domain)
|
|
178
|
+
|
|
179
|
+
Derived from the [sqlite.org](https://sqlite.org) function-reference pages (doc
|
|
180
|
+
bundle 3.53.3). SQLite's code and documentation are dedicated to the
|
|
181
|
+
[public domain](https://sqlite.org/copyright.html); the docs table reproduces one
|
|
182
|
+
descriptive sentence per function.
|
|
183
|
+
|
|
184
|
+
### Databricks and Snowflake signatures, from the vendors' public SQL references
|
|
185
|
+
|
|
186
|
+
Derived from the Syntax sections of the public SQL language references at
|
|
187
|
+
[docs.databricks.com](https://docs.databricks.com) ((c) Databricks, Inc.) and
|
|
188
|
+
[docs.snowflake.com](https://docs.snowflake.com) ((c) Snowflake Inc.). These sites
|
|
189
|
+
publish no redistribution license; the tables reproduce only the factual call
|
|
190
|
+
shape of each function (name, parameter names, arity, optionality), the same facts
|
|
191
|
+
any SQL tool documents about a dialect's API surface, and no documentation prose.
|
|
192
|
+
The docs tables link each function to its page on these sites; no page text is
|
|
193
|
+
reproduced. The same applies to the Redshift
|
|
194
|
+
([docs.aws.amazon.com](https://docs.aws.amazon.com), (c) Amazon Web Services) and
|
|
195
|
+
MySQL ([dev.mysql.com](https://dev.mysql.com/doc/), (c) Oracle Corporation)
|
|
196
|
+
references: links only, no prose. Credited here as sources with thanks.
|
|
197
|
+
|
|
123
198
|
## Runtime and build dependencies (not redistributed in source)
|
|
124
199
|
|
|
125
200
|
- **antlr4ng** — the TypeScript ANTLR runtime (BSD-3-Clause). Runtime dependency.
|
|
126
201
|
- **antlr-ng** — the pure-TypeScript ANTLR generator used by `npm run gen` to
|
|
127
202
|
produce `src/generated/` (a build product, gitignored). Dev dependency.
|
|
128
|
-
- **vscode-languageserver** / **vscode-languageserver-protocol** /
|
|
129
|
-
**vscode-languageserver-textdocument** / **vscode-languageserver-types** — the
|
|
130
|
-
LSP layer's runtime dependencies (MIT).
|
|
131
|
-
- **minimatch** — glob matching used by the LSP layer (ISC).
|
|
132
|
-
|
|
133
203
|
Consult each package's own license for the authoritative terms.
|
package/dist/api.d.ts
CHANGED
|
@@ -117,10 +117,14 @@ export { SqlDocument, type DocumentAnalysis, type StatementCell, type DocumentVa
|
|
|
117
117
|
export { LineIndex } from "./document/line-index.js";
|
|
118
118
|
export type { StatementCellSpan } from "./document/split.js";
|
|
119
119
|
export { complete, completeAt, type Completion } from "./completion/complete.js";
|
|
120
|
-
export {
|
|
121
|
-
export {
|
|
120
|
+
export { jinjaSlotAt, type JinjaSlot } from "./completion/jinja-slot.js";
|
|
121
|
+
export { signatureAt, type SignatureHelpInfo, type SignatureLabel } from "./signature/signature.js";
|
|
122
|
+
export { SIGNATURES, lookupSignature, hasSignature, type FnSignature, type ParamSig } from "./signature/signatures.js";
|
|
123
|
+
export { renderSignature, type RenderSignatureOptions } from "./signature/render.js";
|
|
124
|
+
export { FN_DOCS, lookupFnDoc, type FnDoc } from "./signature/docs.js";
|
|
122
125
|
export { referencesAt, type Occurrence, type Occurrences } from "./references/references.js";
|
|
123
126
|
export { dialectSymbols, type DialectSymbols } from "./dialect-symbols.js";
|
|
124
127
|
export { CallbackSchema, type SchemaProvider, type TableResolver } from "./qualify/schema-provider.js";
|
|
125
128
|
export { DERIVED_DIALECTS, resolveDialect } from "./derived-dialects.js";
|
|
126
|
-
export { foldIdentifier, displayName
|
|
129
|
+
export { foldIdentifier, displayName } from "./dialect-behavior/public-fold.js";
|
|
130
|
+
export type { IdentKind } from "./ident/fold.js";
|
package/dist/api.js
CHANGED
|
@@ -205,11 +205,20 @@ export { LineIndex } from "./document/line-index.js";
|
|
|
205
205
|
// Scope-aware completion over a SqlDocument — the broken-input editor feature (keywords + schema
|
|
206
206
|
// tables/columns + function names at the caret). Total: never throws.
|
|
207
207
|
export { complete, completeAt } from "./completion/complete.js";
|
|
208
|
+
// The NEUTRAL half of jinja completion: which call + arg slot the caret sits in inside a jinja tag
|
|
209
|
+
// (`{{ ref('cu│` → { callee: "ref", argIndex: 0, prefix: "cu" }). Carries no dbt vocabulary; a
|
|
210
|
+
// consumer maps callee + argIndex to a role and supplies candidates. Reuses the parsed tags.
|
|
211
|
+
export { jinjaSlotAt } from "./completion/jinja-slot.js";
|
|
208
212
|
// Signature help over a SqlDocument — the broken-input editor feature that shows parameter hints
|
|
209
|
-
// while typing inside a call's parens.
|
|
210
|
-
// long tail,
|
|
213
|
+
// while typing inside a call's parens. SIGNATURES is the merged per-dialect table (curated overrides
|
|
214
|
+
// folded over the harvested doc-derived long tail at generation time, tools/harvest-signatures.mjs);
|
|
215
|
+
// a name maps to an overload SET (readonly FnSignature[]), not a single shape: it is common for a
|
|
216
|
+
// builtin to be overloaded on argument type or arity. An unknown name degrades to a one-entry
|
|
217
|
+
// name-only fallback. A pure token scan; never throws.
|
|
211
218
|
export { signatureAt } from "./signature/signature.js";
|
|
212
|
-
export {
|
|
219
|
+
export { SIGNATURES, lookupSignature, hasSignature } from "./signature/signatures.js";
|
|
220
|
+
export { renderSignature } from "./signature/render.js";
|
|
221
|
+
export { FN_DOCS, lookupFnDoc } from "./signature/docs.js";
|
|
213
222
|
// References / occurrence engine — find the declaration + every occurrence of the symbol under a
|
|
214
223
|
// cursor offset. The core primitive behind LSP references / documentHighlight / codeLens / rename.
|
|
215
224
|
// Total: never throws; returns null off-symbol.
|
|
@@ -228,4 +237,4 @@ export { DERIVED_DIALECTS, resolveDialect } from "./derived-dialects.js";
|
|
|
228
237
|
// The dialect-true identifier fold — the identity key for name comparison (unquote + case-fold per
|
|
229
238
|
// the dialect's documented rules) and its display twin (unquote only). Exported so an embedding
|
|
230
239
|
// consumer comparing names against IR/scope output folds the same way the pipeline does.
|
|
231
|
-
export { foldIdentifier, displayName } from "./
|
|
240
|
+
export { foldIdentifier, displayName } from "./dialect-behavior/public-fold.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { acceptsFor } from "../dialect-behavior/coerce-rules.js";
|
|
2
|
+
import { likePatternToRegExp } from "../scope/like-pattern.js";
|
|
3
|
+
import { SIGNATURES } from "../signature/signatures.js";
|
|
4
|
+
import { displayName, fold, foldTableName, matchesSourceKey } from "./fold.js";
|
|
5
|
+
import { bigqueryLiteral, bigqueryParseType, bigquerySpecial, BIGQUERY_FUNCTION_RETURNS } from "./infer.js";
|
|
6
|
+
export const bigqueryBehavior = {
|
|
7
|
+
fold,
|
|
8
|
+
displayName,
|
|
9
|
+
foldTableName,
|
|
10
|
+
matchesSourceKey,
|
|
11
|
+
likeMatch: (pattern, value) => likePatternToRegExp(pattern).test(value),
|
|
12
|
+
literal: bigqueryLiteral,
|
|
13
|
+
parseType: bigqueryParseType,
|
|
14
|
+
functions: BIGQUERY_FUNCTION_RETURNS,
|
|
15
|
+
division: "float",
|
|
16
|
+
special: bigquerySpecial,
|
|
17
|
+
signatures: SIGNATURES.bigquery,
|
|
18
|
+
// BigQuery implicit coercion: no STRING->NUMBER coercion, no BOOL<->NUMBER coercion (STR_TO_NUM=false, BOOL_NUM=false).
|
|
19
|
+
accepts: (argType, paramText) => acceptsFor(bigqueryParseType, false, false, argType, paramText),
|
|
20
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Lexer, ListTokenSource } from "antlr4ng";
|
|
2
|
-
import { GoogleSQLLexer } from "../generated/bigquery/GoogleSQLLexer.js";
|
|
3
2
|
import type { SyntaxDiagnostic } from "../parse-diagnostics.js";
|
|
4
3
|
/**
|
|
5
4
|
* Lex `sql` and return a token source with the DOT_IDENTIFIER rewrite applied, plus positioned
|
|
@@ -11,4 +10,3 @@ export declare function dotPathTokenSource(sql: string, lexer: Lexer): {
|
|
|
11
10
|
source: ListTokenSource;
|
|
12
11
|
escapeDiagnostics: SyntaxDiagnostic[];
|
|
13
12
|
};
|
|
14
|
-
export { GoogleSQLLexer };
|
|
@@ -365,4 +365,3 @@ export function dotPathTokenSource(sql, lexer) {
|
|
|
365
365
|
const tokens = lexer.getAllTokens(); // full lex (drives lexer error listeners); EOF excluded
|
|
366
366
|
return { source: new ListTokenSource(rewriteDotPaths(tokens)), escapeDiagnostics: badLiteralEscapes(tokens) };
|
|
367
367
|
}
|
|
368
|
-
export { GoogleSQLLexer };
|