@mrclrchtr/supi-code-intelligence 10.0.0 → 11.0.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 +77 -21
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/LICENSE +21 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/README.md +743 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/index.js +17 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/constants.js +184 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/parse.js +1425 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/picomatch.js +361 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/scan.js +403 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/utils.js +72 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/package.json +83 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/posix.js +3 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +4 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +11 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/file-associations.ts +190 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +22 -0
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/README.md +88 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/LICENSE +21 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/README.md +743 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/index.js +17 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/constants.js +184 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/parse.js +1425 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/picomatch.js +361 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/scan.js +403 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/utils.js +72 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/package.json +83 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/posix.js +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +4 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +11 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/file-associations.ts +190 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +22 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +1 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +6 -4
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-request-enrollment.ts +66 -22
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +37 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +136 -43
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +261 -22
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +13 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-discovery.ts +151 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +97 -129
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-protocol.ts +132 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +8 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +7 -20
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +172 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +14 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/utils.ts +12 -11
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +63 -17
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/LICENSE +21 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/README.md +743 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/index.js +17 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/constants.js +184 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/parse.js +1425 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/picomatch.js +361 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/scan.js +403 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/lib/utils.js +72 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/package.json +83 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/picomatch/posix.js +3 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +4 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +11 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/file-associations.ts +190 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +22 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +16 -10
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/operation-support.ts +13 -6
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +19 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +18 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +10 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +17 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-process.ts +22 -5
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +36 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-errors.ts +73 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-node.ts +4 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +15 -9
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +24 -15
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +8 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/imports.ts +233 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/node-at.ts +7 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-expansion.ts +78 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-jvm.ts +25 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-nested.ts +390 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline.ts +49 -28
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +16 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/process-host.mjs +61 -24
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +44 -10
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/service.ts +13 -9
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/worker-main.ts +15 -2
- package/package.json +5 -5
- package/src/analysis/refactor/apply.ts +35 -14
- package/src/analysis/relations/callees.ts +9 -2
- package/src/analysis/relations/implementations.ts +7 -2
- package/src/analysis/search/pattern-analysis.ts +90 -12
- package/src/analysis/search/pattern.ts +1 -0
- package/src/analysis/target/anchored-structural.ts +1 -0
- package/src/analysis/target/discovery.ts +29 -0
- package/src/analysis/target/file.ts +19 -9
- package/src/analysis/target/types.ts +5 -0
- package/src/config.ts +46 -7
- package/src/session/graph/collect.ts +2 -2
- package/src/session/graph-types.ts +6 -0
- package/src/session/inspect/collect.ts +35 -20
- package/src/session/inspect-types.ts +9 -2
- package/src/session/orientation/collect.ts +90 -18
- package/src/session/orientation/context-sections.ts +22 -1
- package/src/session/orientation/gather.ts +46 -6
- package/src/session/orientation-types.ts +7 -1
- package/src/session/refactor-plans.ts +17 -0
- package/src/session/refactor-workflow.ts +13 -6
- package/src/session/target-store.ts +5 -0
- package/src/session/target-workflow.ts +3 -0
- package/src/substrate/workspace-provider-host.ts +22 -2
- package/src/tool/code_find/markdown.ts +17 -4
- package/src/tool/code_find/result.ts +17 -3
- package/src/tool/code_graph/details.ts +2 -0
- package/src/tool/code_graph/display.ts +1 -0
- package/src/tool/code_graph/format.ts +1 -0
- package/src/tool/code_graph/result.ts +32 -6
- package/src/tool/code_inspect/markdown.ts +15 -1
- package/src/tool/code_inspect/result.ts +11 -0
- package/src/tool/code_orientation/result.ts +4 -2
- package/src/tool/code_resolve/markdown.ts +34 -14
- package/src/tool/code_resolve/result.ts +7 -3
- package/src/tool/result/types.ts +20 -2
- package/src/ui/tui/display.ts +2 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/LICENSE-MIT +0 -21
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/README.md +0 -501
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/index.d.ts +0 -81
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/index.js +0 -1566
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/legacy.js +0 -1346
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/ignore/package.json +0 -93
|
@@ -11,44 +11,63 @@ if (
|
|
|
11
11
|
throw new Error("Structural Worker process received invalid startup data");
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const worker = new Worker(new URL("./bootstrap.mjs", import.meta.url), {
|
|
15
|
-
execArgv: [],
|
|
16
|
-
workerData: { cwd, generation },
|
|
17
|
-
});
|
|
18
14
|
const cancellationFlags = new Map();
|
|
15
|
+
let worker = null;
|
|
19
16
|
let closing = false;
|
|
20
17
|
let workerExited = false;
|
|
21
18
|
|
|
22
|
-
worker.on("message", (message) => {
|
|
23
|
-
if (message.kind === "terminal") cancellationFlags.delete(message.requestId);
|
|
24
|
-
send({ channel: "supi-tree-sitter-worker", message });
|
|
25
|
-
});
|
|
26
|
-
worker.on("error", (error) => {
|
|
27
|
-
send(
|
|
28
|
-
{
|
|
29
|
-
channel: "supi-tree-sitter-worker",
|
|
30
|
-
message: { kind: "worker-error", message: error.message },
|
|
31
|
-
},
|
|
32
|
-
() => stopWorker(1),
|
|
33
|
-
);
|
|
34
|
-
});
|
|
35
|
-
worker.on("exit", (code) => {
|
|
36
|
-
workerExited = true;
|
|
37
|
-
cancellationFlags.clear();
|
|
38
|
-
process.exitCode = code === 0 ? 1 : code;
|
|
39
|
-
disconnect();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
19
|
process.on("message", (value) => {
|
|
43
20
|
if (!isParentChannel(value)) {
|
|
44
21
|
stopWorker(1);
|
|
45
22
|
return;
|
|
46
23
|
}
|
|
24
|
+
if (!worker) {
|
|
25
|
+
if (!isInitialization(value.message)) {
|
|
26
|
+
stopWorker(1);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
startWorker(value.message);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (value.message.kind === "initialize") {
|
|
33
|
+
stopWorker(1);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
47
36
|
forwardToWorker(value.message);
|
|
48
37
|
});
|
|
49
38
|
process.on("disconnect", () => stopWorker());
|
|
50
39
|
if (!process.connected) stopWorker();
|
|
51
40
|
|
|
41
|
+
function startWorker(initialization) {
|
|
42
|
+
worker = new Worker(new URL("./bootstrap.mjs", import.meta.url), {
|
|
43
|
+
execArgv: [],
|
|
44
|
+
workerData: {
|
|
45
|
+
cwd,
|
|
46
|
+
generation,
|
|
47
|
+
fileAssociations: initialization.fileAssociations,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
worker.on("message", (message) => {
|
|
51
|
+
if (message.kind === "terminal") cancellationFlags.delete(message.requestId);
|
|
52
|
+
send({ channel: "supi-tree-sitter-worker", message });
|
|
53
|
+
});
|
|
54
|
+
worker.on("error", (error) => {
|
|
55
|
+
send(
|
|
56
|
+
{
|
|
57
|
+
channel: "supi-tree-sitter-worker",
|
|
58
|
+
message: { kind: "worker-error", message: error.message },
|
|
59
|
+
},
|
|
60
|
+
() => stopWorker(1),
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
worker.on("exit", (code) => {
|
|
64
|
+
workerExited = true;
|
|
65
|
+
cancellationFlags.clear();
|
|
66
|
+
process.exitCode = code === 0 ? 1 : code;
|
|
67
|
+
disconnect();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
52
71
|
function forwardToWorker(message) {
|
|
53
72
|
if (!message || typeof message !== "object") {
|
|
54
73
|
throw new Error("Structural Worker process received an invalid message");
|
|
@@ -70,6 +89,20 @@ function forwardToWorker(message) {
|
|
|
70
89
|
worker.postMessage(message);
|
|
71
90
|
}
|
|
72
91
|
|
|
92
|
+
function isInitialization(value) {
|
|
93
|
+
return (
|
|
94
|
+
value !== null &&
|
|
95
|
+
typeof value === "object" &&
|
|
96
|
+
!Array.isArray(value) &&
|
|
97
|
+
Object.keys(value).length === 5 &&
|
|
98
|
+
value.kind === "initialize" &&
|
|
99
|
+
value.version === 1 &&
|
|
100
|
+
value.generation === generation &&
|
|
101
|
+
value.cwd === cwd &&
|
|
102
|
+
Array.isArray(value.fileAssociations)
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
73
106
|
function isParentChannel(value) {
|
|
74
107
|
return (
|
|
75
108
|
value !== null &&
|
|
@@ -105,5 +138,9 @@ function stopWorker(exitCode) {
|
|
|
105
138
|
closing = true;
|
|
106
139
|
if (exitCode !== undefined) process.exitCode = exitCode;
|
|
107
140
|
cancellationFlags.clear();
|
|
141
|
+
if (!worker) {
|
|
142
|
+
disconnect();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
108
145
|
void worker.terminate().finally(disconnect);
|
|
109
146
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Tree-sitter runtime — parser management, parse, and query services.
|
|
3
3
|
|
|
4
4
|
import * as path from "node:path";
|
|
5
|
+
import type { CFamilyFileAssociationResolver } from "@mrclrchtr/supi-code-runtime/api";
|
|
5
6
|
import { resolveToolPath } from "@mrclrchtr/supi-core/path";
|
|
6
7
|
import type { Language, Parser, Tree } from "web-tree-sitter";
|
|
7
8
|
import { detectGrammar, resolveGrammarWasmPath } from "../language.ts";
|
|
@@ -12,6 +13,11 @@ import {
|
|
|
12
13
|
type StructuralTimingEvent,
|
|
13
14
|
startStructuralTiming,
|
|
14
15
|
} from "../session/structural-timing.ts";
|
|
16
|
+
import {
|
|
17
|
+
collectSyntaxErrorRanges,
|
|
18
|
+
hasSyntaxErrors,
|
|
19
|
+
withSyntaxCompleteness,
|
|
20
|
+
} from "../syntax-errors.ts";
|
|
15
21
|
import type { GrammarId, QueryCapture, TreeSitterResult } from "../types.ts";
|
|
16
22
|
import {
|
|
17
23
|
ParsedFileReadError,
|
|
@@ -39,6 +45,7 @@ interface ParserEntry {
|
|
|
39
45
|
const QUERY_PARSED_FILE = Symbol("query-parsed-file");
|
|
40
46
|
|
|
41
47
|
interface ParsedQueryInput {
|
|
48
|
+
readonly file: string;
|
|
42
49
|
readonly grammarId: GrammarId;
|
|
43
50
|
readonly tree: Tree;
|
|
44
51
|
readonly source: string;
|
|
@@ -66,8 +73,14 @@ export class TreeSitterRuntime {
|
|
|
66
73
|
constructor(
|
|
67
74
|
private cwd: string,
|
|
68
75
|
private onTiming?: (event: StructuralTimingEvent) => void,
|
|
76
|
+
private readonly fileAssociations?: CFamilyFileAssociationResolver,
|
|
69
77
|
) {}
|
|
70
78
|
|
|
79
|
+
/** Resolve one file's grammar under this runtime's immutable association snapshot. */
|
|
80
|
+
getGrammarForFile(filePath: string): GrammarId | undefined {
|
|
81
|
+
return detectGrammar(filePath, this.fileAssociations);
|
|
82
|
+
}
|
|
83
|
+
|
|
71
84
|
/** Ensure web-tree-sitter Parser is initialized. */
|
|
72
85
|
private async ensureParserInit(): Promise<typeof import("web-tree-sitter")> {
|
|
73
86
|
this.assertActive();
|
|
@@ -152,15 +165,21 @@ export class TreeSitterRuntime {
|
|
|
152
165
|
filePath: string,
|
|
153
166
|
control?: StructuralRequestControl,
|
|
154
167
|
): Promise<
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
168
|
+
| {
|
|
169
|
+
kind: "success";
|
|
170
|
+
data: {
|
|
171
|
+
tree: Tree;
|
|
172
|
+
source: string;
|
|
173
|
+
resolvedPath: string;
|
|
174
|
+
grammarId: GrammarId;
|
|
175
|
+
hasSyntaxErrors: boolean;
|
|
176
|
+
errorRanges: ReturnType<typeof collectSyntaxErrorRanges>;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
| Exclude<TreeSitterResult<never>, { kind: "success" | "partial" }>
|
|
161
180
|
> {
|
|
162
181
|
const resolvedPath = resolveToolPath(this.cwd, filePath);
|
|
163
|
-
const grammarId = detectGrammar(filePath);
|
|
182
|
+
const grammarId = detectGrammar(filePath, this.fileAssociations);
|
|
164
183
|
if (!grammarId) {
|
|
165
184
|
return {
|
|
166
185
|
kind: "unsupported-language",
|
|
@@ -230,6 +249,8 @@ export class TreeSitterRuntime {
|
|
|
230
249
|
source: parsed.source,
|
|
231
250
|
resolvedPath: parsed.resolvedPath,
|
|
232
251
|
grammarId: parsed.grammarId,
|
|
252
|
+
hasSyntaxErrors: hasSyntaxErrors(parsed.tree.rootNode),
|
|
253
|
+
errorRanges: collectSyntaxErrorRanges(parsed.tree.rootNode, parsed.source),
|
|
233
254
|
},
|
|
234
255
|
};
|
|
235
256
|
} catch (err: unknown) {
|
|
@@ -281,7 +302,14 @@ export class TreeSitterRuntime {
|
|
|
281
302
|
|
|
282
303
|
const { grammarId, tree, source } = parseResult.data;
|
|
283
304
|
try {
|
|
284
|
-
return await this[QUERY_PARSED_FILE]({
|
|
305
|
+
return await this[QUERY_PARSED_FILE]({
|
|
306
|
+
file: filePath,
|
|
307
|
+
grammarId,
|
|
308
|
+
tree,
|
|
309
|
+
source,
|
|
310
|
+
queryString,
|
|
311
|
+
control,
|
|
312
|
+
});
|
|
285
313
|
} finally {
|
|
286
314
|
tree.delete();
|
|
287
315
|
}
|
|
@@ -289,7 +317,7 @@ export class TreeSitterRuntime {
|
|
|
289
317
|
|
|
290
318
|
/** Execute a query against one caller-owned parsed tree without parsing again. */
|
|
291
319
|
async [QUERY_PARSED_FILE](input: ParsedQueryInput): Promise<TreeSitterResult<QueryCapture[]>> {
|
|
292
|
-
const { grammarId, tree, source, queryString, control } = input;
|
|
320
|
+
const { file, grammarId, tree, source, queryString, control } = input;
|
|
293
321
|
const validation = validateQueryString(queryString);
|
|
294
322
|
if (validation) return validation;
|
|
295
323
|
|
|
@@ -344,7 +372,13 @@ export class TreeSitterRuntime {
|
|
|
344
372
|
cache: execution.cache,
|
|
345
373
|
finalPhase: "query-execution",
|
|
346
374
|
});
|
|
347
|
-
return {
|
|
375
|
+
return withSyntaxCompleteness({
|
|
376
|
+
data: execution.data,
|
|
377
|
+
file,
|
|
378
|
+
root: tree.rootNode,
|
|
379
|
+
source,
|
|
380
|
+
grammarId,
|
|
381
|
+
});
|
|
348
382
|
} catch (err: unknown) {
|
|
349
383
|
if (isStructuralRequestInterruption(err, control)) {
|
|
350
384
|
finishStructuralTiming(timer, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { detectGrammar } from "../language.ts";
|
|
2
1
|
import { supportsGrammarOperation } from "../operation-support.ts";
|
|
3
2
|
import type { StructuralWorkerOperation } from "../session/structural-worker-protocol.ts";
|
|
3
|
+
import { withSyntaxCompleteness } from "../syntax-errors.ts";
|
|
4
4
|
import { extractCallSites } from "../tool/call-sites.ts";
|
|
5
5
|
import { lookupCalleesAt } from "../tool/callees.ts";
|
|
6
6
|
import { extractExports } from "../tool/exports.ts";
|
|
@@ -68,16 +68,19 @@ export class StructuralWorkerService {
|
|
|
68
68
|
file: string,
|
|
69
69
|
control: StructuralRequestControl,
|
|
70
70
|
): Promise<TreeSitterResult<unknown>> {
|
|
71
|
-
const unsupported = unsupportedOperation(file, "outline");
|
|
71
|
+
const unsupported = unsupportedOperation(this.runtime, file, "outline");
|
|
72
72
|
if (unsupported) return unsupported;
|
|
73
73
|
const result = await this.runtime.parseFile(file, control);
|
|
74
74
|
if (result.kind !== "success") return result;
|
|
75
75
|
try {
|
|
76
76
|
throwIfStructuralRequestInterrupted(control);
|
|
77
|
-
return {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
return withSyntaxCompleteness({
|
|
78
|
+
data: extractOutline(result.data.tree.rootNode, result.data.source, result.data.grammarId),
|
|
79
|
+
file,
|
|
80
|
+
root: result.data.tree.rootNode,
|
|
81
|
+
source: result.data.source,
|
|
82
|
+
grammarId: result.data.grammarId,
|
|
83
|
+
});
|
|
81
84
|
} finally {
|
|
82
85
|
result.data.tree.delete();
|
|
83
86
|
}
|
|
@@ -87,7 +90,7 @@ export class StructuralWorkerService {
|
|
|
87
90
|
file: string,
|
|
88
91
|
control: StructuralRequestControl,
|
|
89
92
|
): Promise<TreeSitterResult<unknown>> {
|
|
90
|
-
const unsupported = unsupportedOperation(file, "imports");
|
|
93
|
+
const unsupported = unsupportedOperation(this.runtime, file, "imports");
|
|
91
94
|
return unsupported ?? extractImports(this.runtime, file, control);
|
|
92
95
|
}
|
|
93
96
|
|
|
@@ -95,16 +98,17 @@ export class StructuralWorkerService {
|
|
|
95
98
|
file: string,
|
|
96
99
|
control: StructuralRequestControl,
|
|
97
100
|
): Promise<TreeSitterResult<unknown>> {
|
|
98
|
-
const unsupported = unsupportedOperation(file, "exports");
|
|
101
|
+
const unsupported = unsupportedOperation(this.runtime, file, "exports");
|
|
99
102
|
return unsupported ?? extractExports(this.runtime, file, control);
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
function unsupportedOperation(
|
|
107
|
+
runtime: TreeSitterRuntime,
|
|
104
108
|
file: string,
|
|
105
109
|
operation: "outline" | "imports" | "exports",
|
|
106
110
|
): TreeSitterResult<never> | null {
|
|
107
|
-
const grammarId =
|
|
111
|
+
const grammarId = runtime.getGrammarForFile(file);
|
|
108
112
|
if (!grammarId || supportsGrammarOperation(grammarId, operation)) return null;
|
|
109
113
|
return {
|
|
110
114
|
kind: "unsupported-language",
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { MessagePort } from "node:worker_threads";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type CFamilyFileAssociationRule,
|
|
4
|
+
createCFamilyFileAssociationResolver,
|
|
5
|
+
isCodeRequestDeadlineError,
|
|
6
|
+
} from "@mrclrchtr/supi-code-runtime/api";
|
|
3
7
|
import type { StructuralTimingEvent } from "../session/structural-timing.ts";
|
|
4
8
|
import { assertStructuralProtocolMessageSize } from "../session/structural-worker-message-size.ts";
|
|
5
9
|
import {
|
|
@@ -18,6 +22,7 @@ import { StructuralWorkerService } from "./service.ts";
|
|
|
18
22
|
interface WorkerBootstrapData {
|
|
19
23
|
readonly cwd: string;
|
|
20
24
|
readonly generation: number;
|
|
25
|
+
readonly fileAssociations?: readonly CFamilyFileAssociationRule[];
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
interface ActiveWorkerRequest {
|
|
@@ -36,7 +41,15 @@ export async function runStructuralWorker(
|
|
|
36
41
|
parentPort: MessagePort,
|
|
37
42
|
workerData: WorkerBootstrapData,
|
|
38
43
|
): Promise<void> {
|
|
39
|
-
const
|
|
44
|
+
const associationResolver = createCFamilyFileAssociationResolver(
|
|
45
|
+
workerData.cwd,
|
|
46
|
+
workerData.fileAssociations ?? [],
|
|
47
|
+
);
|
|
48
|
+
const runtime = new TreeSitterRuntime(
|
|
49
|
+
workerData.cwd,
|
|
50
|
+
(event) => forwardObservation(event),
|
|
51
|
+
associationResolver,
|
|
52
|
+
);
|
|
40
53
|
const service = new StructuralWorkerService(runtime);
|
|
41
54
|
let active: ActiveWorkerRequest | null = null;
|
|
42
55
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-code-intelligence",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "LSP and AST navigation, search, diagnostics, and refactoring",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"ignore": "^7.0.12",
|
|
38
38
|
"smol-toml": "^1.9.1",
|
|
39
39
|
"yaml": "^2.9.0",
|
|
40
|
-
"@mrclrchtr/supi-code-runtime": "
|
|
41
|
-
"@mrclrchtr/supi-core": "
|
|
42
|
-
"@mrclrchtr/supi-
|
|
43
|
-
"@mrclrchtr/supi-
|
|
40
|
+
"@mrclrchtr/supi-code-runtime": "11.0.0",
|
|
41
|
+
"@mrclrchtr/supi-core": "11.0.0",
|
|
42
|
+
"@mrclrchtr/supi-lsp": "11.0.0",
|
|
43
|
+
"@mrclrchtr/supi-tree-sitter": "11.0.0"
|
|
44
44
|
},
|
|
45
45
|
"bundledDependencies": [
|
|
46
46
|
"@mrclrchtr/supi-code-runtime",
|
|
@@ -69,7 +69,11 @@ export async function applyWorkspaceEdit(
|
|
|
69
69
|
if (!freshness.ok) return { kind: "error", reason: freshness.reason };
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const documentState = validateDocumentPreconditions(
|
|
72
|
+
const documentState = validateDocumentPreconditions(
|
|
73
|
+
edit,
|
|
74
|
+
options.getOpenDocumentVersion,
|
|
75
|
+
options.expectedFingerprints,
|
|
76
|
+
);
|
|
73
77
|
if (!documentState.ok) return { kind: "error", reason: documentState.reason };
|
|
74
78
|
|
|
75
79
|
const validation = validateEditAgainstFiles(edit);
|
|
@@ -92,6 +96,7 @@ export async function applyWorkspaceEdit(
|
|
|
92
96
|
function validateDocumentPreconditions(
|
|
93
97
|
edit: WorkspaceEdit,
|
|
94
98
|
getOpenDocumentVersion: ApplyOptions["getOpenDocumentVersion"],
|
|
99
|
+
expectedFingerprints: ApplyOptions["expectedFingerprints"],
|
|
95
100
|
): { ok: true } | { ok: false; reason: string } {
|
|
96
101
|
const preconditions = edit.documentPreconditions ?? [];
|
|
97
102
|
if (preconditions.length === 0) return { ok: true };
|
|
@@ -103,23 +108,39 @@ function validateDocumentPreconditions(
|
|
|
103
108
|
}
|
|
104
109
|
|
|
105
110
|
for (const precondition of preconditions) {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
if (precondition.kind === "disk-content" && currentVersion !== null) {
|
|
114
|
-
return {
|
|
115
|
-
ok: false,
|
|
116
|
-
reason: `File ${precondition.file} is now open and no longer uses disk content as its master.`,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
111
|
+
const reason = validateDocumentPrecondition(
|
|
112
|
+
precondition,
|
|
113
|
+
getOpenDocumentVersion,
|
|
114
|
+
expectedFingerprints,
|
|
115
|
+
);
|
|
116
|
+
if (reason) return { ok: false, reason };
|
|
119
117
|
}
|
|
120
118
|
return { ok: true };
|
|
121
119
|
}
|
|
122
120
|
|
|
121
|
+
function validateDocumentPrecondition(
|
|
122
|
+
precondition: NonNullable<WorkspaceEdit["documentPreconditions"]>[number],
|
|
123
|
+
getOpenDocumentVersion: NonNullable<ApplyOptions["getOpenDocumentVersion"]>,
|
|
124
|
+
expectedFingerprints: ApplyOptions["expectedFingerprints"],
|
|
125
|
+
): string | null {
|
|
126
|
+
const currentVersion = getOpenDocumentVersion(precondition.file);
|
|
127
|
+
if (precondition.kind === "disk-content") {
|
|
128
|
+
return currentVersion === null
|
|
129
|
+
? null
|
|
130
|
+
: `File ${precondition.file} is now open and no longer uses disk content as its master.`;
|
|
131
|
+
}
|
|
132
|
+
if (currentVersion !== precondition.version) {
|
|
133
|
+
return `File ${precondition.file} open document version has changed since the plan was generated.`;
|
|
134
|
+
}
|
|
135
|
+
if (
|
|
136
|
+
precondition.kind === "open-document-content" &&
|
|
137
|
+
expectedFingerprints?.get(precondition.file) !== precondition.fingerprint
|
|
138
|
+
) {
|
|
139
|
+
return `File ${precondition.file} synchronized content fingerprint does not match the stored plan.`;
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
123
144
|
function validateFingerprints(
|
|
124
145
|
files: string[],
|
|
125
146
|
expected: ReadonlyMap<string, string>,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Structural callee lookup — finds direct calls in the enclosing scope at a target position.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { CodeRequestControl } from "@mrclrchtr/supi-code-runtime/api";
|
|
5
|
+
import type { CodeRequestControl, SourceRange } from "@mrclrchtr/supi-code-runtime/api";
|
|
6
6
|
import type { CalleeEntry, CalleeScope, RelationsServiceDeps } from "./types.ts";
|
|
7
7
|
|
|
8
8
|
export interface CalleesResult {
|
|
@@ -14,6 +14,8 @@ export interface CalleesResult {
|
|
|
14
14
|
/** Original provider reason when callee evidence is unavailable. */
|
|
15
15
|
message: string | null;
|
|
16
16
|
depth: "direct" | "deep";
|
|
17
|
+
/** Syntax recovery that may hide call sites in the analyzed file. */
|
|
18
|
+
partial: { file: string; reason: string; errorRanges: readonly SourceRange[] } | null;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
/**
|
|
@@ -42,7 +44,7 @@ export async function collectCallees(
|
|
|
42
44
|
targetCharacter,
|
|
43
45
|
depthOrOptions,
|
|
44
46
|
);
|
|
45
|
-
if (result.kind !== "success") {
|
|
47
|
+
if (result.kind !== "success" && result.kind !== "partial") {
|
|
46
48
|
return unavailableCallees(targetName, result.message, depth);
|
|
47
49
|
}
|
|
48
50
|
|
|
@@ -69,6 +71,10 @@ export async function collectCallees(
|
|
|
69
71
|
confidence: "structural",
|
|
70
72
|
message: null,
|
|
71
73
|
depth: result.data.depth ?? depth,
|
|
74
|
+
partial:
|
|
75
|
+
result.kind === "partial"
|
|
76
|
+
? { file: result.file, reason: result.reason, errorRanges: result.errorRanges }
|
|
77
|
+
: null,
|
|
72
78
|
};
|
|
73
79
|
}
|
|
74
80
|
|
|
@@ -85,6 +91,7 @@ function unavailableCallees(
|
|
|
85
91
|
confidence: "unavailable",
|
|
86
92
|
message,
|
|
87
93
|
depth,
|
|
94
|
+
partial: null,
|
|
88
95
|
};
|
|
89
96
|
}
|
|
90
97
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./provider-locations.ts";
|
|
11
11
|
import type { ImplementationEntry, RelationsServiceDeps } from "./types.ts";
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
interface ImplementationsResultBase {
|
|
14
14
|
kind: "implementations";
|
|
15
15
|
targetName: string;
|
|
16
16
|
implementations: ImplementationEntry[];
|
|
@@ -18,9 +18,12 @@ export interface ImplementationsResult {
|
|
|
18
18
|
/** Provider locations omitted because their URI or position was unusable. */
|
|
19
19
|
invalidLocationCount: number;
|
|
20
20
|
partialReason: RelationLocationPartialReason | null;
|
|
21
|
-
confidence: "semantic" | "unavailable";
|
|
22
21
|
}
|
|
23
22
|
|
|
23
|
+
/** An implementation lookup result with a reason on every unavailable outcome. */
|
|
24
|
+
export type ImplementationsResult = ImplementationsResultBase &
|
|
25
|
+
({ confidence: "semantic" } | { confidence: "unavailable"; message: string });
|
|
26
|
+
|
|
24
27
|
/**
|
|
25
28
|
* Collect implementations for a target file/position using semantic provider.
|
|
26
29
|
*/
|
|
@@ -41,6 +44,7 @@ export async function collectImplementations(
|
|
|
41
44
|
invalidLocationCount: 0,
|
|
42
45
|
partialReason: null,
|
|
43
46
|
confidence: "unavailable",
|
|
47
|
+
message: "No semantic implementations provider",
|
|
44
48
|
};
|
|
45
49
|
}
|
|
46
50
|
|
|
@@ -54,6 +58,7 @@ export async function collectImplementations(
|
|
|
54
58
|
invalidLocationCount: 0,
|
|
55
59
|
partialReason: null,
|
|
56
60
|
confidence: "unavailable",
|
|
61
|
+
message: result.reason,
|
|
57
62
|
};
|
|
58
63
|
}
|
|
59
64
|
|