fallow-type-aware 3.28.0 → 3.30.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/package.json +1 -1
- package/src/cli.mjs +13 -28
- package/src/protocol.mjs +1 -1
- package/src/semantic-identity.mjs +3 -3
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -2,7 +2,6 @@ import path from "node:path";
|
|
|
2
2
|
import { createInterface } from "node:readline";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
ANALYSIS_OPERATION,
|
|
6
5
|
SESSION_ENVELOPE_TYPES,
|
|
7
6
|
STATUS_OPERATION,
|
|
8
7
|
WIRE_PROTOCOL_VERSION,
|
|
@@ -35,18 +34,6 @@ const writeJson = (output, value) => {
|
|
|
35
34
|
output.write(`${JSON.stringify(value)}\n`);
|
|
36
35
|
};
|
|
37
36
|
|
|
38
|
-
const handleArguments = (args, output) => {
|
|
39
|
-
if (args.length === 1 && args[0] === "--status") {
|
|
40
|
-
writeJson(output, createStatusResponse());
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
// --session is dispatched by run() before this function is reached.
|
|
44
|
-
if (args.length > 0) {
|
|
45
|
-
throw new Error(`unknown argument: ${args[0]}`);
|
|
46
|
-
}
|
|
47
|
-
return false;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
37
|
const sessionFileChanges = (value, root) => {
|
|
51
38
|
if (value === undefined) return undefined;
|
|
52
39
|
if (value?.invalidate_all === true && Object.keys(value).length === 1) {
|
|
@@ -117,7 +104,7 @@ const runSession = async (input, output) => {
|
|
|
117
104
|
writeJson(output, {
|
|
118
105
|
request_id: envelope.request_id,
|
|
119
106
|
revision: envelope.revision,
|
|
120
|
-
response: responseFor(
|
|
107
|
+
response: responseFor(result, performance.now() - startedAt),
|
|
121
108
|
});
|
|
122
109
|
}
|
|
123
110
|
} finally {
|
|
@@ -137,19 +124,20 @@ const isStatusRequest = (request) =>
|
|
|
137
124
|
Object.keys(request ?? {}).length === STATUS_FIELDS.length &&
|
|
138
125
|
STATUS_FIELDS.every(([name, value]) => request[name] === value);
|
|
139
126
|
|
|
140
|
-
const responseFor = (
|
|
141
|
-
if (request.protocolVersion !== WIRE_PROTOCOL_VERSION) {
|
|
142
|
-
throw new Error(`unsupported protocol_version ${String(request.protocolVersion)}`);
|
|
143
|
-
}
|
|
144
|
-
return createSemanticResponse({ ...result, elapsedMs });
|
|
145
|
-
};
|
|
127
|
+
const responseFor = (result, elapsedMs) => createSemanticResponse({ ...result, elapsedMs });
|
|
146
128
|
|
|
147
129
|
export const run = async ({ input, output, args = [] }) => {
|
|
148
|
-
if (args.length
|
|
149
|
-
|
|
150
|
-
|
|
130
|
+
if (args.length > 0) {
|
|
131
|
+
if (args.length === 1 && args[0] === "--session") {
|
|
132
|
+
await runSession(input, output);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (args.length === 1 && args[0] === "--status") {
|
|
136
|
+
writeJson(output, createStatusResponse());
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
throw new Error(`unknown argument: ${args[0]}`);
|
|
151
140
|
}
|
|
152
|
-
if (handleArguments(args, output)) return;
|
|
153
141
|
const startedAt = performance.now();
|
|
154
142
|
const rawRequest = parseJsonRequest(await readAll(input));
|
|
155
143
|
if (isStatusRequest(rawRequest)) {
|
|
@@ -157,9 +145,6 @@ export const run = async ({ input, output, args = [] }) => {
|
|
|
157
145
|
return;
|
|
158
146
|
}
|
|
159
147
|
const request = parseRequest(rawRequest);
|
|
160
|
-
if (rawRequest.operation !== ANALYSIS_OPERATION) {
|
|
161
|
-
throw new Error(`unsupported operation ${String(rawRequest.operation)}`);
|
|
162
|
-
}
|
|
163
148
|
const result = analyzeSemanticQueries(request);
|
|
164
|
-
writeJson(output, responseFor(
|
|
149
|
+
writeJson(output, responseFor(result, performance.now() - startedAt));
|
|
165
150
|
};
|
package/src/protocol.mjs
CHANGED
|
@@ -372,7 +372,7 @@ const parseBatchRequest = (value) => {
|
|
|
372
372
|
validateGraphQueryCount(queries);
|
|
373
373
|
requireUniqueCandidateIds(queries);
|
|
374
374
|
const evidenceLimit = parseEvidenceLimit(value.evidence_limit);
|
|
375
|
-
return {
|
|
375
|
+
return { root, projects, queries, evidenceLimit };
|
|
376
376
|
};
|
|
377
377
|
|
|
378
378
|
export const parseRequest = (value) => {
|
|
@@ -63,7 +63,7 @@ export const relativePath = (root, fileName) =>
|
|
|
63
63
|
|
|
64
64
|
export const sourceFileIdentity = (sourceFile) => canonicalFileIdentity(sourceFile.fileName);
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
const positions = (node) => {
|
|
67
67
|
const sourceFile = node.getSourceFile();
|
|
68
68
|
const nodes = node.name ? [node, node.name] : [node];
|
|
69
69
|
return nodes.map((candidate) => {
|
|
@@ -79,7 +79,7 @@ export const positions = (node) => {
|
|
|
79
79
|
|
|
80
80
|
export const nodeText = (node) => node?.text;
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
const declarationKind = (node) =>
|
|
83
83
|
DECLARATION_KIND_RULES.find(([checks]) => matchesAny(node, checks))?.[1];
|
|
84
84
|
|
|
85
85
|
export const declarationNamespaces = (node) =>
|
|
@@ -95,7 +95,7 @@ const ownerName = (node) => {
|
|
|
95
95
|
return ownerName(node.parent);
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
const declarationOwner = (node) => ownerName(node.parent);
|
|
99
99
|
|
|
100
100
|
export const ownerDeclaration = (node) => {
|
|
101
101
|
let current = node?.parent;
|