@wrongstack/tools 1.0.11 → 1.0.12
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/dist/builtin.js +15 -15
- package/dist/{chunk-GU7TZE6Z.js → chunk-2BCRQAIW.js} +7 -7
- package/dist/{chunk-XRNN44QY.js → chunk-2IRHFHZY.js} +235 -71
- package/dist/{chunk-NEYUPZL6.js → chunk-6D3UIQMF.js} +651 -303
- package/dist/chunk-BJ5LXLKE.js +351 -0
- package/dist/{chunk-C6ZOXNXV.js → chunk-CSS42GRP.js} +2 -2
- package/dist/{chunk-SKRMUHTU.js → chunk-HSLDY55L.js} +41 -8
- package/dist/{chunk-ENE22I5W.js → chunk-K37AKCTN.js} +884 -362
- package/dist/{chunk-DKXMDO5F.js → chunk-K3VX6V5P.js} +3 -3
- package/dist/chunk-OIFY4XNP.js +855 -0
- package/dist/{chunk-7GOE2ZTZ.js → chunk-OMWC2OGT.js} +2 -2
- package/dist/{chunk-IE4KDAOB.js → chunk-OYQE2UNT.js} +3 -3
- package/dist/chunk-R3HR3QI3.js +97 -0
- package/dist/{chunk-XPVYZ2S6.js → chunk-RYLMSGR5.js} +2 -2
- package/dist/{chunk-HYHE4VNA.js → chunk-UMOP3VGK.js} +79 -45
- package/dist/{chunk-6OIEYJM4.js → chunk-VMNWQI4V.js} +2 -2
- package/dist/{chunk-2UVAIS5O.js → chunk-YPSVPCIE.js} +2 -2
- package/dist/{chunk-PWZUHZP7.js → chunk-Z77XMU3U.js} +2 -2
- package/dist/codebase-index/ast-invariant-engine.d.ts +19 -2
- package/dist/codebase-index/atlas-projection.d.ts +19 -0
- package/dist/codebase-index/background-indexer.d.ts +14 -0
- package/dist/codebase-index/circuit-breaker.d.ts +7 -0
- package/dist/codebase-index/codebase-ast-replace-tool.d.ts +1 -1
- package/dist/codebase-index/codebase-impact-analysis-tool.d.ts +6 -0
- package/dist/codebase-index/codebase-invariant-check-tool.d.ts +2 -0
- package/dist/codebase-index/codebase-targeted-test-tool.d.ts +26 -0
- package/dist/codebase-index/dead-code-scan.d.ts +4 -0
- package/dist/codebase-index/go-parser.d.ts +23 -3
- package/dist/codebase-index/graph-rank-pass.d.ts +10 -0
- package/dist/codebase-index/graph-rank.d.ts +8 -0
- package/dist/codebase-index/index.d.ts +1 -1
- package/dist/codebase-index/index.js +9 -9
- package/dist/codebase-index/lsp-kind.d.ts +3 -1
- package/dist/codebase-index/module-resolver.d.ts +21 -1
- package/dist/codebase-index/parser-batch.d.ts +6 -8
- package/dist/codebase-index/parser-output.d.ts +5 -1
- package/dist/codebase-index/parser-worker-script.js +4 -4
- package/dist/codebase-index/project-server-framing.d.ts +1 -17
- package/dist/codebase-index/project-server-watcher.d.ts +6 -0
- package/dist/codebase-index/project-server.js +72 -26
- package/dist/codebase-index/py-parser.d.ts +4 -4
- package/dist/codebase-index/rs-parser.d.ts +7 -0
- package/dist/codebase-index/toolchain-scripts.d.ts +64 -0
- package/dist/codebase-index/tree-sitter/queries.d.ts +14 -0
- package/dist/codebase-index/tree-sitter/util.d.ts +6 -1
- package/dist/codebase-index/tree-sitter-parser.d.ts +7 -0
- package/dist/codebase-index/worker.js +23 -16
- package/dist/codebase-index/writer-refs.d.ts +17 -2
- package/dist/codebase-index/writer-search-helpers.d.ts +9 -0
- package/dist/codebase-index/writer.d.ts +20 -1
- package/dist/edit.js +8 -8
- package/dist/{generic-parser-N2PLGBC2.js → generic-parser-IVWLFKMR.js} +2 -2
- package/dist/go-parser-LWV3L5V7.js +197 -0
- package/dist/index.js +17 -17
- package/dist/json-parser-PERV2JHX.js +204 -0
- package/dist/pack.js +16 -16
- package/dist/parser-dispatch-ZSWCQB6M.js +14 -0
- package/dist/patch.js +8 -8
- package/dist/{py-parser-4PFZYAJ7.js → py-parser-B6D6RGH7.js} +4 -4
- package/dist/read.js +8 -8
- package/dist/replace.js +8 -8
- package/dist/rs-parser-L7SP4GWJ.js +182 -0
- package/dist/tool-tier.js +17 -17
- package/dist/{tree-sitter-parser-GILYQLS4.js → tree-sitter-parser-KU6JF3ZC.js} +6 -4
- package/dist/{ts-parser-7W26YB26.js → ts-parser-PML6QIH7.js} +55 -23
- package/dist/write.js +8 -8
- package/dist/{yaml-parser-DFBC5FWH.js → yaml-parser-7BJN544B.js} +41 -6
- package/package.json +5 -5
- package/dist/chunk-4CE3RKEP.js +0 -390
- package/dist/chunk-KHUCKLOR.js +0 -899
- package/dist/chunk-ZKC5UNGD.js +0 -167
- package/dist/go-parser-Z4H6SR3R.js +0 -474
- package/dist/json-parser-IJD77VL4.js +0 -256
- package/dist/parser-dispatch-WG4DNBHH.js +0 -14
- package/dist/rs-parser-GIWPUA3T.js +0 -81
package/dist/builtin.js
CHANGED
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
TIER2_TOOLS,
|
|
7
7
|
TIER3_TOOLS,
|
|
8
8
|
builtinTools
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2BCRQAIW.js";
|
|
10
10
|
import "./chunk-BVHKBBGA.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-K37AKCTN.js";
|
|
12
|
+
import "./chunk-2IRHFHZY.js";
|
|
13
13
|
import "./chunk-MRXWOOOR.js";
|
|
14
14
|
import "./chunk-7V33PHT6.js";
|
|
15
15
|
import "./chunk-OKZJJDOG.js";
|
|
@@ -21,7 +21,7 @@ import "./chunk-C3WP6ZOT.js";
|
|
|
21
21
|
import "./chunk-JPK2HHBK.js";
|
|
22
22
|
import "./chunk-KS2OEZWV.js";
|
|
23
23
|
import "./chunk-SPNXDTCJ.js";
|
|
24
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-YPSVPCIE.js";
|
|
25
25
|
import "./chunk-D6RQZMZS.js";
|
|
26
26
|
import "./chunk-2OCAAFAT.js";
|
|
27
27
|
import "./chunk-M4ZHHCCW.js";
|
|
@@ -31,7 +31,7 @@ import "./chunk-4IMNVQRB.js";
|
|
|
31
31
|
import "./chunk-E7A4SLKR.js";
|
|
32
32
|
import "./chunk-G7CYW5EP.js";
|
|
33
33
|
import "./chunk-UVYRQKPZ.js";
|
|
34
|
-
import "./chunk-
|
|
34
|
+
import "./chunk-CSS42GRP.js";
|
|
35
35
|
import "./chunk-ON6ET5ER.js";
|
|
36
36
|
import "./chunk-DLZCOEVG.js";
|
|
37
37
|
import "./chunk-YJTXRH5Y.js";
|
|
@@ -50,17 +50,17 @@ import "./chunk-DBG7UQGK.js";
|
|
|
50
50
|
import "./chunk-VMJY6FYJ.js";
|
|
51
51
|
import "./chunk-YZECCW3F.js";
|
|
52
52
|
import "./chunk-O2MHULBO.js";
|
|
53
|
-
import "./chunk-
|
|
54
|
-
import "./chunk-
|
|
55
|
-
import "./chunk-
|
|
53
|
+
import "./chunk-OYQE2UNT.js";
|
|
54
|
+
import "./chunk-Z77XMU3U.js";
|
|
55
|
+
import "./chunk-OMWC2OGT.js";
|
|
56
56
|
import "./chunk-MSOAX3GC.js";
|
|
57
|
-
import "./chunk-
|
|
58
|
-
import "./chunk-
|
|
59
|
-
import "./chunk-
|
|
60
|
-
import "./chunk-
|
|
61
|
-
import "./chunk-
|
|
62
|
-
import "./chunk-
|
|
63
|
-
import "./chunk-
|
|
57
|
+
import "./chunk-UMOP3VGK.js";
|
|
58
|
+
import "./chunk-RYLMSGR5.js";
|
|
59
|
+
import "./chunk-6D3UIQMF.js";
|
|
60
|
+
import "./chunk-BJ5LXLKE.js";
|
|
61
|
+
import "./chunk-R3HR3QI3.js";
|
|
62
|
+
import "./chunk-HSLDY55L.js";
|
|
63
|
+
import "./chunk-OIFY4XNP.js";
|
|
64
64
|
import "./chunk-YOHO4DVT.js";
|
|
65
65
|
import "./chunk-XHSHNOAF.js";
|
|
66
66
|
import "./chunk-XZLVJD56.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
codebaseStatsTool,
|
|
16
16
|
codebaseTargetedTestTool,
|
|
17
17
|
deadCodeScanTool
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-K37AKCTN.js";
|
|
19
19
|
import {
|
|
20
20
|
designTool
|
|
21
21
|
} from "./chunk-MRXWOOOR.js";
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
} from "./chunk-SPNXDTCJ.js";
|
|
52
52
|
import {
|
|
53
53
|
patchTool
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-YPSVPCIE.js";
|
|
55
55
|
import {
|
|
56
56
|
jsonTool
|
|
57
57
|
} from "./chunk-D6RQZMZS.js";
|
|
@@ -77,7 +77,7 @@ import {
|
|
|
77
77
|
} from "./chunk-G7CYW5EP.js";
|
|
78
78
|
import {
|
|
79
79
|
replaceTool
|
|
80
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-CSS42GRP.js";
|
|
81
81
|
import {
|
|
82
82
|
globTool
|
|
83
83
|
} from "./chunk-ON6ET5ER.js";
|
|
@@ -125,13 +125,13 @@ import {
|
|
|
125
125
|
} from "./chunk-O2MHULBO.js";
|
|
126
126
|
import {
|
|
127
127
|
readTool
|
|
128
|
-
} from "./chunk-
|
|
128
|
+
} from "./chunk-OYQE2UNT.js";
|
|
129
129
|
import {
|
|
130
130
|
writeTool
|
|
131
|
-
} from "./chunk-
|
|
131
|
+
} from "./chunk-Z77XMU3U.js";
|
|
132
132
|
import {
|
|
133
133
|
editTool
|
|
134
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-OMWC2OGT.js";
|
|
135
135
|
import {
|
|
136
136
|
resolvePowerShell
|
|
137
137
|
} from "./chunk-XZLVJD56.js";
|
|
@@ -1623,4 +1623,4 @@ export {
|
|
|
1623
1623
|
TIER3_TOOLS,
|
|
1624
1624
|
builtinTools
|
|
1625
1625
|
};
|
|
1626
|
-
//# sourceMappingURL=chunk-
|
|
1626
|
+
//# sourceMappingURL=chunk-2BCRQAIW.js.map
|
|
@@ -5,6 +5,126 @@ import * as path from "node:path";
|
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
|
|
7
7
|
// src/codebase-index/tree-sitter/queries.ts
|
|
8
|
+
var NAME_LIKE_TYPES = /* @__PURE__ */ new Set([
|
|
9
|
+
"identifier",
|
|
10
|
+
"simple_identifier",
|
|
11
|
+
"type_identifier",
|
|
12
|
+
"field_identifier",
|
|
13
|
+
"name",
|
|
14
|
+
"constant"
|
|
15
|
+
]);
|
|
16
|
+
function namedChildrenOf(node) {
|
|
17
|
+
const out = [];
|
|
18
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
19
|
+
const child = node.namedChild(i);
|
|
20
|
+
if (child) out.push(child);
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
function declaratorNames(node, declaratorTypes, containerTypes = /* @__PURE__ */ new Set()) {
|
|
25
|
+
const out = [];
|
|
26
|
+
const walk = (current, depth) => {
|
|
27
|
+
for (const child of namedChildrenOf(current)) {
|
|
28
|
+
if (declaratorTypes.has(child.type)) {
|
|
29
|
+
const id = child.childForFieldName("name") ?? namedChildrenOf(child).find((c) => NAME_LIKE_TYPES.has(c.type));
|
|
30
|
+
if (id) out.push(id.text);
|
|
31
|
+
} else if (depth < 2 && containerTypes.has(child.type)) {
|
|
32
|
+
walk(child, depth + 1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
walk(node, 0);
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
function cDeclaratorNames(node) {
|
|
40
|
+
const out = [];
|
|
41
|
+
for (const declarator of node.childrenForFieldName("declarator")) {
|
|
42
|
+
let current = declarator;
|
|
43
|
+
for (let depth = 0; current && depth < 16; depth++) {
|
|
44
|
+
if (current.type === "identifier") {
|
|
45
|
+
out.push(current.text);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
current = current.childForFieldName("declarator");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
function cDeclaresFunction(node) {
|
|
54
|
+
for (const declarator of node.childrenForFieldName("declarator")) {
|
|
55
|
+
let current = declarator;
|
|
56
|
+
for (let depth = 0; current && depth < 16; depth++) {
|
|
57
|
+
if (current.type === "function_declarator") return true;
|
|
58
|
+
current = current.childForFieldName("declarator");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
function cDeclarationKind(node) {
|
|
64
|
+
if (cDeclaresFunction(node)) return "function";
|
|
65
|
+
let parent = node.parent;
|
|
66
|
+
while (parent?.type.startsWith("preproc_")) parent = parent.parent;
|
|
67
|
+
return parent?.type === "translation_unit" ? "var" : null;
|
|
68
|
+
}
|
|
69
|
+
var C_SPECIFIER_TYPES = /* @__PURE__ */ new Set([
|
|
70
|
+
"struct_specifier",
|
|
71
|
+
"union_specifier",
|
|
72
|
+
"enum_specifier",
|
|
73
|
+
"class_specifier"
|
|
74
|
+
]);
|
|
75
|
+
function cSpecifierKind(node, kind) {
|
|
76
|
+
if (!C_SPECIFIER_TYPES.has(node.type)) return kind;
|
|
77
|
+
return node.childForFieldName("body") ? kind : null;
|
|
78
|
+
}
|
|
79
|
+
function sameNode(a, b) {
|
|
80
|
+
return a !== null && a.startIndex === b.startIndex && a.endIndex === b.endIndex;
|
|
81
|
+
}
|
|
82
|
+
function rubyInsideClass(node) {
|
|
83
|
+
for (let parent = node.parent; parent; parent = parent.parent) {
|
|
84
|
+
if (parent.type === "class" || parent.type === "module" || parent.type === "singleton_class") {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
if (parent.type === "method" || parent.type === "singleton_method") return false;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
var ELIXIR_FUNCTION_DEFS = /* @__PURE__ */ new Set([
|
|
92
|
+
"def",
|
|
93
|
+
"defp",
|
|
94
|
+
"defmacro",
|
|
95
|
+
"defmacrop",
|
|
96
|
+
"defguard",
|
|
97
|
+
"defguardp",
|
|
98
|
+
"defdelegate"
|
|
99
|
+
]);
|
|
100
|
+
var ELIXIR_MODULE_DEFS = /* @__PURE__ */ new Set(["defmodule", "defprotocol"]);
|
|
101
|
+
function elixirDefinition(node) {
|
|
102
|
+
if (node.type !== "call") return null;
|
|
103
|
+
const target = node.childForFieldName("target") ?? node.namedChild(0);
|
|
104
|
+
if (target?.type !== "identifier") return null;
|
|
105
|
+
const args = namedChildrenOf(node).find((child) => child.type === "arguments");
|
|
106
|
+
const head = args?.namedChild(0);
|
|
107
|
+
if (!head) return null;
|
|
108
|
+
if (ELIXIR_MODULE_DEFS.has(target.text)) {
|
|
109
|
+
return head.type === "alias" ? { kind: "namespace", name: head.text } : null;
|
|
110
|
+
}
|
|
111
|
+
if (!ELIXIR_FUNCTION_DEFS.has(target.text)) return null;
|
|
112
|
+
const name = elixirFunctionName(head, 0);
|
|
113
|
+
return name ? { kind: "function", name } : null;
|
|
114
|
+
}
|
|
115
|
+
function elixirFunctionName(head, depth) {
|
|
116
|
+
if (depth > 3) return null;
|
|
117
|
+
if (head.type === "identifier") return head.text;
|
|
118
|
+
if (head.type === "call") {
|
|
119
|
+
const target = head.childForFieldName("target") ?? head.namedChild(0);
|
|
120
|
+
return target?.type === "identifier" ? target.text : null;
|
|
121
|
+
}
|
|
122
|
+
if (head.type === "binary_operator") {
|
|
123
|
+
const left = head.childForFieldName("left") ?? head.namedChild(0);
|
|
124
|
+
return left ? elixirFunctionName(left, depth + 1) : null;
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
8
128
|
function parseGroupedUse(text) {
|
|
9
129
|
const open = text.indexOf("{");
|
|
10
130
|
const close = text.lastIndexOf("}");
|
|
@@ -248,6 +368,8 @@ var LANG_QUERIES = {
|
|
|
248
368
|
type_definition: "declarator",
|
|
249
369
|
preproc_def: "name"
|
|
250
370
|
},
|
|
371
|
+
resolveKind: (node, kind) => node.type === "declaration" ? cDeclarationKind(node) : cSpecifierKind(node, kind),
|
|
372
|
+
declaredNames: (node) => node.type === "declaration" && !cDeclaresFunction(node) ? cDeclaratorNames(node) : void 0,
|
|
251
373
|
scopeNodes: /* @__PURE__ */ new Set([
|
|
252
374
|
"translation_unit",
|
|
253
375
|
"function_definition",
|
|
@@ -283,6 +405,7 @@ var LANG_QUERIES = {
|
|
|
283
405
|
namespace_definition: "name",
|
|
284
406
|
type_definition: "declarator"
|
|
285
407
|
},
|
|
408
|
+
resolveKind: cSpecifierKind,
|
|
286
409
|
scopeNodes: /* @__PURE__ */ new Set([
|
|
287
410
|
"translation_unit",
|
|
288
411
|
"function_definition",
|
|
@@ -308,8 +431,10 @@ var LANG_QUERIES = {
|
|
|
308
431
|
annotation_type_declaration: "interface",
|
|
309
432
|
method_declaration: "method",
|
|
310
433
|
constructor_declaration: "method",
|
|
311
|
-
field_declaration: "property"
|
|
434
|
+
field_declaration: "property",
|
|
435
|
+
constant_declaration: "const"
|
|
312
436
|
},
|
|
437
|
+
declaredNames: (node) => node.type === "field_declaration" || node.type === "constant_declaration" ? declaratorNames(node, /* @__PURE__ */ new Set(["variable_declarator"])) : void 0,
|
|
313
438
|
nameField: {
|
|
314
439
|
class_declaration: "name",
|
|
315
440
|
interface_declaration: "name",
|
|
@@ -320,12 +445,7 @@ var LANG_QUERIES = {
|
|
|
320
445
|
constructor_declaration: "name"
|
|
321
446
|
},
|
|
322
447
|
// `field_declaration` has no single `name` field — it carries a list of
|
|
323
|
-
// variable declarators
|
|
324
|
-
// identifier-shaped named child (see `extractName` fallback in
|
|
325
|
-
// `visitor.ts`). `int a, b, c;` therefore indexes only `a` — splitting
|
|
326
|
-
// multi-declarator fields into separate Symbols is a separate refactor
|
|
327
|
-
// that needs the visitor to know it has multiple names per node, and no
|
|
328
|
-
// current test relies on it.
|
|
448
|
+
// variable declarators, each emitted as its own symbol (declaredNames).
|
|
329
449
|
scopeNodes: /* @__PURE__ */ new Set([
|
|
330
450
|
"program",
|
|
331
451
|
"class_declaration",
|
|
@@ -369,14 +489,22 @@ var LANG_QUERIES = {
|
|
|
369
489
|
field_declaration: "property",
|
|
370
490
|
namespace_declaration: "namespace"
|
|
371
491
|
},
|
|
372
|
-
//
|
|
492
|
+
// Namespaces keep their full dotted name verbatim. Scoped to namespace
|
|
493
|
+
// nodes: applied to every declaration it named an interface member
|
|
494
|
+
// `System.Threading.Tasks.Task RunAsync();` after its RETURN TYPE.
|
|
373
495
|
nameExtractor: (node) => {
|
|
496
|
+
if (node.type !== "namespace_declaration" && node.type !== "file_scoped_namespace_declaration") {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
const named = node.childForFieldName("name");
|
|
500
|
+
if (named) return named.text;
|
|
374
501
|
const inner = node.namedChild(0);
|
|
375
|
-
if (inner && (inner.type === "qualified_name" || inner.type === "
|
|
502
|
+
if (inner && (inner.type === "qualified_name" || inner.type === "identifier")) {
|
|
376
503
|
return inner.text;
|
|
377
504
|
}
|
|
378
505
|
return null;
|
|
379
506
|
},
|
|
507
|
+
declaredNames: (node) => node.type === "field_declaration" ? declaratorNames(node, /* @__PURE__ */ new Set(["variable_declarator"]), /* @__PURE__ */ new Set(["variable_declaration"])) : void 0,
|
|
380
508
|
scopeNodes: /* @__PURE__ */ new Set([
|
|
381
509
|
"compilation_unit",
|
|
382
510
|
"namespace_declaration",
|
|
@@ -417,6 +545,13 @@ var LANG_QUERIES = {
|
|
|
417
545
|
enum_declaration: "name",
|
|
418
546
|
namespace_definition: "name"
|
|
419
547
|
},
|
|
548
|
+
// `namespace App\Models;` — the whole qualified name, not its first
|
|
549
|
+
// segment. The resolver binds `use App\Models\User` against it.
|
|
550
|
+
declaredNames: (node) => {
|
|
551
|
+
if (node.type !== "namespace_definition") return void 0;
|
|
552
|
+
const name = node.childForFieldName("name")?.text;
|
|
553
|
+
return name ? [name] : [];
|
|
554
|
+
},
|
|
420
555
|
scopeNodes: /* @__PURE__ */ new Set([
|
|
421
556
|
"program",
|
|
422
557
|
"namespace_definition",
|
|
@@ -459,6 +594,15 @@ var LANG_QUERIES = {
|
|
|
459
594
|
module: "name",
|
|
460
595
|
constant: "name"
|
|
461
596
|
},
|
|
597
|
+
resolveKind: (node, kind) => {
|
|
598
|
+
if (node.type === "constant") {
|
|
599
|
+
const parent = node.parent;
|
|
600
|
+
return parent?.type === "assignment" && sameNode(parent.childForFieldName("left"), node) ? "const" : null;
|
|
601
|
+
}
|
|
602
|
+
if (node.type === "method") return rubyInsideClass(node) ? "method" : "function";
|
|
603
|
+
return kind;
|
|
604
|
+
},
|
|
605
|
+
declaredNames: (node) => node.type === "constant" ? [node.text] : void 0,
|
|
462
606
|
scopeNodes: /* @__PURE__ */ new Set(["program", "class", "module", "singleton_method", "method"]),
|
|
463
607
|
refRules: {
|
|
464
608
|
// `call` covers both `foo(...)` and `obj.foo(...)` — the extractor
|
|
@@ -477,7 +621,8 @@ var LANG_QUERIES = {
|
|
|
477
621
|
actor_declaration: "class",
|
|
478
622
|
extension_declaration: "class",
|
|
479
623
|
initializer: "method",
|
|
480
|
-
property_declaration: "property"
|
|
624
|
+
property_declaration: "property",
|
|
625
|
+
protocol_function_declaration: "method"
|
|
481
626
|
},
|
|
482
627
|
nameField: {
|
|
483
628
|
function_declaration: "name",
|
|
@@ -528,6 +673,11 @@ var LANG_QUERIES = {
|
|
|
528
673
|
property_declaration: "name",
|
|
529
674
|
type_alias: "name"
|
|
530
675
|
},
|
|
676
|
+
declaredNames: (node) => node.type === "property_declaration" ? declaratorNames(
|
|
677
|
+
node,
|
|
678
|
+
/* @__PURE__ */ new Set(["variable_declaration"]),
|
|
679
|
+
/* @__PURE__ */ new Set(["multi_variable_declaration"])
|
|
680
|
+
) : void 0,
|
|
531
681
|
scopeNodes: /* @__PURE__ */ new Set([
|
|
532
682
|
"source_file",
|
|
533
683
|
"class_declaration",
|
|
@@ -547,30 +697,17 @@ var LANG_QUERIES = {
|
|
|
547
697
|
}
|
|
548
698
|
},
|
|
549
699
|
elixir: {
|
|
700
|
+
// Every Elixir definition is a `call` node (`def`, `defmodule`, …), and so
|
|
701
|
+
// is every ordinary call. The previous table indexed `defmodule` itself as
|
|
702
|
+
// a function named "defmodule", named each def after its whole argument
|
|
703
|
+
// text ("total(items), do: …"), and emitted a function symbol for every
|
|
704
|
+
// plain call in every body. elixirDefinition decides all three.
|
|
550
705
|
declKinds: {
|
|
551
|
-
|
|
552
|
-
// `call` nodes in the tree-sitter grammar — there is no
|
|
553
|
-
// `function_definition`. The `nameExtractor` walks the call's
|
|
554
|
-
// children to pick the right sibling identifier.
|
|
555
|
-
call: "function",
|
|
556
|
-
module: "namespace"
|
|
557
|
-
},
|
|
558
|
-
nameExtractor: (node) => {
|
|
559
|
-
if (node.type === "module") {
|
|
560
|
-
const aliasNode = node.childForFieldName("alias");
|
|
561
|
-
return readFirstString(aliasNode) ?? null;
|
|
562
|
-
}
|
|
563
|
-
if (node.type !== "call") return null;
|
|
564
|
-
const first = node.namedChild(0);
|
|
565
|
-
if (!first) return null;
|
|
566
|
-
const target = first.text;
|
|
567
|
-
if (target !== "def" && target !== "defp" && target !== "defmacro" && target !== "defp_macro" && target !== "macrop" && target !== "defprotocol" && target !== "defguard" && target !== "defguardp") {
|
|
568
|
-
return null;
|
|
569
|
-
}
|
|
570
|
-
const nameNode = node.namedChild(1);
|
|
571
|
-
return nameNode?.text ?? null;
|
|
706
|
+
call: "function"
|
|
572
707
|
},
|
|
573
|
-
|
|
708
|
+
resolveKind: (node) => elixirDefinition(node)?.kind ?? null,
|
|
709
|
+
nameExtractor: (node) => elixirDefinition(node)?.name ?? null,
|
|
710
|
+
isScopeNode: (node) => elixirDefinition(node)?.kind === "namespace"
|
|
574
711
|
},
|
|
575
712
|
shell: {
|
|
576
713
|
declKinds: {
|
|
@@ -583,14 +720,6 @@ var LANG_QUERIES = {
|
|
|
583
720
|
function getQueries(lang) {
|
|
584
721
|
return LANG_QUERIES[lang] ?? DEFAULT_QUERIES;
|
|
585
722
|
}
|
|
586
|
-
function readFirstString(node) {
|
|
587
|
-
if (!node) return null;
|
|
588
|
-
if (node.type === "string_literal" || node.type === "alias") {
|
|
589
|
-
return node.text.replace(/^"|"$/g, "");
|
|
590
|
-
}
|
|
591
|
-
const child = node.namedChild(0);
|
|
592
|
-
return child ? readFirstString(child) : null;
|
|
593
|
-
}
|
|
594
723
|
|
|
595
724
|
// src/codebase-index/tree-sitter/util.ts
|
|
596
725
|
function lineColAt(offsets, index) {
|
|
@@ -602,7 +731,7 @@ function lineColAt(offsets, index) {
|
|
|
602
731
|
else high = mid;
|
|
603
732
|
}
|
|
604
733
|
const lastNl = low > 0 ? offsets[low - 1] ?? -1 : -1;
|
|
605
|
-
return { line: low + 1, col: index - lastNl };
|
|
734
|
+
return { line: low + 1, col: index - lastNl - 1 };
|
|
606
735
|
}
|
|
607
736
|
function newlineOffsets(content) {
|
|
608
737
|
const offsets = [];
|
|
@@ -653,26 +782,33 @@ function visitTree(tree, content, file, lang, queries) {
|
|
|
653
782
|
}
|
|
654
783
|
function visit(node, depth) {
|
|
655
784
|
if (symbols.length >= TREE_SITTER_MAX_SYMBOLS) return;
|
|
785
|
+
if (node.startIndex >= boundedContent.length) return;
|
|
656
786
|
if (node.isMissing || node.isError) {
|
|
657
787
|
} else {
|
|
658
|
-
const
|
|
788
|
+
const staticKind = queries.declKinds[node.type];
|
|
789
|
+
const kind = staticKind && queries.resolveKind ? queries.resolveKind(node, staticKind) : staticKind;
|
|
659
790
|
if (kind) {
|
|
660
|
-
const
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
791
|
+
const names = queries.declaredNames?.(node);
|
|
792
|
+
for (const name of names ?? [void 0]) {
|
|
793
|
+
if (symbols.length >= TREE_SITTER_MAX_SYMBOLS) break;
|
|
794
|
+
const emitted = emitSymbol(
|
|
795
|
+
node,
|
|
796
|
+
kind,
|
|
797
|
+
file,
|
|
798
|
+
lang,
|
|
799
|
+
scopeStack,
|
|
800
|
+
boundedContent,
|
|
801
|
+
nlOffsets,
|
|
802
|
+
queries,
|
|
803
|
+
name
|
|
804
|
+
);
|
|
805
|
+
if (emitted) symbols.push(emitted);
|
|
806
|
+
}
|
|
671
807
|
}
|
|
672
808
|
const refRule = queries.refRules?.[node.type];
|
|
673
809
|
if (refRule) emitRefsForNode(node, refRule);
|
|
674
810
|
}
|
|
675
|
-
const pushesScope = queries.scopeNodes?.has(node.type) ?? false;
|
|
811
|
+
const pushesScope = queries.isScopeNode ? queries.isScopeNode(node) : queries.scopeNodes?.has(node.type) ?? false;
|
|
676
812
|
const pushIdx = pushesScope ? pushScope(scopeStack, node, queries) : -1;
|
|
677
813
|
if (queries.skipNamedChildren) {
|
|
678
814
|
if (pushIdx !== -1) scopeStack.pop();
|
|
@@ -706,8 +842,20 @@ var IDENTIFIER_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
|
706
842
|
"word",
|
|
707
843
|
"variable_name",
|
|
708
844
|
"constant",
|
|
709
|
-
"sym"
|
|
845
|
+
"sym",
|
|
846
|
+
"namespace_identifier"
|
|
710
847
|
]);
|
|
848
|
+
function declaratorChainName(start) {
|
|
849
|
+
let current = start;
|
|
850
|
+
for (let depth = 0; current && depth < 16; depth++) {
|
|
851
|
+
if (IDENTIFIER_NODE_TYPES.has(current.type)) return current.text;
|
|
852
|
+
if (current.type === "destructor_name" || current.type === "operator_name") {
|
|
853
|
+
return current.text;
|
|
854
|
+
}
|
|
855
|
+
current = current.childForFieldName("declarator") ?? current.childForFieldName("name");
|
|
856
|
+
}
|
|
857
|
+
return null;
|
|
858
|
+
}
|
|
711
859
|
function extractName(node, queries) {
|
|
712
860
|
if (queries.nameExtractor) {
|
|
713
861
|
const extracted = queries.nameExtractor(node);
|
|
@@ -716,10 +864,9 @@ function extractName(node, queries) {
|
|
|
716
864
|
const fieldName = queries.nameField?.[node.type] ?? "name";
|
|
717
865
|
const field = node.childForFieldName(fieldName);
|
|
718
866
|
if (field) {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
const inner = field.childForFieldName("name") ?? field.namedChild(0);
|
|
867
|
+
const chained = declaratorChainName(field);
|
|
868
|
+
if (chained) return chained;
|
|
869
|
+
const inner = field.namedChild(0);
|
|
723
870
|
if (inner && IDENTIFIER_NODE_TYPES.has(inner.type)) {
|
|
724
871
|
return inner.text;
|
|
725
872
|
}
|
|
@@ -732,8 +879,8 @@ function extractName(node, queries) {
|
|
|
732
879
|
}
|
|
733
880
|
return null;
|
|
734
881
|
}
|
|
735
|
-
function emitSymbol(node, kind, file, lang, scopeStack, content, nlOffsets, queries) {
|
|
736
|
-
const name = extractName(node, queries);
|
|
882
|
+
function emitSymbol(node, kind, file, lang, scopeStack, content, nlOffsets, queries, nameOverride) {
|
|
883
|
+
const name = nameOverride ?? extractName(node, queries);
|
|
737
884
|
if (!name) return null;
|
|
738
885
|
const pos = node.startIndex;
|
|
739
886
|
const { line, col } = lineColAt(nlOffsets, pos);
|
|
@@ -875,15 +1022,19 @@ async function parseSymbols(opts) {
|
|
|
875
1022
|
const { Parser } = await getRuntime();
|
|
876
1023
|
const cached = await loadLanguage(lang);
|
|
877
1024
|
const parser = new Parser();
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1025
|
+
let tree = null;
|
|
1026
|
+
try {
|
|
1027
|
+
parser.setLanguage(cached.Language);
|
|
1028
|
+
tree = parser.parse(content);
|
|
1029
|
+
if (!tree) {
|
|
1030
|
+
return { file, lang, symbols: [], mtimeMs: Date.now() };
|
|
1031
|
+
}
|
|
1032
|
+
const { symbols, refs } = visitTree(tree, content, file, lang, getQueries(lang));
|
|
1033
|
+
return { file, lang, symbols, refs, mtimeMs: Date.now() };
|
|
1034
|
+
} finally {
|
|
1035
|
+
tree?.delete();
|
|
1036
|
+
parser.delete();
|
|
882
1037
|
}
|
|
883
|
-
const { symbols, refs } = visitTree(tree, content, file, lang, getQueries(lang));
|
|
884
|
-
parser.delete();
|
|
885
|
-
tree.delete();
|
|
886
|
-
return { file, lang, symbols, refs, mtimeMs: Date.now() };
|
|
887
1038
|
} catch {
|
|
888
1039
|
return { file, lang, symbols: [], mtimeMs: Date.now() };
|
|
889
1040
|
}
|
|
@@ -931,12 +1082,25 @@ async function parseTreeSitterAst(opts) {
|
|
|
931
1082
|
return null;
|
|
932
1083
|
}
|
|
933
1084
|
}
|
|
1085
|
+
function treeSitterDeclarationName(node) {
|
|
1086
|
+
const named = node.childForFieldName("name");
|
|
1087
|
+
if (named) return named.text;
|
|
1088
|
+
let declarator = node.childForFieldName("declarator");
|
|
1089
|
+
if (!declarator) return void 0;
|
|
1090
|
+
for (; ; ) {
|
|
1091
|
+
const inner = declarator.childForFieldName("declarator");
|
|
1092
|
+
if (!inner) break;
|
|
1093
|
+
declarator = inner;
|
|
1094
|
+
}
|
|
1095
|
+
return /identifier$/.test(declarator.type) ? declarator.text : void 0;
|
|
1096
|
+
}
|
|
934
1097
|
|
|
935
1098
|
export {
|
|
936
1099
|
getGrammarWasmPath,
|
|
937
1100
|
parseSymbols,
|
|
938
1101
|
loadTreeSitterLanguage,
|
|
939
1102
|
__smokeRootType,
|
|
940
|
-
parseTreeSitterAst
|
|
1103
|
+
parseTreeSitterAst,
|
|
1104
|
+
treeSitterDeclarationName
|
|
941
1105
|
};
|
|
942
|
-
//# sourceMappingURL=chunk-
|
|
1106
|
+
//# sourceMappingURL=chunk-2IRHFHZY.js.map
|