sqllens 1.2.0 → 1.4.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/THIRD-PARTY-NOTICES.md +31 -6
- package/dist/api.d.ts +2 -0
- package/dist/api.js +2 -0
- package/dist/bigquery/fn-docs.generated.d.ts +2 -0
- package/dist/bigquery/fn-docs.generated.js +1704 -0
- package/dist/completion/complete.js +13 -4
- package/dist/completion/jinja-slot.d.ts +6 -0
- package/dist/completion/jinja-slot.js +13 -3
- package/dist/databricks/fn-docs.generated.d.ts +2 -0
- package/dist/databricks/fn-docs.generated.js +3257 -0
- package/dist/duckdb/fn-docs.generated.d.ts +2 -0
- package/dist/duckdb/fn-docs.generated.js +2051 -0
- package/dist/duckdb/fold.js +6 -4
- package/dist/ident/fold.d.ts +5 -2
- package/dist/ident/fold.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/infer/types.js +4 -1
- package/dist/minijinja/apply-tags.js +19 -10
- package/dist/mysql/fn-docs.generated.d.ts +2 -0
- package/dist/mysql/fn-docs.generated.js +1204 -0
- package/dist/parse-diagnostics.js +33 -1
- package/dist/postgres/fn-docs.generated.d.ts +2 -0
- package/dist/postgres/fn-docs.generated.js +2818 -0
- package/dist/postgres/fold.js +9 -3
- package/dist/postgres/signatures.generated.js +585 -585
- package/dist/qualify/template-provider.d.ts +5 -2
- package/dist/qualify/template-provider.js +5 -2
- package/dist/redshift/fn-docs.generated.d.ts +2 -0
- package/dist/redshift/fn-docs.generated.js +1457 -0
- package/dist/redshift/fold.js +6 -4
- package/dist/sema/resolve.js +3 -1
- 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.js +5 -5
- package/dist/snowflake/fn-docs.generated.d.ts +2 -0
- package/dist/snowflake/fn-docs.generated.js +2461 -0
- package/dist/sqlite/fn-docs.generated.d.ts +2 -0
- package/dist/sqlite/fn-docs.generated.js +609 -0
- package/dist/sqlite/fold.js +5 -7
- package/dist/trino/fn-docs.generated.d.ts +2 -0
- package/dist/trino/fn-docs.generated.js +1932 -0
- package/dist/tsql/fn-docs.generated.d.ts +2 -0
- package/dist/tsql/fn-docs.generated.js +1017 -0
- package/package.json +1 -1
|
@@ -130,20 +130,29 @@ function collect(doc, offset, schema) {
|
|
|
130
130
|
function templateCompletions(slot, schema) {
|
|
131
131
|
if (!(schema instanceof DefaultTemplateProvider))
|
|
132
132
|
return [];
|
|
133
|
-
return schema.templateCandidates(slot.
|
|
133
|
+
return schema.templateCandidates(slot.call, slot.argIndex).map((c) => ({
|
|
134
134
|
label: c.label,
|
|
135
135
|
kind: "template",
|
|
136
136
|
...(c.detail !== undefined ? { detail: c.detail } : {}),
|
|
137
137
|
}));
|
|
138
138
|
}
|
|
139
|
-
/** The walk's caret token index
|
|
140
|
-
*
|
|
141
|
-
*
|
|
139
|
+
/** The walk's caret token index. Two rules, in order (anvil 2026-07-15; antlr4-c3's own caret
|
|
140
|
+
* convention):
|
|
141
|
+
* 1. the token being TYPED — a word-like token whose span CONTAINS the caret (start < offset <=
|
|
142
|
+
* end). A caret at the end of `ifn` completes `ifn`; it does not mean the slot is filled.
|
|
143
|
+
* Word-like only: punctuation is never partially typed, so `abs(|` keeps rule 2.
|
|
144
|
+
* 2. between tokens — the first default-channel token whose `.start >= offset`; for an
|
|
145
|
+
* end-of-input caret that is the EOF sentinel's index (last entry).
|
|
146
|
+
* `toks` is the document's own token stream (doc coordinates) with the EOF sentinel appended.
|
|
147
|
+
* Source order makes one pass sufficient: a containing token starts before any `.start >= offset`
|
|
148
|
+
* token, so rule 1 fires first whenever it applies. */
|
|
142
149
|
function caretTokenIndex(toks, offset) {
|
|
143
150
|
for (let i = 0; i < toks.length; i++) {
|
|
144
151
|
const t = toks[i];
|
|
145
152
|
if (!t || t.channel !== Token.DEFAULT_CHANNEL)
|
|
146
153
|
continue;
|
|
154
|
+
if (/^\w/.test(t.text) && t.start < offset && offset <= t.start + t.text.length)
|
|
155
|
+
return i;
|
|
147
156
|
if (t.start >= offset)
|
|
148
157
|
return i;
|
|
149
158
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TemplateCall } from "../qualify/template-provider.js";
|
|
1
2
|
import type { TagNode } from "../minijinja/tag-ast.js";
|
|
2
3
|
/** Where the caret sits inside a jinja call tag. NEUTRAL, the callee is a bare string; the dbt
|
|
3
4
|
* meaning of the slot (ref arg0 = a model) is the consumer's to apply. */
|
|
@@ -6,6 +7,11 @@ export interface JinjaSlot {
|
|
|
6
7
|
callee: string;
|
|
7
8
|
/** Dotted package before the callee (`dbt_utils` in `dbt_utils.star(...)`). */
|
|
8
9
|
packageName?: string;
|
|
10
|
+
/** The WHOLE parsed call (issue #37): name, packageParts and every sibling arg's literal value
|
|
11
|
+
* (null where computed) — the same TemplateCall shape every provider method receives. A slot's
|
|
12
|
+
* candidates can depend on the other args (source('raw', '|')'s candidates are the tables OF
|
|
13
|
+
* raw), so the provider callback gets the call, not just the callee name. */
|
|
14
|
+
call: TemplateCall;
|
|
9
15
|
/** 0-based index of the positional arg the caret is in. The callee-name slot (caret still in the
|
|
10
16
|
* callee identifier, `{{ my_mac|`) is `-1`. */
|
|
11
17
|
argIndex: number;
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
// Reuses the parse: it reads the tags the document already produced, never re-parses.
|
|
19
19
|
// Total: returns undefined off any jinja completion slot; never throws.
|
|
20
20
|
// ---------------------------------------------------------------------------
|
|
21
|
+
import { callOf } from "../minijinja/apply-tags.js";
|
|
21
22
|
/**
|
|
22
23
|
* The jinja completion slot at `offset`, or undefined when the caret is not in a completable jinja
|
|
23
24
|
* position. `tags` is `parseTemplated(...).tags` (or `doc.templated.tags`); `text` is the document
|
|
@@ -82,7 +83,10 @@ function macroHit(c) {
|
|
|
82
83
|
}
|
|
83
84
|
/** The slot for a caret inside a resolved call: the callee name, or the positional argument. */
|
|
84
85
|
function slotFromCall(c, text, offset) {
|
|
85
|
-
|
|
86
|
+
// The whole call rides the slot (#37): callOf reads name + literal args off the source text,
|
|
87
|
+
// the same extraction apply-tags feeds the provider everywhere else.
|
|
88
|
+
const call = callOf({ name: c.name, nameSpan: c.nameSpan, args: c.args, ...(c.packageName !== undefined ? { packageName: c.packageName } : {}) }, text);
|
|
89
|
+
const base = { callee: c.name, call, ...(c.packageName !== undefined ? { packageName: c.packageName } : {}) };
|
|
86
90
|
// Callee-name slot: the caret is still within (or right at the end of) the callee identifier,
|
|
87
91
|
// before the open paren, the user is typing the macro name itself.
|
|
88
92
|
if (offset <= c.nameSpan.end) {
|
|
@@ -97,7 +101,12 @@ function slotFromCall(c, text, offset) {
|
|
|
97
101
|
// already ended before the caret.
|
|
98
102
|
const inArg = c.args.findIndex((a) => offset >= a.span.start && offset <= a.span.end);
|
|
99
103
|
if (inArg >= 0) {
|
|
100
|
-
return {
|
|
104
|
+
return {
|
|
105
|
+
...base,
|
|
106
|
+
argIndex: inArg,
|
|
107
|
+
prefix: stripQuote(text.slice(c.args[inArg].span.start, offset)),
|
|
108
|
+
incomplete: c.incomplete,
|
|
109
|
+
};
|
|
101
110
|
}
|
|
102
111
|
const argIndex = c.args.filter((a) => a.span.end <= offset).length;
|
|
103
112
|
return { ...base, argIndex, prefix: "", incomplete: c.incomplete };
|
|
@@ -117,7 +126,8 @@ function bareCalleeSlot(tags, text, offset) {
|
|
|
117
126
|
const m = /^\s*([A-Za-z_]\w*)$/.exec(before);
|
|
118
127
|
if (!m)
|
|
119
128
|
return undefined;
|
|
120
|
-
|
|
129
|
+
// No parsed call exists yet (`{{ re`) — the slot's call is the bare callee with no args.
|
|
130
|
+
return { callee: m[1], call: { name: m[1], args: [] }, argIndex: -1, prefix: m[1], incomplete: true };
|
|
121
131
|
}
|
|
122
132
|
/** Drop a single leading quote from a partial string arg (`'cu` -> `cu`) so the prefix is the value
|
|
123
133
|
* the consumer filters by. Leaves a non-string arg untouched. */
|