@descryy/adapter-kotlin 0.1.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/dist/adapter.d.ts +27 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +272 -0
- package/dist/adapter.js.map +1 -0
- package/dist/client.d.ts +93 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +344 -0
- package/dist/client.js.map +1 -0
- package/dist/extract.d.ts +56 -0
- package/dist/extract.d.ts.map +1 -0
- package/dist/extract.js +722 -0
- package/dist/extract.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/parse.d.ts +157 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +571 -0
- package/dist/parse.js.map +1 -0
- package/dist/retrofit.d.ts +78 -0
- package/dist/retrofit.d.ts.map +1 -0
- package/dist/retrofit.js +195 -0
- package/dist/retrofit.js.map +1 -0
- package/dist/routes.d.ts +54 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +231 -0
- package/dist/routes.js.map +1 -0
- package/dist/spring.d.ts +39 -0
- package/dist/spring.d.ts.map +1 -0
- package/dist/spring.js +231 -0
- package/dist/spring.js.map +1 -0
- package/dist/tree-sitter-kotlin.wasm +0 -0
- package/package.json +35 -0
package/dist/parse.js
ADDED
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading Kotlin structure out of a tree-sitter tree.
|
|
3
|
+
*
|
|
4
|
+
* ## Three grammar facts that decide the design
|
|
5
|
+
*
|
|
6
|
+
* **1. `class_declaration` covers class, interface, enum class and data class;
|
|
7
|
+
* `object_declaration` is separate.** The discriminator is the anonymous keyword
|
|
8
|
+
* child plus `modifiers`, exactly as in Swift — there is no `interface_declaration`
|
|
9
|
+
* node to match on. A reader that looked for one finds nothing and emits an empty
|
|
10
|
+
* graph, which is the failure this project keeps meeting: a true report about a
|
|
11
|
+
* graph that is missing everything.
|
|
12
|
+
*
|
|
13
|
+
* **2. A supertype list says which entry is the superclass, and Swift's did not.**
|
|
14
|
+
* `class C : Base(), Repository` parses as two `delegation_specifier` children —
|
|
15
|
+
* the first holding a `constructor_invocation`, the second a bare `user_type`.
|
|
16
|
+
* Kotlin requires the superclass constructor to be invoked and forbids invoking
|
|
17
|
+
* an interface, so **the parentheses are a syntactic discriminator**, not a
|
|
18
|
+
* heuristic.
|
|
19
|
+
*
|
|
20
|
+
* It is still not sufficient. `interface A : B` names a super-interface with no
|
|
21
|
+
* parentheses, and a bare entry in a class declaration may be an interface *or*
|
|
22
|
+
* a superclass whose constructor takes no explicit invocation in a secondary
|
|
23
|
+
* form. So the invocation is recorded as a **prior** and `extract.ts` decides
|
|
24
|
+
* against the declaration table, the same rule Swift uses. Guessing here would
|
|
25
|
+
* put a wrong edge in the graph, and rule 2 makes a wrong edge worse than a
|
|
26
|
+
* missing one.
|
|
27
|
+
*
|
|
28
|
+
* **3. `hasError` is true on trees with zero ERROR nodes.** Measured on a clean
|
|
29
|
+
* fixture: `descendantsOfType("ERROR")` is empty and `rootNode.hasError` is
|
|
30
|
+
* true. This is a property of the pinned grammar (DEC-171 investigated it), so
|
|
31
|
+
* error accounting here counts **ERROR subtrees**, never the flag. Reporting the
|
|
32
|
+
* flag would label every file in every repository as partially unread.
|
|
33
|
+
*
|
|
34
|
+
* ## What is deliberately not read
|
|
35
|
+
*
|
|
36
|
+
* Delegation (`by`), inline/reified generics, `typealias` targets, annotation
|
|
37
|
+
* arguments and destructuring declarations. Each is a place where the written
|
|
38
|
+
* text and the compiled meaning differ, and this adapter is breadth tier.
|
|
39
|
+
*/
|
|
40
|
+
import {} from "@descryy/adapter-treesitter";
|
|
41
|
+
import { readKtorRoutes } from "./routes.js";
|
|
42
|
+
import { readKtorClientCalls } from "./client.js";
|
|
43
|
+
import { readSpringRoutes } from "./spring.js";
|
|
44
|
+
import { readRetrofitEndpoints } from "./retrofit.js";
|
|
45
|
+
const lineOf = (node) => node.startPosition.row + 1;
|
|
46
|
+
const namedChildren = (node) => {
|
|
47
|
+
const out = [];
|
|
48
|
+
for (let i = 0; i < node.namedChildCount; i += 1) {
|
|
49
|
+
const child = node.namedChild(i);
|
|
50
|
+
if (child !== null)
|
|
51
|
+
out.push(child);
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
};
|
|
55
|
+
const childrenOf = (node) => {
|
|
56
|
+
const out = [];
|
|
57
|
+
for (let i = 0; i < node.childCount; i += 1) {
|
|
58
|
+
const child = node.child(i);
|
|
59
|
+
if (child !== null)
|
|
60
|
+
out.push(child);
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
};
|
|
64
|
+
const firstOfType = (node, type) => namedChildren(node).find((child) => child.type === type);
|
|
65
|
+
/** Every named descendant of a type, depth-first. */
|
|
66
|
+
function descendants(node, type, out = []) {
|
|
67
|
+
for (const child of namedChildren(node)) {
|
|
68
|
+
if (child.type === type)
|
|
69
|
+
out.push(child);
|
|
70
|
+
descendants(child, type, out);
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* ERROR subtrees, counted directly.
|
|
76
|
+
*
|
|
77
|
+
* Header fact 3: `hasError` is true on clean trees under this grammar, so it
|
|
78
|
+
* cannot be used. This walks for the node type instead.
|
|
79
|
+
*/
|
|
80
|
+
function hasErrorSubtree(node) {
|
|
81
|
+
if (node.type === "ERROR")
|
|
82
|
+
return true;
|
|
83
|
+
for (const child of childrenOf(node)) {
|
|
84
|
+
if (child.type === "ERROR" || child.isMissing)
|
|
85
|
+
return true;
|
|
86
|
+
if (hasErrorSubtree(child))
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
/** The modifier keywords on a declaration, as written. */
|
|
92
|
+
function modifiersOf(node) {
|
|
93
|
+
const block = firstOfType(node, "modifiers");
|
|
94
|
+
if (block === undefined)
|
|
95
|
+
return [];
|
|
96
|
+
return descendants(block, "simple_identifier")
|
|
97
|
+
.map((n) => n.text)
|
|
98
|
+
.concat(childrenOf(block).flatMap((c) => childrenOf(c).map((k) => k.text)))
|
|
99
|
+
.filter((t) => t !== "");
|
|
100
|
+
}
|
|
101
|
+
/** Annotation names on a declaration — `@Test`, `@Deprecated`. */
|
|
102
|
+
function annotationsOf(node) {
|
|
103
|
+
const block = firstOfType(node, "modifiers");
|
|
104
|
+
if (block === undefined)
|
|
105
|
+
return [];
|
|
106
|
+
const names = [];
|
|
107
|
+
for (const child of namedChildren(block)) {
|
|
108
|
+
if (!child.type.includes("annotation"))
|
|
109
|
+
continue;
|
|
110
|
+
for (const id of descendants(child, "type_identifier"))
|
|
111
|
+
names.push(id.text);
|
|
112
|
+
for (const id of descendants(child, "simple_identifier"))
|
|
113
|
+
names.push(id.text);
|
|
114
|
+
}
|
|
115
|
+
return names;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The keyword a `class_declaration` was written with.
|
|
119
|
+
*
|
|
120
|
+
* Anonymous children, so invisible to `namedChild`. `interface` is checked
|
|
121
|
+
* before `class` because `enum class` and `data class` both carry `class` and
|
|
122
|
+
* only the modifier block separates them.
|
|
123
|
+
*/
|
|
124
|
+
function declKindOf(node) {
|
|
125
|
+
if (node.type === "object_declaration")
|
|
126
|
+
return "object";
|
|
127
|
+
if (node.type === "companion_object")
|
|
128
|
+
return "companion";
|
|
129
|
+
for (const child of childrenOf(node)) {
|
|
130
|
+
if (child.isNamed)
|
|
131
|
+
continue;
|
|
132
|
+
if (child.type === "interface")
|
|
133
|
+
return "interface";
|
|
134
|
+
}
|
|
135
|
+
const modifiers = modifiersOf(node);
|
|
136
|
+
if (modifiers.includes("enum"))
|
|
137
|
+
return "enum";
|
|
138
|
+
if (modifiers.includes("annotation"))
|
|
139
|
+
return "annotation";
|
|
140
|
+
for (const child of childrenOf(node)) {
|
|
141
|
+
if (!child.isNamed && child.type === "enum")
|
|
142
|
+
return "enum";
|
|
143
|
+
}
|
|
144
|
+
// A declaration whose keyword is absent from the tree is malformed. `class` is
|
|
145
|
+
// the least specific answer rather than a guess at the most likely one.
|
|
146
|
+
return "class";
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* A written type, as the dotted path it is written as.
|
|
150
|
+
*
|
|
151
|
+
* `List<Order>` -> `List`. **`DiskLruCache.Snapshot` -> `DiskLruCache.Snapshot`,
|
|
152
|
+
* not `DiskLruCache`.**
|
|
153
|
+
*
|
|
154
|
+
* The first version returned the outermost `type_identifier` and so read a
|
|
155
|
+
* nested type as its enclosing one. Measured on okhttp: `val snapshot:
|
|
156
|
+
* DiskLruCache.Snapshot` typed the local as `DiskLruCache`, and every
|
|
157
|
+
* `snapshot.getSource(...)` was then refused with "getSource is not declared on
|
|
158
|
+
* DiskLruCache" — which is true, it is declared on `Snapshot`. 427 dotted type
|
|
159
|
+
* references on okhttp and 915 on ktor.
|
|
160
|
+
*
|
|
161
|
+
* This is the same defect the Swift adapter had for extension subjects, found
|
|
162
|
+
* there and not carried across, which is why the fix is written the same way:
|
|
163
|
+
* the dotted segments are the `user_type`'s **direct** `type_identifier`
|
|
164
|
+
* children, in order, while a generic argument sits under a `type_arguments`
|
|
165
|
+
* child. So the two cases separate structurally rather than by a rule about
|
|
166
|
+
* angle brackets.
|
|
167
|
+
*/
|
|
168
|
+
function typeNameOf(node) {
|
|
169
|
+
const user = findUserType(node);
|
|
170
|
+
if (user === undefined) {
|
|
171
|
+
if (node?.type === "type_identifier")
|
|
172
|
+
return node.text;
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
const segments = namedChildren(user)
|
|
176
|
+
.filter((child) => child.type === "type_identifier")
|
|
177
|
+
.map((child) => child.text);
|
|
178
|
+
return segments.length === 0 ? undefined : segments.join(".");
|
|
179
|
+
}
|
|
180
|
+
/** The first `user_type` at or under a node — past `nullable_type`, `type_annotation`. */
|
|
181
|
+
function findUserType(node) {
|
|
182
|
+
if (node === undefined)
|
|
183
|
+
return undefined;
|
|
184
|
+
if (node.type === "user_type")
|
|
185
|
+
return node;
|
|
186
|
+
for (const child of namedChildren(node)) {
|
|
187
|
+
const found = findUserType(child);
|
|
188
|
+
if (found !== undefined)
|
|
189
|
+
return found;
|
|
190
|
+
}
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* A supertype list entry.
|
|
195
|
+
*
|
|
196
|
+
* `constructor_invocation` is the superclass tell — Kotlin requires the
|
|
197
|
+
* superclass constructor to be invoked and forbids invoking an interface. It is
|
|
198
|
+
* recorded, not acted on; see header fact 2.
|
|
199
|
+
*/
|
|
200
|
+
function supertypeOf(node) {
|
|
201
|
+
const invocation = firstOfType(node, "constructor_invocation");
|
|
202
|
+
const subject = invocation ?? node;
|
|
203
|
+
const name = typeNameOf(subject);
|
|
204
|
+
if (name === undefined)
|
|
205
|
+
return undefined;
|
|
206
|
+
return { name, invoked: invocation !== undefined, line: lineOf(node) };
|
|
207
|
+
}
|
|
208
|
+
/** Functions under a node, for counting what an anonymous object hides. */
|
|
209
|
+
function countFunctions(node) {
|
|
210
|
+
return descendants(node, "function_declaration").length;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* `import a.b.C`, `import a.b.*`, `import a.b.C as D`.
|
|
214
|
+
*
|
|
215
|
+
* The whole dotted path is kept. Unlike Swift's module imports, a Kotlin import
|
|
216
|
+
* names a *symbol or a package*, and which one it is decides whether a reference
|
|
217
|
+
* resolves to it — so truncating to the first segment would lose the fact.
|
|
218
|
+
*/
|
|
219
|
+
function readImport(node, walk) {
|
|
220
|
+
const identifier = firstOfType(node, "identifier");
|
|
221
|
+
if (identifier === undefined)
|
|
222
|
+
return;
|
|
223
|
+
const isWildcard = firstOfType(node, "wildcard_import") !== undefined
|
|
224
|
+
|| node.text.trimEnd().endsWith(".*");
|
|
225
|
+
const aliasNode = namedChildren(node).find((c) => c.type === "import_alias");
|
|
226
|
+
walk.imports.push({
|
|
227
|
+
path: identifier.text,
|
|
228
|
+
isWildcard,
|
|
229
|
+
alias: aliasNode === undefined ? undefined : typeNameOf(aliasNode) ?? undefined,
|
|
230
|
+
line: lineOf(node),
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
/** JUnit and kotlin.test both spell it `@Test`; the import decides which. */
|
|
234
|
+
function testStyleOf(annotations, imports) {
|
|
235
|
+
if (!annotations.includes("Test"))
|
|
236
|
+
return undefined;
|
|
237
|
+
const paths = imports.map((i) => i.path);
|
|
238
|
+
if (paths.some((p) => p.startsWith("kotlin.test")))
|
|
239
|
+
return "kotlin-test";
|
|
240
|
+
if (paths.some((p) => p.startsWith("org.junit")))
|
|
241
|
+
return "junit";
|
|
242
|
+
// A `@Test` with neither import is still a test declaration. JUnit is the
|
|
243
|
+
// larger population, and the style is a label rather than an identity input.
|
|
244
|
+
return "junit";
|
|
245
|
+
}
|
|
246
|
+
/** The written type of a `val`/`var`, when one is stated. Kotlin infers a lot. */
|
|
247
|
+
function propertyTypeOf(node) {
|
|
248
|
+
const declaration = firstOfType(node, "variable_declaration");
|
|
249
|
+
if (declaration === undefined)
|
|
250
|
+
return typeNameOf(firstOfType(node, "user_type"));
|
|
251
|
+
return typeNameOf(firstOfType(declaration, "user_type"));
|
|
252
|
+
}
|
|
253
|
+
function propertyNameOf(node) {
|
|
254
|
+
const declaration = firstOfType(node, "variable_declaration");
|
|
255
|
+
const holder = declaration ?? node;
|
|
256
|
+
return firstOfType(holder, "simple_identifier")?.text;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* A call's callee and receiver.
|
|
260
|
+
*
|
|
261
|
+
* `a.b(x)` parses as `call_expression(navigation_expression(a, navigation_suffix(b)), call_suffix)`.
|
|
262
|
+
* A bare `b(x)` is `call_expression(simple_identifier, call_suffix)`.
|
|
263
|
+
*/
|
|
264
|
+
function readCall(node, scope, refs) {
|
|
265
|
+
const head = namedChildren(node)[0];
|
|
266
|
+
if (head === undefined)
|
|
267
|
+
return;
|
|
268
|
+
if (head.type === "simple_identifier") {
|
|
269
|
+
refs.push({
|
|
270
|
+
kind: "call",
|
|
271
|
+
name: head.text,
|
|
272
|
+
receiver: undefined,
|
|
273
|
+
hasReceiver: false,
|
|
274
|
+
receiverType: undefined,
|
|
275
|
+
line: lineOf(node),
|
|
276
|
+
});
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (head.type === "navigation_expression") {
|
|
280
|
+
const parts = namedChildren(head);
|
|
281
|
+
const target = parts[0];
|
|
282
|
+
const suffix = parts[parts.length - 1];
|
|
283
|
+
const name = suffix === undefined ? undefined : firstOfType(suffix, "simple_identifier")?.text;
|
|
284
|
+
if (name === undefined)
|
|
285
|
+
return;
|
|
286
|
+
// A receiver that is itself an expression — `a.b().c()` — has no written
|
|
287
|
+
// name by construction. `hasReceiver` stays true so the refusal reason says
|
|
288
|
+
// "unreadable receiver" rather than "no declaration for this name".
|
|
289
|
+
const receiver = target?.type === "simple_identifier" ? target.text : undefined;
|
|
290
|
+
refs.push({
|
|
291
|
+
kind: "call",
|
|
292
|
+
name,
|
|
293
|
+
receiver,
|
|
294
|
+
hasReceiver: true,
|
|
295
|
+
receiverType: receiver === undefined ? undefined : scope.locals.get(receiver),
|
|
296
|
+
line: lineOf(node),
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/** Type references written in a body — annotations, parameters, constructions. */
|
|
301
|
+
function readTypeRefs(node, refs) {
|
|
302
|
+
for (const user of descendants(node, "user_type")) {
|
|
303
|
+
const name = typeNameOf(user);
|
|
304
|
+
if (name === undefined)
|
|
305
|
+
continue;
|
|
306
|
+
refs.push({
|
|
307
|
+
kind: "type",
|
|
308
|
+
name,
|
|
309
|
+
receiver: undefined,
|
|
310
|
+
hasReceiver: false,
|
|
311
|
+
receiverType: undefined,
|
|
312
|
+
line: lineOf(user),
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* A class or enum named as a VALUE through a bare member access — `Status.PENDING`,
|
|
318
|
+
* with no call involved at all. DEC-068: this is real dependency information and
|
|
319
|
+
* is not expressible as CALLS, which targets functions; `resolveType` in
|
|
320
|
+
* `extract.ts` already knows how to turn a name like this into a type, so the
|
|
321
|
+
* ref is emitted with the same `kind: "type"` `readTypeRefs` uses.
|
|
322
|
+
*
|
|
323
|
+
* `callHeads` excludes navigation expressions that are a call's own callee —
|
|
324
|
+
* `repository.findById(id)` is a CALL and is read by `readCall`, not by this;
|
|
325
|
+
* counting it here too would be the same reference reported through two
|
|
326
|
+
* mechanisms rather than a second, genuinely different one.
|
|
327
|
+
*/
|
|
328
|
+
function readValueRefs(node, callHeads, refs) {
|
|
329
|
+
for (const nav of descendants(node, "navigation_expression")) {
|
|
330
|
+
if (callHeads.has(nav))
|
|
331
|
+
continue;
|
|
332
|
+
const target = namedChildren(nav)[0];
|
|
333
|
+
if (target?.type !== "simple_identifier")
|
|
334
|
+
continue;
|
|
335
|
+
refs.push({
|
|
336
|
+
kind: "type",
|
|
337
|
+
name: target.text,
|
|
338
|
+
receiver: undefined,
|
|
339
|
+
hasReceiver: false,
|
|
340
|
+
receiverType: undefined,
|
|
341
|
+
line: lineOf(nav),
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* `property_declaration`s that belong to THIS body, not to something nested in it.
|
|
347
|
+
*
|
|
348
|
+
* `descendants` reaches into method bodies and into a companion object, and both
|
|
349
|
+
* are wrong here: measured on a fixture, a `val h = Helper()` local inside a
|
|
350
|
+
* method was recorded as a property of the enclosing class, and a companion's
|
|
351
|
+
* `const val MAX` was recorded twice — once on the class and once on the
|
|
352
|
+
* companion. A member is a **direct** child of its body.
|
|
353
|
+
*/
|
|
354
|
+
function ownProperties(body) {
|
|
355
|
+
return namedChildren(body).filter((c) => c.type === "property_declaration");
|
|
356
|
+
}
|
|
357
|
+
/** Seed a scope's locals from parameters and `val`/`var` declarations. */
|
|
358
|
+
function seedLocals(node, scope, deep) {
|
|
359
|
+
for (const parameter of descendants(node, "parameter")) {
|
|
360
|
+
const name = firstOfType(parameter, "simple_identifier")?.text;
|
|
361
|
+
const type = typeNameOf(firstOfType(parameter, "user_type"));
|
|
362
|
+
if (name !== undefined && type !== undefined)
|
|
363
|
+
scope.locals.set(name, type);
|
|
364
|
+
}
|
|
365
|
+
for (const parameter of descendants(node, "class_parameter")) {
|
|
366
|
+
const name = firstOfType(parameter, "simple_identifier")?.text;
|
|
367
|
+
const type = typeNameOf(firstOfType(parameter, "user_type"));
|
|
368
|
+
if (name !== undefined && type !== undefined)
|
|
369
|
+
scope.locals.set(name, type);
|
|
370
|
+
}
|
|
371
|
+
// A function's locals are anywhere in its body; a class's members are only its
|
|
372
|
+
// direct children. Passing the wrong one is the defect above.
|
|
373
|
+
const properties = deep ? descendants(node, "property_declaration") : ownProperties(node);
|
|
374
|
+
for (const property of properties) {
|
|
375
|
+
const name = propertyNameOf(property);
|
|
376
|
+
const type = propertyTypeOf(property);
|
|
377
|
+
if (name !== undefined && type !== undefined)
|
|
378
|
+
scope.locals.set(name, type);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function readFunction(node, scope, walk, imports) {
|
|
382
|
+
const name = firstOfType(node, "simple_identifier")?.text;
|
|
383
|
+
if (name === undefined)
|
|
384
|
+
return;
|
|
385
|
+
const annotations = annotationsOf(node);
|
|
386
|
+
const testStyle = testStyleOf(annotations, imports);
|
|
387
|
+
const refs = [];
|
|
388
|
+
const inner = { owners: scope.owners, locals: new Map(scope.locals) };
|
|
389
|
+
// Parameters and locals are seeded BEFORE the body is walked. A method may use
|
|
390
|
+
// a property declared below it and Kotlin allows that; a single forward pass
|
|
391
|
+
// resolves a receiver only when the declaration happens to come first, which
|
|
392
|
+
// makes a resolved edge depend on source order.
|
|
393
|
+
seedLocals(node, inner, true);
|
|
394
|
+
const body = firstOfType(node, "function_body");
|
|
395
|
+
if (body !== undefined) {
|
|
396
|
+
const calls = descendants(body, "call_expression");
|
|
397
|
+
const callHeads = new Set(calls.map((call) => namedChildren(call)[0]).filter((h) => h !== undefined));
|
|
398
|
+
for (const call of calls)
|
|
399
|
+
readCall(call, inner, refs);
|
|
400
|
+
readTypeRefs(body, refs);
|
|
401
|
+
readValueRefs(body, callHeads, refs);
|
|
402
|
+
}
|
|
403
|
+
const parameters = firstOfType(node, "function_value_parameters");
|
|
404
|
+
if (parameters !== undefined)
|
|
405
|
+
readTypeRefs(parameters, refs);
|
|
406
|
+
walk.funcs.push({
|
|
407
|
+
name,
|
|
408
|
+
owners: scope.owners,
|
|
409
|
+
isTest: testStyle !== undefined,
|
|
410
|
+
testStyle,
|
|
411
|
+
startLine: lineOf(node),
|
|
412
|
+
endLine: node.endPosition.row + 1,
|
|
413
|
+
refs,
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
function walkNode(node, scope, walk, imports) {
|
|
417
|
+
for (const child of namedChildren(node)) {
|
|
418
|
+
switch (child.type) {
|
|
419
|
+
case "class_declaration":
|
|
420
|
+
case "object_declaration":
|
|
421
|
+
case "companion_object": {
|
|
422
|
+
const kind = declKindOf(child);
|
|
423
|
+
// A companion object is named `Companion` when it is anonymous, which is
|
|
424
|
+
// the JVM's own name for it and is stable. Anything else would churn.
|
|
425
|
+
const declared = firstOfType(child, "type_identifier")?.text;
|
|
426
|
+
const name = declared ?? (kind === "companion" ? "Companion" : undefined);
|
|
427
|
+
if (name === undefined)
|
|
428
|
+
break;
|
|
429
|
+
const supertypes = namedChildren(child)
|
|
430
|
+
.filter((c) => c.type === "delegation_specifier")
|
|
431
|
+
.map(supertypeOf)
|
|
432
|
+
.filter((s) => s !== undefined);
|
|
433
|
+
walk.decls.push({
|
|
434
|
+
kind,
|
|
435
|
+
name,
|
|
436
|
+
owners: scope.owners,
|
|
437
|
+
supertypes,
|
|
438
|
+
startLine: lineOf(child),
|
|
439
|
+
endLine: child.endPosition.row + 1,
|
|
440
|
+
});
|
|
441
|
+
const inner = { owners: [...scope.owners, name], locals: new Map() };
|
|
442
|
+
const constructor = firstOfType(child, "primary_constructor");
|
|
443
|
+
if (constructor !== undefined) {
|
|
444
|
+
seedLocals(constructor, inner, true);
|
|
445
|
+
// `data class Order(val id: String)` declares a PROPERTY, not just a
|
|
446
|
+
// parameter — the `val`/`var` binding is what makes it one, and a
|
|
447
|
+
// parameter without it is not a member. Kotlin's data classes put most
|
|
448
|
+
// model fields here, so a reader that only walks the class body reads
|
|
449
|
+
// a model with no fields and reports it as a fact about the model.
|
|
450
|
+
for (const parameter of namedChildren(constructor)) {
|
|
451
|
+
if (parameter.type !== "class_parameter")
|
|
452
|
+
continue;
|
|
453
|
+
const binding = firstOfType(parameter, "binding_pattern_kind");
|
|
454
|
+
if (binding === undefined)
|
|
455
|
+
continue;
|
|
456
|
+
const propertyName = firstOfType(parameter, "simple_identifier")?.text;
|
|
457
|
+
if (propertyName === undefined)
|
|
458
|
+
continue;
|
|
459
|
+
walk.properties.push({
|
|
460
|
+
name: propertyName,
|
|
461
|
+
owners: inner.owners,
|
|
462
|
+
type: typeNameOf(firstOfType(parameter, "user_type")),
|
|
463
|
+
line: lineOf(parameter),
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
const body = namedChildren(child).find((c) => c.type === "class_body" || c.type === "enum_class_body");
|
|
468
|
+
if (body !== undefined) {
|
|
469
|
+
seedLocals(body, inner, false);
|
|
470
|
+
for (const property of ownProperties(body)) {
|
|
471
|
+
const propertyName = propertyNameOf(property);
|
|
472
|
+
if (propertyName === undefined)
|
|
473
|
+
continue;
|
|
474
|
+
walk.properties.push({
|
|
475
|
+
name: propertyName,
|
|
476
|
+
owners: inner.owners,
|
|
477
|
+
type: propertyTypeOf(property),
|
|
478
|
+
line: lineOf(property),
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
walkNode(body, inner, walk, imports);
|
|
482
|
+
}
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
case "function_declaration":
|
|
486
|
+
readFunction(child, scope, walk, imports);
|
|
487
|
+
break;
|
|
488
|
+
case "lambda_literal":
|
|
489
|
+
// A declaration inside a lambda body is never a top-level declaration,
|
|
490
|
+
// and this branch exists because the grammar makes that load-bearing.
|
|
491
|
+
//
|
|
492
|
+
// tree-sitter-kotlin 0.3.8 does not support `fun interface` — Kotlin's
|
|
493
|
+
// SAM interface. `fun interface Dns { interface Call; class Request }`
|
|
494
|
+
// parses as an ERROR node followed by an ORPHANED `lambda_literal`
|
|
495
|
+
// holding the body, so `Call` and `Request` arrive with no owners and
|
|
496
|
+
// were minted as top-level `okhttp3.Call` and `okhttp3.Request`.
|
|
497
|
+
//
|
|
498
|
+
// That is a WRONG node, not a missing one: it gave `import
|
|
499
|
+
// okhttp3.Request` an edge to a type that is really `okhttp3.Dns.Request`.
|
|
500
|
+
// Rule 2 ranks a wrong node worse, so the body is not walked and the
|
|
501
|
+
// count is disclosed. Same family as the single-line `class_body`
|
|
502
|
+
// limitation already recorded in grammar.json.
|
|
503
|
+
walk.unparseableDeclarations += descendants(child, "class_declaration").length;
|
|
504
|
+
break;
|
|
505
|
+
case "object_literal":
|
|
506
|
+
// `object : DerAdapter<Long> { override fun encode(...) }` — an
|
|
507
|
+
// ANONYMOUS type. It has no name, so its members have no qualified
|
|
508
|
+
// symbol path and cannot be given an identity.
|
|
509
|
+
//
|
|
510
|
+
// Walking into it with the ENCLOSING scope is what the default branch
|
|
511
|
+
// below used to do, and it is worse than skipping: measured on okhttp,
|
|
512
|
+
// `der/Adapters.kt` declares `override fun encode` fourteen times in
|
|
513
|
+
// fourteen anonymous objects, and all fourteen collapsed onto one node
|
|
514
|
+
// owned by the enclosing `Adapters`. Calls from the other thirteen were
|
|
515
|
+
// then attributed to the survivor — WRONG edges, not missing ones, and
|
|
516
|
+
// both of that repository's CALLS precision failures were this.
|
|
517
|
+
//
|
|
518
|
+
// So the body is not walked. The members are unreachable at R2 and that
|
|
519
|
+
// is a disclosed gap rather than an invented owner.
|
|
520
|
+
walk.anonymousMembers += countFunctions(child);
|
|
521
|
+
break;
|
|
522
|
+
default:
|
|
523
|
+
// `statements`, `class_body` contents and anything else that can hold a
|
|
524
|
+
// declaration are walked through rather than matched on, so a construct
|
|
525
|
+
// this reader does not know about does not hide the ones it does.
|
|
526
|
+
if (child.namedChildCount > 0)
|
|
527
|
+
walkNode(child, scope, walk, imports);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
/** Parse one Kotlin file into the structures `extract.ts` consumes. */
|
|
532
|
+
export function readKotlinFile(file, tree) {
|
|
533
|
+
const root = tree.rootNode;
|
|
534
|
+
const walk = { anonymousMembers: 0, unparseableDeclarations: 0, imports: [], decls: [], funcs: [], properties: [] };
|
|
535
|
+
const header = firstOfType(root, "package_header");
|
|
536
|
+
const packageName = header === undefined ? "" : firstOfType(header, "identifier")?.text ?? "";
|
|
537
|
+
// Imports are read first so `testStyleOf` can see them while walking bodies.
|
|
538
|
+
const importList = firstOfType(root, "import_list");
|
|
539
|
+
if (importList !== undefined) {
|
|
540
|
+
for (const child of namedChildren(importList)) {
|
|
541
|
+
if (child.type === "import_header")
|
|
542
|
+
readImport(child, walk);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
walkNode(root, { owners: [], locals: new Map() }, walk, walk.imports);
|
|
546
|
+
// After the walk, because provenance is decided by the import table and the
|
|
547
|
+
// import may sit anywhere above the routing block that needs it.
|
|
548
|
+
const routes = readKtorRoutes(root, walk.imports);
|
|
549
|
+
const client = readKtorClientCalls(root, walk.imports);
|
|
550
|
+
const springRoutes = readSpringRoutes(root, walk.imports);
|
|
551
|
+
const retrofit = readRetrofitEndpoints(root, walk.imports);
|
|
552
|
+
return {
|
|
553
|
+
file,
|
|
554
|
+
hasError: hasErrorSubtree(root),
|
|
555
|
+
packageName,
|
|
556
|
+
imports: walk.imports,
|
|
557
|
+
decls: walk.decls,
|
|
558
|
+
funcs: walk.funcs,
|
|
559
|
+
properties: walk.properties,
|
|
560
|
+
anonymousMembers: walk.anonymousMembers,
|
|
561
|
+
unparseableDeclarations: walk.unparseableDeclarations,
|
|
562
|
+
identityPackage: undefined,
|
|
563
|
+
routes: [...routes.declarations, ...springRoutes],
|
|
564
|
+
routeRefusals: routes.refusals,
|
|
565
|
+
clientCalls: client.calls,
|
|
566
|
+
clientRefusals: client.refusals,
|
|
567
|
+
retrofitEndpoints: retrofit.declarations,
|
|
568
|
+
retrofitRefusals: retrofit.refusals,
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAa,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,cAAc,EAA6C,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAmD,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAA2D,MAAM,eAAe,CAAC;AAyH/G,MAAM,MAAM,GAAG,CAAC,IAAU,EAAU,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC,CAAC;AAElE,MAAM,aAAa,GAAG,CAAC,IAAU,EAAU,EAAE;IAC3C,MAAM,GAAG,GAAW,EAAE,CAAC;IACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACjD,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,KAAK,KAAK,IAAI;YAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAA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