@colbymchenry/codegraph-win32-arm64 1.4.1 → 1.5.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/bin/codegraph.cmd +1 -1
- package/lib/dist/bin/codegraph.js +61 -15
- package/lib/dist/bin/codegraph.js.map +1 -1
- package/lib/dist/context/index.d.ts.map +1 -1
- package/lib/dist/context/index.js +41 -11
- package/lib/dist/context/index.js.map +1 -1
- package/lib/dist/db/index.d.ts +142 -0
- package/lib/dist/db/index.d.ts.map +1 -1
- package/lib/dist/db/index.js +267 -6
- package/lib/dist/db/index.js.map +1 -1
- package/lib/dist/db/queries.d.ts +74 -2
- package/lib/dist/db/queries.d.ts.map +1 -1
- package/lib/dist/db/queries.js +287 -20
- package/lib/dist/db/queries.js.map +1 -1
- package/lib/dist/db/sqlite-adapter.d.ts +3 -1
- package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
- package/lib/dist/db/sqlite-adapter.js +22 -4
- package/lib/dist/db/sqlite-adapter.js.map +1 -1
- package/lib/dist/db/wal-valve.d.ts +15 -2
- package/lib/dist/db/wal-valve.d.ts.map +1 -1
- package/lib/dist/db/wal-valve.js +88 -6
- package/lib/dist/db/wal-valve.js.map +1 -1
- package/lib/dist/extraction/grammars.d.ts.map +1 -1
- package/lib/dist/extraction/grammars.js +63 -0
- package/lib/dist/extraction/grammars.js.map +1 -1
- package/lib/dist/extraction/index.d.ts +32 -3
- package/lib/dist/extraction/index.d.ts.map +1 -1
- package/lib/dist/extraction/index.js +254 -61
- package/lib/dist/extraction/index.js.map +1 -1
- package/lib/dist/extraction/kernel/decode.d.ts +9 -0
- package/lib/dist/extraction/kernel/decode.d.ts.map +1 -0
- package/lib/dist/extraction/kernel/decode.js +162 -0
- package/lib/dist/extraction/kernel/decode.js.map +1 -0
- package/lib/dist/extraction/kernel/index.d.ts +64 -0
- package/lib/dist/extraction/kernel/index.d.ts.map +1 -0
- package/lib/dist/extraction/kernel/index.js +279 -0
- package/lib/dist/extraction/kernel/index.js.map +1 -0
- package/lib/dist/extraction/kernel/layout.d.ts +101 -0
- package/lib/dist/extraction/kernel/layout.d.ts.map +1 -0
- package/lib/dist/extraction/kernel/layout.js +104 -0
- package/lib/dist/extraction/kernel/layout.js.map +1 -0
- package/lib/dist/extraction/kernel/loader.d.ts +103 -0
- package/lib/dist/extraction/kernel/loader.d.ts.map +1 -0
- package/lib/dist/extraction/kernel/loader.js +146 -0
- package/lib/dist/extraction/kernel/loader.js.map +1 -0
- package/lib/dist/extraction/languages/c-cpp.d.ts +14 -0
- package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.js +849 -12
- package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
- package/lib/dist/extraction/parse-pool.d.ts +8 -0
- package/lib/dist/extraction/parse-pool.d.ts.map +1 -1
- package/lib/dist/extraction/parse-pool.js +15 -0
- package/lib/dist/extraction/parse-pool.js.map +1 -1
- package/lib/dist/extraction/parse-worker.js +35 -1
- package/lib/dist/extraction/parse-worker.js.map +1 -1
- package/lib/dist/extraction/store-worker.d.ts +24 -0
- package/lib/dist/extraction/store-worker.d.ts.map +1 -0
- package/lib/dist/extraction/store-worker.js +139 -0
- package/lib/dist/extraction/store-worker.js.map +1 -0
- package/lib/dist/extraction/store-writer.d.ts +63 -0
- package/lib/dist/extraction/store-writer.d.ts.map +1 -0
- package/lib/dist/extraction/store-writer.js +174 -0
- package/lib/dist/extraction/store-writer.js.map +1 -0
- package/lib/dist/extraction/tree-sitter.d.ts +22 -4
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.js +151 -6
- package/lib/dist/extraction/tree-sitter.js.map +1 -1
- package/lib/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
- package/lib/dist/extraction/wasm-runtime-flags.d.ts +15 -0
- package/lib/dist/extraction/wasm-runtime-flags.d.ts.map +1 -1
- package/lib/dist/extraction/wasm-runtime-flags.js +27 -3
- package/lib/dist/extraction/wasm-runtime-flags.js.map +1 -1
- package/lib/dist/index.d.ts +14 -2
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +188 -10
- package/lib/dist/index.js.map +1 -1
- package/lib/dist/installer/beta-signup.d.ts +54 -0
- package/lib/dist/installer/beta-signup.d.ts.map +1 -0
- package/lib/dist/installer/beta-signup.js +178 -0
- package/lib/dist/installer/beta-signup.js.map +1 -0
- package/lib/dist/installer/index.d.ts.map +1 -1
- package/lib/dist/installer/index.js +11 -0
- package/lib/dist/installer/index.js.map +1 -1
- package/lib/dist/mcp/tools.d.ts.map +1 -1
- package/lib/dist/mcp/tools.js +27 -0
- package/lib/dist/mcp/tools.js.map +1 -1
- package/lib/dist/resolution/c-fnptr-synthesizer.d.ts +1 -1
- package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/c-fnptr-synthesizer.js +574 -132
- package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.d.ts +54 -10
- package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.js +249 -157
- package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
- package/lib/dist/resolution/cooperative-yield.d.ts +10 -2
- package/lib/dist/resolution/cooperative-yield.d.ts.map +1 -1
- package/lib/dist/resolution/cooperative-yield.js +6 -4
- package/lib/dist/resolution/cooperative-yield.js.map +1 -1
- package/lib/dist/resolution/frameworks/go.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/go.js +29 -6
- package/lib/dist/resolution/frameworks/go.js.map +1 -1
- package/lib/dist/resolution/import-resolver.d.ts +2 -3
- package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
- package/lib/dist/resolution/import-resolver.js +166 -7
- package/lib/dist/resolution/import-resolver.js.map +1 -1
- package/lib/dist/resolution/index.d.ts +87 -2
- package/lib/dist/resolution/index.d.ts.map +1 -1
- package/lib/dist/resolution/index.js +716 -130
- package/lib/dist/resolution/index.js.map +1 -1
- package/lib/dist/resolution/memory-budget.d.ts +48 -0
- package/lib/dist/resolution/memory-budget.d.ts.map +1 -0
- package/lib/dist/resolution/memory-budget.js +162 -0
- package/lib/dist/resolution/memory-budget.js.map +1 -0
- package/lib/dist/resolution/name-matcher.d.ts +12 -1
- package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
- package/lib/dist/resolution/name-matcher.js +387 -95
- package/lib/dist/resolution/name-matcher.js.map +1 -1
- package/lib/dist/resolution/resolver-pool.d.ts +106 -0
- package/lib/dist/resolution/resolver-pool.d.ts.map +1 -0
- package/lib/dist/resolution/resolver-pool.js +344 -0
- package/lib/dist/resolution/resolver-pool.js.map +1 -0
- package/lib/dist/resolution/resolver-worker.d.ts +17 -0
- package/lib/dist/resolution/resolver-worker.d.ts.map +1 -0
- package/lib/dist/resolution/resolver-worker.js +141 -0
- package/lib/dist/resolution/resolver-worker.js.map +1 -0
- package/lib/dist/resolution/types.d.ts +3 -0
- package/lib/dist/resolution/types.d.ts.map +1 -1
- package/lib/dist/sync/watcher.d.ts +25 -1
- package/lib/dist/sync/watcher.d.ts.map +1 -1
- package/lib/dist/sync/watcher.js +76 -3
- package/lib/dist/sync/watcher.js.map +1 -1
- package/lib/dist/types.d.ts +41 -2
- package/lib/dist/types.d.ts.map +1 -1
- package/lib/dist/types.js +26 -1
- package/lib/dist/types.js.map +1 -1
- package/lib/dist/ui/color.d.ts +21 -0
- package/lib/dist/ui/color.d.ts.map +1 -0
- package/lib/dist/ui/color.js +42 -0
- package/lib/dist/ui/color.js.map +1 -0
- package/lib/dist/ui/glyphs.d.ts +35 -10
- package/lib/dist/ui/glyphs.d.ts.map +1 -1
- package/lib/dist/ui/glyphs.js +59 -12
- package/lib/dist/ui/glyphs.js.map +1 -1
- package/lib/dist/ui/shimmer-progress.d.ts.map +1 -1
- package/lib/dist/ui/shimmer-progress.js +78 -4
- package/lib/dist/ui/shimmer-progress.js.map +1 -1
- package/lib/dist/ui/shimmer-worker.js +25 -17
- package/lib/dist/ui/shimmer-worker.js.map +1 -1
- package/lib/dist/ui/types.d.ts +0 -2
- package/lib/dist/ui/types.d.ts.map +1 -1
- package/lib/dist/upgrade/index.d.ts +7 -0
- package/lib/dist/upgrade/index.d.ts.map +1 -1
- package/lib/dist/upgrade/index.js +18 -5
- package/lib/dist/upgrade/index.js.map +1 -1
- package/lib/kernel/codegraph-kernel.node +0 -0
- package/lib/node_modules/.package-lock.json +1 -1
- package/lib/package.json +6 -1
- package/package.json +6 -2
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* StoreWriter — main-thread client for the store worker (see store-worker.ts).
|
|
4
|
+
*
|
|
5
|
+
* Used ONLY on the fresh-DB bulk path: bundles are posted in file order and the
|
|
6
|
+
* worker applies them in arrival order, so rowid assignment (and therefore
|
|
7
|
+
* resolution's insertion-order disambiguation) is byte-identical to the
|
|
8
|
+
* main-thread store. Kill switch: CODEGRAPH_NO_STORE_WORKER=1.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.StoreWriter = void 0;
|
|
12
|
+
exports.finalizeStoreBundle = finalizeStoreBundle;
|
|
13
|
+
const worker_threads_1 = require("worker_threads");
|
|
14
|
+
/**
|
|
15
|
+
* The validation/denormalization every bundle gets before storeFileBundle —
|
|
16
|
+
* shared by the orchestrator's object path and the store worker's kernel
|
|
17
|
+
* decode path so the two can never drift:
|
|
18
|
+
* - nodes missing identity fields are dropped (#42-class safety),
|
|
19
|
+
* - edges must connect inserted nodes (FK integrity),
|
|
20
|
+
* - refs must originate from inserted nodes and carry the denormalized
|
|
21
|
+
* filePath/language the resolver reads.
|
|
22
|
+
*/
|
|
23
|
+
function finalizeStoreBundle(result, filePath, language, file) {
|
|
24
|
+
const validNodes = result.nodes.filter((n) => n.id && n.kind && n.name && n.filePath && n.language);
|
|
25
|
+
const insertedIds = new Set(validNodes.map((n) => n.id));
|
|
26
|
+
const validEdges = result.edges.filter((e) => insertedIds.has(e.source) && insertedIds.has(e.target));
|
|
27
|
+
const validRefs = result.unresolvedReferences
|
|
28
|
+
.filter((ref) => insertedIds.has(ref.fromNodeId))
|
|
29
|
+
.map((ref) => ({
|
|
30
|
+
...ref,
|
|
31
|
+
filePath: ref.filePath ?? filePath,
|
|
32
|
+
language: ref.language ?? language,
|
|
33
|
+
}));
|
|
34
|
+
return { nodes: validNodes, edges: validEdges, refs: validRefs, file };
|
|
35
|
+
}
|
|
36
|
+
class StoreWriter {
|
|
37
|
+
worker;
|
|
38
|
+
readyPromise;
|
|
39
|
+
firstError = null;
|
|
40
|
+
drainWaiters = new Map();
|
|
41
|
+
nextDrainId = 0;
|
|
42
|
+
exited = false;
|
|
43
|
+
/** Bundles posted but not yet acked — the queue-depth backpressure signal. */
|
|
44
|
+
outstanding = 0;
|
|
45
|
+
belowWaiters = [];
|
|
46
|
+
constructor(workerScriptPath, dbPath, fastInit) {
|
|
47
|
+
this.worker = new worker_threads_1.Worker(workerScriptPath);
|
|
48
|
+
let readyResolve;
|
|
49
|
+
let readyReject;
|
|
50
|
+
this.readyPromise = new Promise((resolve, reject) => {
|
|
51
|
+
readyResolve = resolve;
|
|
52
|
+
readyReject = reject;
|
|
53
|
+
});
|
|
54
|
+
this.worker.on('message', (msg) => {
|
|
55
|
+
if (msg.type === 'ready') {
|
|
56
|
+
readyResolve();
|
|
57
|
+
}
|
|
58
|
+
else if (msg.type === 'ack') {
|
|
59
|
+
this.settleOne();
|
|
60
|
+
}
|
|
61
|
+
else if (msg.type === 'drained' && msg.id !== undefined) {
|
|
62
|
+
const waiter = this.drainWaiters.get(msg.id);
|
|
63
|
+
this.drainWaiters.delete(msg.id);
|
|
64
|
+
if (!waiter)
|
|
65
|
+
return;
|
|
66
|
+
if (this.firstError)
|
|
67
|
+
waiter.reject(this.firstError);
|
|
68
|
+
else
|
|
69
|
+
waiter.resolve();
|
|
70
|
+
}
|
|
71
|
+
else if (msg.type === 'error') {
|
|
72
|
+
if (!this.firstError)
|
|
73
|
+
this.firstError = new Error(`store worker: ${msg.message}`);
|
|
74
|
+
this.settleOne(); // the error reply is also the failed bundle's ack
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
this.worker.on('error', (err) => {
|
|
78
|
+
this.failAll(err instanceof Error ? err : new Error(String(err)));
|
|
79
|
+
readyReject(this.firstError);
|
|
80
|
+
});
|
|
81
|
+
this.worker.on('exit', (code) => {
|
|
82
|
+
this.exited = true;
|
|
83
|
+
if (code !== 0) {
|
|
84
|
+
this.failAll(new Error(`store worker exited with code ${code}`));
|
|
85
|
+
readyReject(this.firstError);
|
|
86
|
+
}
|
|
87
|
+
else if (this.drainWaiters.size > 0 || this.belowWaiters.length > 0) {
|
|
88
|
+
// A clean exit with waiters pending is a protocol violation (only
|
|
89
|
+
// close() should end the worker) — settle the waiters instead of
|
|
90
|
+
// hanging the index forever.
|
|
91
|
+
this.failAll(new Error('store worker exited before drain completed'));
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
this.worker.postMessage({ type: 'open', dbPath, fastInit });
|
|
95
|
+
// The worker holds the event loop open only until close(); don't unref —
|
|
96
|
+
// bundles must never be dropped because main ran out of work.
|
|
97
|
+
}
|
|
98
|
+
failAll(err) {
|
|
99
|
+
if (!this.firstError)
|
|
100
|
+
this.firstError = err;
|
|
101
|
+
for (const [, waiter] of this.drainWaiters)
|
|
102
|
+
waiter.reject(this.firstError);
|
|
103
|
+
this.drainWaiters.clear();
|
|
104
|
+
this.outstanding = 0;
|
|
105
|
+
const waiters = this.belowWaiters;
|
|
106
|
+
this.belowWaiters = [];
|
|
107
|
+
for (const w of waiters)
|
|
108
|
+
w.resolve(); // send() will surface firstError
|
|
109
|
+
}
|
|
110
|
+
settleOne() {
|
|
111
|
+
if (this.outstanding > 0)
|
|
112
|
+
this.outstanding--;
|
|
113
|
+
if (this.belowWaiters.length === 0)
|
|
114
|
+
return;
|
|
115
|
+
const still = [];
|
|
116
|
+
for (const w of this.belowWaiters) {
|
|
117
|
+
if (this.outstanding < w.limit)
|
|
118
|
+
w.resolve();
|
|
119
|
+
else
|
|
120
|
+
still.push(w);
|
|
121
|
+
}
|
|
122
|
+
this.belowWaiters = still;
|
|
123
|
+
}
|
|
124
|
+
ready() {
|
|
125
|
+
return this.readyPromise;
|
|
126
|
+
}
|
|
127
|
+
/** Post one file's bundle. Throws immediately if the writer already failed. */
|
|
128
|
+
send(bundle) {
|
|
129
|
+
if (this.firstError)
|
|
130
|
+
throw this.firstError;
|
|
131
|
+
if (this.exited)
|
|
132
|
+
throw new Error('store worker already exited');
|
|
133
|
+
this.outstanding++;
|
|
134
|
+
this.worker.postMessage({ type: 'bundle', bundle });
|
|
135
|
+
}
|
|
136
|
+
/** Backpressure: resolves once fewer than `limit` bundles are un-acked. */
|
|
137
|
+
waitBelow(limit) {
|
|
138
|
+
if (this.firstError || this.exited || this.outstanding < limit)
|
|
139
|
+
return Promise.resolve();
|
|
140
|
+
return new Promise((resolve) => {
|
|
141
|
+
this.belowWaiters.push({ limit, resolve });
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/** Resolves when every bundle posted before this call has been applied. */
|
|
145
|
+
drain() {
|
|
146
|
+
if (this.firstError)
|
|
147
|
+
return Promise.reject(this.firstError);
|
|
148
|
+
if (this.exited)
|
|
149
|
+
return Promise.reject(new Error('store worker already exited'));
|
|
150
|
+
const id = this.nextDrainId++;
|
|
151
|
+
const p = new Promise((resolve, reject) => {
|
|
152
|
+
this.drainWaiters.set(id, { resolve, reject });
|
|
153
|
+
});
|
|
154
|
+
this.worker.postMessage({ type: 'drain', id });
|
|
155
|
+
return p;
|
|
156
|
+
}
|
|
157
|
+
/** Close the worker's DB connection and join the thread. */
|
|
158
|
+
async close() {
|
|
159
|
+
if (this.exited)
|
|
160
|
+
return;
|
|
161
|
+
this.worker.postMessage({ type: 'close' });
|
|
162
|
+
await new Promise((resolve) => {
|
|
163
|
+
const t = setTimeout(() => {
|
|
164
|
+
void this.worker.terminate().then(() => resolve());
|
|
165
|
+
}, 5000);
|
|
166
|
+
this.worker.once('exit', () => {
|
|
167
|
+
clearTimeout(t);
|
|
168
|
+
resolve();
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.StoreWriter = StoreWriter;
|
|
174
|
+
//# sourceMappingURL=store-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store-writer.js","sourceRoot":"","sources":["../../src/extraction/store-writer.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAoCH,kDAmBC;AArDD,mDAAwC;AAyBxC;;;;;;;;GAQG;AACH,SAAgB,mBAAmB,CACjC,MAA0E,EAC1E,QAAgB,EAChB,QAAkB,EAClB,IAAgB;IAEhB,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI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AC,MAAM,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;YACrD,CAAC,EAAE,IAAI,CAAC,CAAC;YACT,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;gBAC5B,YAAY,CAAC,CAAC,CAAC,CAAC;gBAChB,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7HD,kCA6HC"}
|
|
@@ -5,9 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Language, ExtractionResult } from '../types';
|
|
7
7
|
export { generateNodeId } from './tree-sitter-helpers';
|
|
8
|
-
/**
|
|
9
|
-
* TreeSitterExtractor - Main extraction class
|
|
10
|
-
*/
|
|
11
8
|
export declare class TreeSitterExtractor {
|
|
12
9
|
private filePath;
|
|
13
10
|
private language;
|
|
@@ -31,7 +28,10 @@ export declare class TreeSitterExtractor {
|
|
|
31
28
|
private fnRefSpec;
|
|
32
29
|
private fnRefCandidates;
|
|
33
30
|
private vueStoreFile;
|
|
34
|
-
|
|
31
|
+
private sourceIsPreParsed;
|
|
32
|
+
constructor(filePath: string, source: string, language?: Language, options?: {
|
|
33
|
+
sourceIsPreParsed?: boolean;
|
|
34
|
+
});
|
|
35
35
|
/**
|
|
36
36
|
* Parse and extract from the source code
|
|
37
37
|
*/
|
|
@@ -103,6 +103,24 @@ export declare class TreeSitterExtractor {
|
|
|
103
103
|
* present (script files, .kts without a package).
|
|
104
104
|
*/
|
|
105
105
|
private extractFilePackage;
|
|
106
|
+
/**
|
|
107
|
+
* Qualified name for a method defined out-of-line via a receiver qualifier
|
|
108
|
+
* (`Type::method() {}`). The declarator spells the receiver RELATIVE to the
|
|
109
|
+
* enclosing namespace, so the active C++ namespace prefix must be composed
|
|
110
|
+
* in — `namespace sim { Output ManifestStartup::Apply() {} }` previously
|
|
111
|
+
* indexed as `ManifestStartup::Apply` while the class node carried
|
|
112
|
+
* `sim::ManifestStartup`, so qualified call sites
|
|
113
|
+
* (`sim::ManifestStartup::Apply(...)`) never resolved (#1291).
|
|
114
|
+
*
|
|
115
|
+
* The source may also re-spell part or all of the namespace path
|
|
116
|
+
* (`namespace sim { void sim::M::f() {} }` is legal), so the receiver is
|
|
117
|
+
* anchored at the first prefix segment it names: everything before that
|
|
118
|
+
* anchor is taken from the prefix, the receiver supplies the rest. A
|
|
119
|
+
* receiver naming no prefix segment gets the whole prefix prepended.
|
|
120
|
+
* `namespacePrefix` is only ever non-empty for C++, so every other
|
|
121
|
+
* receiver language (Go, Rust, Kotlin, Lua) passes through unchanged.
|
|
122
|
+
*/
|
|
123
|
+
private composeReceiverQualifiedName;
|
|
106
124
|
/**
|
|
107
125
|
* Build qualified name from node stack
|
|
108
126
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-sitter.d.ts","sourceRoot":"","sources":["../../src/extraction/tree-sitter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,QAAQ,EAIR,gBAAgB,EAGjB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"tree-sitter.d.ts","sourceRoot":"","sources":["../../src/extraction/tree-sitter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EACL,QAAQ,EAIR,gBAAgB,EAGjB,MAAM,UAAU,CAAC;AAuBlB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AA8VvD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,oBAAoB,CAA6B;IAIzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAA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AAM,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,QAAQ,EACnB,cAAc,CAAC,EAAE,MAAM,EAAE,GACxB,gBAAgB,CAqGlB"}
|
|
@@ -55,6 +55,7 @@ const dfm_extractor_1 = require("./dfm-extractor");
|
|
|
55
55
|
const vue_extractor_1 = require("./vue-extractor");
|
|
56
56
|
const mybatis_extractor_1 = require("./mybatis-extractor");
|
|
57
57
|
const cfml_extractor_1 = require("./cfml-extractor");
|
|
58
|
+
const kernel_1 = require("./kernel");
|
|
58
59
|
const frameworks_1 = require("../resolution/frameworks");
|
|
59
60
|
// Re-export for backward compatibility
|
|
60
61
|
var tree_sitter_helpers_2 = require("./tree-sitter-helpers");
|
|
@@ -358,6 +359,29 @@ const INSTANTIATION_KINDS = new Set([
|
|
|
358
359
|
/**
|
|
359
360
|
* TreeSitterExtractor - Main extraction class
|
|
360
361
|
*/
|
|
362
|
+
/**
|
|
363
|
+
* tree-sitter node types (across grammars) for literal expressions in method-
|
|
364
|
+
* call RECEIVER position. A literal's methods are the language's builtins —
|
|
365
|
+
* `", ".join`, `"x".toUpperCase()`, `5.times`, `[].concat` — never project
|
|
366
|
+
* symbols, so a member call on one must not emit a `calls` ref that bare-name
|
|
367
|
+
* matching could bind to an unrelated same-named project function (#1230).
|
|
368
|
+
*/
|
|
369
|
+
const LITERAL_RECEIVER_TYPES = new Set([
|
|
370
|
+
// strings
|
|
371
|
+
'string', 'string_literal', 'interpreted_string_literal', 'raw_string_literal',
|
|
372
|
+
'template_string', 'concatenated_string', 'formatted_string', 'f_string',
|
|
373
|
+
'line_string_literal', 'string_content', 'heredoc_body',
|
|
374
|
+
// numbers
|
|
375
|
+
'number', 'number_literal', 'integer', 'integer_literal', 'float',
|
|
376
|
+
'float_literal', 'int_literal', 'decimal_integer_literal', 'real_literal',
|
|
377
|
+
// chars / runes / regex / booleans / null-likes
|
|
378
|
+
'char_literal', 'character_literal', 'rune_literal', 'regex', 'regex_literal',
|
|
379
|
+
'true', 'false', 'boolean_literal', 'bool_literal', 'none', 'null', 'nil',
|
|
380
|
+
'null_literal', 'undefined',
|
|
381
|
+
// collection literals
|
|
382
|
+
'list', 'list_literal', 'array', 'array_literal', 'array_creation_expression',
|
|
383
|
+
'dictionary', 'dict_literal', 'object', 'tuple', 'set',
|
|
384
|
+
]);
|
|
361
385
|
class TreeSitterExtractor {
|
|
362
386
|
filePath;
|
|
363
387
|
language;
|
|
@@ -400,12 +424,17 @@ class TreeSitterExtractor {
|
|
|
400
424
|
fnRefCandidates = [];
|
|
401
425
|
// Memoized "is this a Vue store file" verdict (per-extractor = per-file).
|
|
402
426
|
vueStoreFile = null;
|
|
403
|
-
|
|
427
|
+
// Source already went through the extractor's preParse at the kernel route
|
|
428
|
+
// point (this instance is the wasm fallback for a kernel-deferred file) —
|
|
429
|
+
// don't blank it a second time.
|
|
430
|
+
sourceIsPreParsed = false;
|
|
431
|
+
constructor(filePath, source, language, options) {
|
|
404
432
|
this.filePath = filePath;
|
|
405
433
|
this.source = source;
|
|
406
434
|
this.language = language || (0, grammars_1.detectLanguage)(filePath, source);
|
|
407
435
|
this.extractor = languages_1.EXTRACTORS[this.language] || null;
|
|
408
436
|
this.fnRefSpec = function_ref_1.FN_REF_SPECS[this.language];
|
|
437
|
+
this.sourceIsPreParsed = options?.sourceIsPreParsed === true;
|
|
409
438
|
}
|
|
410
439
|
/**
|
|
411
440
|
* Parse and extract from the source code
|
|
@@ -450,8 +479,9 @@ class TreeSitterExtractor {
|
|
|
450
479
|
// grammar gaps — e.g. C# blanks conditional-compilation directive lines
|
|
451
480
|
// the grammar mis-parses inside enum bodies (#237). We reassign
|
|
452
481
|
// this.source so downstream getNodeText reads the same bytes the parser
|
|
453
|
-
// saw (identical outside the blanked directive lines).
|
|
454
|
-
|
|
482
|
+
// saw (identical outside the blanked directive lines). Skipped when the
|
|
483
|
+
// kernel route point already applied it (sourceIsPreParsed).
|
|
484
|
+
if (this.extractor?.preParse && !this.sourceIsPreParsed) {
|
|
455
485
|
this.source = this.extractor.preParse(this.source, this.filePath);
|
|
456
486
|
}
|
|
457
487
|
this.tree = parser.parse(this.source) ?? null;
|
|
@@ -1344,6 +1374,32 @@ class TreeSitterExtractor {
|
|
|
1344
1374
|
const ns = this.createNode('namespace', pkgName, pkgNode);
|
|
1345
1375
|
return ns?.id ?? null;
|
|
1346
1376
|
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Qualified name for a method defined out-of-line via a receiver qualifier
|
|
1379
|
+
* (`Type::method() {}`). The declarator spells the receiver RELATIVE to the
|
|
1380
|
+
* enclosing namespace, so the active C++ namespace prefix must be composed
|
|
1381
|
+
* in — `namespace sim { Output ManifestStartup::Apply() {} }` previously
|
|
1382
|
+
* indexed as `ManifestStartup::Apply` while the class node carried
|
|
1383
|
+
* `sim::ManifestStartup`, so qualified call sites
|
|
1384
|
+
* (`sim::ManifestStartup::Apply(...)`) never resolved (#1291).
|
|
1385
|
+
*
|
|
1386
|
+
* The source may also re-spell part or all of the namespace path
|
|
1387
|
+
* (`namespace sim { void sim::M::f() {} }` is legal), so the receiver is
|
|
1388
|
+
* anchored at the first prefix segment it names: everything before that
|
|
1389
|
+
* anchor is taken from the prefix, the receiver supplies the rest. A
|
|
1390
|
+
* receiver naming no prefix segment gets the whole prefix prepended.
|
|
1391
|
+
* `namespacePrefix` is only ever non-empty for C++, so every other
|
|
1392
|
+
* receiver language (Go, Rust, Kotlin, Lua) passes through unchanged.
|
|
1393
|
+
*/
|
|
1394
|
+
composeReceiverQualifiedName(receiverType, name) {
|
|
1395
|
+
const base = `${receiverType}::${name}`;
|
|
1396
|
+
if (this.namespacePrefix.length === 0)
|
|
1397
|
+
return base;
|
|
1398
|
+
const receiverHead = receiverType.split('::')[0];
|
|
1399
|
+
const anchor = this.namespacePrefix.indexOf(receiverHead);
|
|
1400
|
+
const prefix = anchor === -1 ? this.namespacePrefix : this.namespacePrefix.slice(0, anchor);
|
|
1401
|
+
return prefix.length > 0 ? `${prefix.join('::')}::${base}` : base;
|
|
1402
|
+
}
|
|
1347
1403
|
/**
|
|
1348
1404
|
* Build qualified name from node stack
|
|
1349
1405
|
*/
|
|
@@ -1667,7 +1723,7 @@ class TreeSitterExtractor {
|
|
|
1667
1723
|
returnType,
|
|
1668
1724
|
};
|
|
1669
1725
|
if (receiverType) {
|
|
1670
|
-
extraProps.qualifiedName =
|
|
1726
|
+
extraProps.qualifiedName = this.composeReceiverQualifiedName(receiverType, name);
|
|
1671
1727
|
}
|
|
1672
1728
|
const methodNode = this.createNode('method', name, node, extraProps);
|
|
1673
1729
|
if (!methodNode)
|
|
@@ -4217,6 +4273,59 @@ class TreeSitterExtractor {
|
|
|
4217
4273
|
}
|
|
4218
4274
|
else {
|
|
4219
4275
|
const func = (0, tree_sitter_helpers_1.getChildByField)(node, 'function') || node.namedChild(0);
|
|
4276
|
+
// C++ explicit operator call `a.operator+(b)` / `p->operator+(b)` (#1247):
|
|
4277
|
+
// tree-sitter-cpp can't parse an operator_name in field position, so the
|
|
4278
|
+
// callee is NOT a field_expression — the call_expression carries
|
|
4279
|
+
// `function: <receiver>` plus an ERROR child wrapping the operator_name.
|
|
4280
|
+
// Reading the function field alone yields just the receiver (`a`), an
|
|
4281
|
+
// unresolvable ref. Recover `<receiver>.operator+` so it resolves like any
|
|
4282
|
+
// other member call (matchMethodCall admits the operator method part).
|
|
4283
|
+
// The infix forms `a + b` / `a[i]` need receiver type inference and are
|
|
4284
|
+
// tracked separately (#1258).
|
|
4285
|
+
if (this.language === 'cpp' && func) {
|
|
4286
|
+
let operatorName = '';
|
|
4287
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
4288
|
+
const child = node.namedChild(i);
|
|
4289
|
+
if (child?.type !== 'ERROR')
|
|
4290
|
+
continue;
|
|
4291
|
+
const op = child.namedChildren.find((c) => c.type === 'operator_name');
|
|
4292
|
+
if (op) {
|
|
4293
|
+
operatorName = (0, tree_sitter_helpers_1.getNodeText)(op, this.source);
|
|
4294
|
+
break;
|
|
4295
|
+
}
|
|
4296
|
+
}
|
|
4297
|
+
if (operatorName) {
|
|
4298
|
+
// Call sites may space the symbolic name (nlohmann/json's
|
|
4299
|
+
// `it.operator * ()`, `other.operator < (*this)`) while definitions
|
|
4300
|
+
// index compact (`operator*`) — normalize so they match. The word
|
|
4301
|
+
// forms (`operator new`) keep their space.
|
|
4302
|
+
const sym = operatorName.slice('operator'.length).trim();
|
|
4303
|
+
if (/^[^\w\s]/.test(sym))
|
|
4304
|
+
operatorName = `operator${sym.replace(/\s+/g, '')}`;
|
|
4305
|
+
// `->` receivers resolve identically to `.` ones. A receiver that
|
|
4306
|
+
// isn't a simple identifier/member chain (`(*it)`, a call result, …)
|
|
4307
|
+
// can't aid type inference, and a bare operator name would fall
|
|
4308
|
+
// through to exact-name matching — which GUESSES among the many
|
|
4309
|
+
// same-named operators (on nlohmann/json it linked a std::map
|
|
4310
|
+
// `object->operator[]` call to an unrelated in-repo operator[]).
|
|
4311
|
+
// Drop the ref: a silent miss, never a wrong edge. `this->` keeps
|
|
4312
|
+
// the bare name, matching how `this.method()` calls are emitted —
|
|
4313
|
+
// the target is on the enclosing class, where exact-name's same-file
|
|
4314
|
+
// preference is reliable.
|
|
4315
|
+
const receiver = (0, tree_sitter_helpers_1.getNodeText)(func, this.source).replace(/->/g, '.').replace(/\s+/g, '');
|
|
4316
|
+
if (receiver !== 'this' && !/^[A-Za-z_][\w.]*$/.test(receiver))
|
|
4317
|
+
return;
|
|
4318
|
+
const calleeName = receiver === 'this' ? operatorName : `${receiver}.${operatorName}`;
|
|
4319
|
+
this.unresolvedReferences.push({
|
|
4320
|
+
fromNodeId: callerId,
|
|
4321
|
+
referenceName: calleeName,
|
|
4322
|
+
referenceKind: 'calls',
|
|
4323
|
+
line: node.startPosition.row + 1,
|
|
4324
|
+
column: node.startPosition.column,
|
|
4325
|
+
});
|
|
4326
|
+
return;
|
|
4327
|
+
}
|
|
4328
|
+
}
|
|
4220
4329
|
if (func) {
|
|
4221
4330
|
if (func.type === 'member_expression' || func.type === 'attribute' || func.type === 'selector_expression' || func.type === 'navigation_expression' || func.type === 'field_expression') {
|
|
4222
4331
|
// Method call: obj.method() or obj.field.method()
|
|
@@ -4244,6 +4353,16 @@ class TreeSitterExtractor {
|
|
|
4244
4353
|
(0, tree_sitter_helpers_1.getChildByField)(func, 'operand') ||
|
|
4245
4354
|
(0, tree_sitter_helpers_1.getChildByField)(func, 'argument') ||
|
|
4246
4355
|
func.namedChild(0);
|
|
4356
|
+
// A LITERAL receiver — `", ".join(...)`, `"x".toUpperCase()`,
|
|
4357
|
+
// `5.times`, `[].concat(...)` — calls a builtin of the literal's
|
|
4358
|
+
// type, never a project symbol. The bare-name fallback below let
|
|
4359
|
+
// these exact-match an unrelated same-named project function
|
|
4360
|
+
// (`", ".join` bound to a local `join` defined inside a DIFFERENT
|
|
4361
|
+
// function, #1230). Emit nothing: a silent miss, never a wrong
|
|
4362
|
+
// edge. Nested calls in the arguments are visited independently.
|
|
4363
|
+
if (receiver && LITERAL_RECEIVER_TYPES.has(receiver.type)) {
|
|
4364
|
+
return;
|
|
4365
|
+
}
|
|
4247
4366
|
const SKIP_RECEIVERS = new Set(['self', 'this', 'cls', 'super']);
|
|
4248
4367
|
if (receiver && (receiver.type === 'identifier' || receiver.type === 'simple_identifier' || receiver.type === 'field_identifier')) {
|
|
4249
4368
|
const receiverName = (0, tree_sitter_helpers_1.getNodeText)(receiver, this.source);
|
|
@@ -4329,6 +4448,20 @@ class TreeSitterExtractor {
|
|
|
4329
4448
|
// name, which either failed to resolve or resolved ambiguously.
|
|
4330
4449
|
calleeName = `${(0, tree_sitter_helpers_1.getNodeText)(receiver, this.source)}.${methodName}`;
|
|
4331
4450
|
}
|
|
4451
|
+
else if (this.language === 'go' &&
|
|
4452
|
+
receiver &&
|
|
4453
|
+
receiver.type === 'selector_expression' &&
|
|
4454
|
+
/^[A-Za-z_]\w*\.[A-Za-z_]\w*$/.test((0, tree_sitter_helpers_1.getNodeText)(receiver, this.source).replace(/\s+/g, ''))) {
|
|
4455
|
+
// Go 2-hop field chain `target.conn.Exec(...)`: keep the
|
|
4456
|
+
// receiver chain so resolution can infer `conn`'s declared type
|
|
4457
|
+
// from the Target struct. Previously this emitted the bare
|
|
4458
|
+
// method name, and when the field's type is EXTERNAL (sql.DB)
|
|
4459
|
+
// the bare name exact-matched an unrelated same-named local
|
|
4460
|
+
// method — a fabricated internal dependency (#1276). Chained
|
|
4461
|
+
// Go receivers resolve strictly via validated field-hop
|
|
4462
|
+
// inference (see matchGoFieldChainCall) or stay unresolved.
|
|
4463
|
+
calleeName = `${(0, tree_sitter_helpers_1.getNodeText)(receiver, this.source).replace(/\s+/g, '')}.${methodName}`;
|
|
4464
|
+
}
|
|
4332
4465
|
else {
|
|
4333
4466
|
calleeName = methodName;
|
|
4334
4467
|
}
|
|
@@ -6477,8 +6610,20 @@ function extractFromSource(filePath, source, language, frameworkNames) {
|
|
|
6477
6610
|
result = extractor.extract();
|
|
6478
6611
|
}
|
|
6479
6612
|
else {
|
|
6480
|
-
|
|
6481
|
-
|
|
6613
|
+
// Native-kernel route (docs/design/rust-kernel-migration-plan.md): gated
|
|
6614
|
+
// per language, null when not routed/available or on a kernel error —
|
|
6615
|
+
// the wasm TreeSitterExtractor below stays the fallback either way.
|
|
6616
|
+
const kernelResult = (0, kernel_1.tryKernelExtract)(filePath, source, detectedLanguage);
|
|
6617
|
+
if (kernelResult) {
|
|
6618
|
+
result = kernelResult;
|
|
6619
|
+
}
|
|
6620
|
+
else {
|
|
6621
|
+
// A kernel-deferred file already paid the (offset-preserving) preParse
|
|
6622
|
+
// at the route point — reuse those bytes instead of blanking again.
|
|
6623
|
+
const deferredPre = (0, kernel_1.takeDeferredPreParse)(filePath, source, detectedLanguage);
|
|
6624
|
+
const extractor = new TreeSitterExtractor(filePath, deferredPre ?? source, detectedLanguage, { sourceIsPreParsed: deferredPre != null });
|
|
6625
|
+
result = extractor.extract();
|
|
6626
|
+
}
|
|
6482
6627
|
}
|
|
6483
6628
|
// Framework-specific extraction (routes, middleware, etc.)
|
|
6484
6629
|
if (frameworkNames && frameworkNames.length > 0) {
|