@cleocode/nexus 2026.5.28 → 2026.5.29
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/src/intelligence/providers/typescript.d.ts.map +1 -1
- package/dist/src/intelligence/providers/typescript.js +10 -3
- package/dist/src/intelligence/providers/typescript.js.map +1 -1
- package/dist/src/pipeline/call-processor.d.ts.map +1 -1
- package/dist/src/pipeline/call-processor.js +8 -2
- package/dist/src/pipeline/call-processor.js.map +1 -1
- package/dist/src/pipeline/community-processor.d.ts.map +1 -1
- package/dist/src/pipeline/community-processor.js +4 -1
- package/dist/src/pipeline/community-processor.js.map +1 -1
- package/dist/src/pipeline/extractors/generic-extractor.d.ts +69 -0
- package/dist/src/pipeline/extractors/generic-extractor.d.ts.map +1 -0
- package/dist/src/pipeline/extractors/generic-extractor.js +410 -0
- package/dist/src/pipeline/extractors/generic-extractor.js.map +1 -0
- package/dist/src/pipeline/extractors/java-extractor.d.ts +77 -0
- package/dist/src/pipeline/extractors/java-extractor.d.ts.map +1 -0
- package/dist/src/pipeline/extractors/java-extractor.js +290 -0
- package/dist/src/pipeline/extractors/java-extractor.js.map +1 -0
- package/dist/src/pipeline/extractors/language-config.d.ts +333 -0
- package/dist/src/pipeline/extractors/language-config.d.ts.map +1 -0
- package/dist/src/pipeline/extractors/language-config.js +21 -0
- package/dist/src/pipeline/extractors/language-config.js.map +1 -0
- package/dist/src/pipeline/extractors/typescript-extractor.d.ts.map +1 -1
- package/dist/src/pipeline/extractors/typescript-extractor.js +20 -2
- package/dist/src/pipeline/extractors/typescript-extractor.js.map +1 -1
- package/dist/src/pipeline/heritage-processor.d.ts +2 -0
- package/dist/src/pipeline/heritage-processor.d.ts.map +1 -1
- package/dist/src/pipeline/heritage-processor.js +100 -1
- package/dist/src/pipeline/heritage-processor.js.map +1 -1
- package/dist/src/pipeline/import-processor.d.ts.map +1 -1
- package/dist/src/pipeline/import-processor.js +7 -2
- package/dist/src/pipeline/import-processor.js.map +1 -1
- package/dist/src/pipeline/index.d.ts +6 -0
- package/dist/src/pipeline/index.d.ts.map +1 -1
- package/dist/src/pipeline/index.js +14 -2
- package/dist/src/pipeline/index.js.map +1 -1
- package/dist/src/pipeline/parse-loop.d.ts +6 -2
- package/dist/src/pipeline/parse-loop.d.ts.map +1 -1
- package/dist/src/pipeline/parse-loop.js +112 -8
- package/dist/src/pipeline/parse-loop.js.map +1 -1
- package/dist/src/pipeline/process-processor.d.ts.map +1 -1
- package/dist/src/pipeline/process-processor.js +7 -2
- package/dist/src/pipeline/process-processor.js.map +1 -1
- package/dist/src/pipeline/processors/access-processor.d.ts +133 -0
- package/dist/src/pipeline/processors/access-processor.d.ts.map +1 -0
- package/dist/src/pipeline/processors/access-processor.js +351 -0
- package/dist/src/pipeline/processors/access-processor.js.map +1 -0
- package/dist/src/pipeline/structure-processor.d.ts.map +1 -1
- package/dist/src/pipeline/structure-processor.js +4 -1
- package/dist/src/pipeline/structure-processor.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic AST extractor — single walker parametrized by LanguageConfig.
|
|
3
|
+
*
|
|
4
|
+
* Implements the core insight from Graphify v7's `_extract_generic` function
|
|
5
|
+
* (`extract.py:933`, 794 lines) that drives 13 of 26 supported languages from
|
|
6
|
+
* one walker by accepting a {@link LanguageConfig} dataclass per language.
|
|
7
|
+
*
|
|
8
|
+
* In Graphify, the config-driven path drastically reduces per-language code:
|
|
9
|
+
* each new language requires only a 12–20 line declarative config block rather
|
|
10
|
+
* than a 200–600 line hand-written extractor. This module ports that pattern to
|
|
11
|
+
* TypeScript for the CLEO nexus pipeline.
|
|
12
|
+
*
|
|
13
|
+
* Extracted artefacts:
|
|
14
|
+
* - **Definitions**: functions, classes, methods, constructors (via
|
|
15
|
+
* {@link LanguageConfig.functionNodeTypes}, {@link LanguageConfig.classNodeTypes},
|
|
16
|
+
* {@link LanguageConfig.methodNodeTypes})
|
|
17
|
+
* - **Imports**: import/use/include statements (via
|
|
18
|
+
* {@link LanguageConfig.importNodeTypes} + optional
|
|
19
|
+
* {@link LanguageConfig.importHandler} callback)
|
|
20
|
+
* - **Heritage**: extends / implements relationships (via
|
|
21
|
+
* {@link LanguageConfig.inheritanceFieldPaths})
|
|
22
|
+
* - **Calls**: method and free-function call sites (via
|
|
23
|
+
* {@link LanguageConfig.callNodeTypes})
|
|
24
|
+
* - **Post-pass**: optional {@link LanguageConfig.extraWalkFn} for language
|
|
25
|
+
* quirks that don't fit the primary model (arrow functions, enum cases, etc.)
|
|
26
|
+
*
|
|
27
|
+
* @arch See graphify v7 inspiration: https://github.com/safishamsi/graphify
|
|
28
|
+
* branch v7, `_extract_generic` at `extract.py:933`.
|
|
29
|
+
*
|
|
30
|
+
* @module pipeline/extractors/generic-extractor
|
|
31
|
+
*/
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
// Internal helpers
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
/** Convert 0-based tree-sitter row to 1-based line number. */
|
|
36
|
+
function toLine(row) {
|
|
37
|
+
return row + 1;
|
|
38
|
+
}
|
|
39
|
+
/** Derive a stable node ID from file path and symbol name. */
|
|
40
|
+
function nodeId(filePath, name) {
|
|
41
|
+
return `${filePath}::${name}`;
|
|
42
|
+
}
|
|
43
|
+
/** Default method names treated as constructors. */
|
|
44
|
+
const DEFAULT_CONSTRUCTOR_NAMES = new Set(['<init>', 'constructor']);
|
|
45
|
+
/**
|
|
46
|
+
* Resolve a dot-separated field path against an AST node.
|
|
47
|
+
*
|
|
48
|
+
* Single-segment paths (no dot) call `childForFieldName` directly.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* resolveFieldPath(node, 'name') // equivalent to node.childForFieldName('name')
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
function resolveFieldPath(node, path) {
|
|
56
|
+
const parts = path.split('.');
|
|
57
|
+
let current = node;
|
|
58
|
+
for (const part of parts) {
|
|
59
|
+
current = current.childForFieldName(part);
|
|
60
|
+
if (!current)
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return current;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Extract parameter names from a parameter-list node.
|
|
67
|
+
*
|
|
68
|
+
* Handles the common pattern where each parameter node exposes a `name` field
|
|
69
|
+
* or is an `identifier` node directly. Skips conventional receiver names
|
|
70
|
+
* (`this`, `self`, `cls`).
|
|
71
|
+
*/
|
|
72
|
+
function extractParamNames(paramsNode) {
|
|
73
|
+
const names = [];
|
|
74
|
+
const SKIP = new Set(['this', 'self', 'cls']);
|
|
75
|
+
for (let i = 0; i < paramsNode.namedChildCount; i++) {
|
|
76
|
+
const param = paramsNode.namedChild(i);
|
|
77
|
+
if (!param)
|
|
78
|
+
continue;
|
|
79
|
+
const nameNode = param.childForFieldName('name') ?? (param.type === 'identifier' ? param : null);
|
|
80
|
+
if (nameNode?.text && !SKIP.has(nameNode.text)) {
|
|
81
|
+
names.push(nameNode.text);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return names;
|
|
85
|
+
}
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
// Definition extraction helpers
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
/**
|
|
90
|
+
* Emit a function / method / constructor node from a function-like AST node.
|
|
91
|
+
*
|
|
92
|
+
* @param node - The function declaration AST node
|
|
93
|
+
* @param filePath - File path relative to repo root
|
|
94
|
+
* @param config - Language configuration
|
|
95
|
+
* @param parentName - Qualified parent class name, or undefined for top-level
|
|
96
|
+
* @param results - Accumulator (mutated in place)
|
|
97
|
+
*/
|
|
98
|
+
function emitFunction(node, filePath, config, parentName, results) {
|
|
99
|
+
const nameNode = resolveFieldPath(node, config.nameFieldPath);
|
|
100
|
+
if (!nameNode)
|
|
101
|
+
return;
|
|
102
|
+
const name = nameNode.text;
|
|
103
|
+
if (!name)
|
|
104
|
+
return;
|
|
105
|
+
const constructorNames = config.constructorNames ?? DEFAULT_CONSTRUCTOR_NAMES;
|
|
106
|
+
const kind = constructorNames.has(name) ? 'constructor' : 'function';
|
|
107
|
+
const paramsNode = node.childForFieldName(config.parametersFieldPath);
|
|
108
|
+
const parameters = paramsNode ? extractParamNames(paramsNode) : [];
|
|
109
|
+
const qualifiedName = parentName ? `${parentName}.${name}` : name;
|
|
110
|
+
const isExported = config.isExported ? config.isExported(node, name) : true;
|
|
111
|
+
results.push({
|
|
112
|
+
id: nodeId(filePath, qualifiedName),
|
|
113
|
+
kind,
|
|
114
|
+
name,
|
|
115
|
+
filePath,
|
|
116
|
+
startLine: toLine(node.startPosition.row),
|
|
117
|
+
endLine: toLine(node.endPosition.row),
|
|
118
|
+
language: config.language,
|
|
119
|
+
exported: parentName ? false : isExported,
|
|
120
|
+
parent: parentName ? nodeId(filePath, parentName) : undefined,
|
|
121
|
+
parameters,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Emit a method node from a method declaration inside a class body.
|
|
126
|
+
*
|
|
127
|
+
* Sets kind to `'method'` unless the name matches a constructor name, in
|
|
128
|
+
* which case kind is `'constructor'`.
|
|
129
|
+
*/
|
|
130
|
+
function emitMethod(node, filePath, config, parentName, results) {
|
|
131
|
+
const nameNode = resolveFieldPath(node, config.nameFieldPath);
|
|
132
|
+
if (!nameNode)
|
|
133
|
+
return;
|
|
134
|
+
const name = nameNode.text;
|
|
135
|
+
if (!name)
|
|
136
|
+
return;
|
|
137
|
+
const constructorNames = config.constructorNames ?? DEFAULT_CONSTRUCTOR_NAMES;
|
|
138
|
+
const isConstructorByType = config.constructorNodeTypes?.has(node.type) ?? false;
|
|
139
|
+
const kind = isConstructorByType || constructorNames.has(name) ? 'constructor' : 'method';
|
|
140
|
+
const paramsNode = node.childForFieldName(config.parametersFieldPath);
|
|
141
|
+
const parameters = paramsNode ? extractParamNames(paramsNode) : [];
|
|
142
|
+
results.push({
|
|
143
|
+
id: nodeId(filePath, `${parentName}.${name}`),
|
|
144
|
+
kind,
|
|
145
|
+
name,
|
|
146
|
+
filePath,
|
|
147
|
+
startLine: toLine(node.startPosition.row),
|
|
148
|
+
endLine: toLine(node.endPosition.row),
|
|
149
|
+
language: config.language,
|
|
150
|
+
exported: false,
|
|
151
|
+
parent: nodeId(filePath, parentName),
|
|
152
|
+
parameters,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Collect all type names from an inheritance specifier node (possibly nested).
|
|
157
|
+
*
|
|
158
|
+
* Handles:
|
|
159
|
+
* - Direct `type_identifier` → one name
|
|
160
|
+
* - `generic_type` (`List<String>`) → base name only (e.g. `List`)
|
|
161
|
+
* - `type_list` (Java `super_interfaces` child) → multiple names (recurse)
|
|
162
|
+
* - Any other container → recurse into named children up to depth 3
|
|
163
|
+
*
|
|
164
|
+
* Returns all found type names so callers can emit one heritage record each.
|
|
165
|
+
*/
|
|
166
|
+
function collectTypeNames(node, config, depth = 0) {
|
|
167
|
+
if (depth > 3)
|
|
168
|
+
return [];
|
|
169
|
+
// Direct match: type_identifier or any node in inheritanceNameNodeTypes
|
|
170
|
+
if (config.inheritanceNameNodeTypes.has(node.type)) {
|
|
171
|
+
const text = node.text.trim();
|
|
172
|
+
return text ? [text] : [];
|
|
173
|
+
}
|
|
174
|
+
// Generic type: `Comparable<String>` → just `Comparable`
|
|
175
|
+
if (node.type === 'generic_type') {
|
|
176
|
+
const inner = node.namedChild(0);
|
|
177
|
+
if (inner) {
|
|
178
|
+
if (config.inheritanceNameNodeTypes.has(inner.type)) {
|
|
179
|
+
const text = inner.text.trim();
|
|
180
|
+
return text ? [text] : [];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// Container node (e.g. `type_list`, `superclass`, `super_interfaces`,
|
|
185
|
+
// `interface_type_list`): recurse into all named children
|
|
186
|
+
const names = [];
|
|
187
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
188
|
+
const child = node.namedChild(i);
|
|
189
|
+
if (!child)
|
|
190
|
+
continue;
|
|
191
|
+
const found = collectTypeNames(child, config, depth + 1);
|
|
192
|
+
for (const n of found)
|
|
193
|
+
names.push(n);
|
|
194
|
+
}
|
|
195
|
+
return names;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Emit a class node and all methods in its body, plus heritage records.
|
|
199
|
+
*
|
|
200
|
+
* @param node - The class declaration AST node
|
|
201
|
+
* @param filePath - File path relative to repo root
|
|
202
|
+
* @param config - Language configuration
|
|
203
|
+
* @param definitions - Accumulator for definition nodes (mutated in place)
|
|
204
|
+
* @param heritage - Accumulator for heritage records (mutated in place)
|
|
205
|
+
*/
|
|
206
|
+
function emitClass(node, filePath, config, definitions, heritage) {
|
|
207
|
+
const nameNode = resolveFieldPath(node, config.nameFieldPath);
|
|
208
|
+
if (!nameNode)
|
|
209
|
+
return;
|
|
210
|
+
const className = nameNode.text;
|
|
211
|
+
if (!className)
|
|
212
|
+
return;
|
|
213
|
+
const isExported = config.isExported ? config.isExported(node, className) : true;
|
|
214
|
+
const kind = config.kindOverrides?.get(node.type) ?? 'class';
|
|
215
|
+
definitions.push({
|
|
216
|
+
id: nodeId(filePath, className),
|
|
217
|
+
kind,
|
|
218
|
+
name: className,
|
|
219
|
+
filePath,
|
|
220
|
+
startLine: toLine(node.startPosition.row),
|
|
221
|
+
endLine: toLine(node.endPosition.row),
|
|
222
|
+
language: config.language,
|
|
223
|
+
exported: isExported,
|
|
224
|
+
});
|
|
225
|
+
// Emit heritage (extends / implements)
|
|
226
|
+
for (const { fieldName, kind: heritageKind } of config.inheritanceFieldPaths) {
|
|
227
|
+
const heritageNode = node.childForFieldName(fieldName);
|
|
228
|
+
if (!heritageNode)
|
|
229
|
+
continue;
|
|
230
|
+
// Collect all type names from the heritage node (handles nested type_list)
|
|
231
|
+
const parentTypeNames = collectTypeNames(heritageNode, config);
|
|
232
|
+
for (const parentTypeName of parentTypeNames) {
|
|
233
|
+
heritage.push({
|
|
234
|
+
filePath,
|
|
235
|
+
typeName: className,
|
|
236
|
+
typeNodeId: nodeId(filePath, className),
|
|
237
|
+
kind: heritageKind,
|
|
238
|
+
parentName: parentTypeName,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
// Emit methods inside the class body
|
|
243
|
+
const bodyNode = node.childForFieldName(config.bodyFieldPath);
|
|
244
|
+
if (!bodyNode)
|
|
245
|
+
return;
|
|
246
|
+
for (let i = 0; i < bodyNode.namedChildCount; i++) {
|
|
247
|
+
const member = bodyNode.namedChild(i);
|
|
248
|
+
if (!member)
|
|
249
|
+
continue;
|
|
250
|
+
if (config.methodNodeTypes.has(member.type)) {
|
|
251
|
+
emitMethod(member, filePath, config, className, definitions);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
// ---------------------------------------------------------------------------
|
|
256
|
+
// Call site extraction
|
|
257
|
+
// ---------------------------------------------------------------------------
|
|
258
|
+
/**
|
|
259
|
+
* Emit a call record from a call expression node.
|
|
260
|
+
*
|
|
261
|
+
* Uses {@link LanguageConfig.callFunctionPath} to locate the callee identifier.
|
|
262
|
+
*/
|
|
263
|
+
function emitCall(node, filePath, config, results) {
|
|
264
|
+
const calleeNode = resolveFieldPath(node, config.callFunctionPath);
|
|
265
|
+
if (!calleeNode)
|
|
266
|
+
return;
|
|
267
|
+
const calledName = calleeNode.text;
|
|
268
|
+
if (!calledName)
|
|
269
|
+
return;
|
|
270
|
+
results.push({
|
|
271
|
+
filePath,
|
|
272
|
+
calledName,
|
|
273
|
+
sourceId: `${filePath}::__file__`,
|
|
274
|
+
callForm: 'free',
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
// ---------------------------------------------------------------------------
|
|
278
|
+
// Import extraction
|
|
279
|
+
// ---------------------------------------------------------------------------
|
|
280
|
+
/**
|
|
281
|
+
* Process a single import-bearing AST node.
|
|
282
|
+
*
|
|
283
|
+
* Delegates to {@link LanguageConfig.importHandler} when set; otherwise
|
|
284
|
+
* applies a default text-extraction strategy.
|
|
285
|
+
*/
|
|
286
|
+
function processImport(node, filePath, config, results) {
|
|
287
|
+
if (config.importHandler) {
|
|
288
|
+
const rawPath = node.text;
|
|
289
|
+
config.importHandler({ node, filePath, rawPath }, results);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
// Default: strip quotes and use raw text
|
|
293
|
+
const rawImportPath = node.text.replace(/^['"`]|['"`]$/g, '').trim();
|
|
294
|
+
if (rawImportPath) {
|
|
295
|
+
results.push({ filePath, rawImportPath });
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// ---------------------------------------------------------------------------
|
|
299
|
+
// Post-pass extra walk
|
|
300
|
+
// ---------------------------------------------------------------------------
|
|
301
|
+
/**
|
|
302
|
+
* Run {@link LanguageConfig.extraWalkFn} on every node in the subtree.
|
|
303
|
+
*
|
|
304
|
+
* Mirrors graphify's `_apply_extra_walk` helper. The callback receives a
|
|
305
|
+
* shared mutable context so it can push records into any of the result arrays.
|
|
306
|
+
*/
|
|
307
|
+
function runExtraWalk(node, ctx, config) {
|
|
308
|
+
config.extraWalkFn({ ...ctx, node });
|
|
309
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
310
|
+
const child = node.namedChild(i);
|
|
311
|
+
if (child)
|
|
312
|
+
runExtraWalk(child, ctx, config);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
// ---------------------------------------------------------------------------
|
|
316
|
+
// Main entry point
|
|
317
|
+
// ---------------------------------------------------------------------------
|
|
318
|
+
/**
|
|
319
|
+
* Extract all intelligence from a source file AST using a declarative
|
|
320
|
+
* {@link LanguageConfig}.
|
|
321
|
+
*
|
|
322
|
+
* This is the TypeScript port of Graphify v7's `_extract_generic` walker
|
|
323
|
+
* (`extract.py:933`). It performs a single-pass traversal of the AST,
|
|
324
|
+
* emitting definitions, imports, heritage records, and call records based
|
|
325
|
+
* on the configuration provided.
|
|
326
|
+
*
|
|
327
|
+
* The `tree` parameter is kept for API parity with future incremental-walk
|
|
328
|
+
* support (tree-sitter's `Tree` object). It is currently unused.
|
|
329
|
+
*
|
|
330
|
+
* @param rootNode - The root node of the parsed tree-sitter AST
|
|
331
|
+
* @param tree - Reserved for future incremental-walk support (currently unused)
|
|
332
|
+
* @param fileNodeId - Node ID of the file, format `<filePath>::__file__`
|
|
333
|
+
* @param config - Language-specific configuration record
|
|
334
|
+
* @returns Full extraction result for the file
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```ts
|
|
338
|
+
* import { extractGeneric } from './generic-extractor.js';
|
|
339
|
+
* import { JAVA_CONFIG } from './java-extractor.js';
|
|
340
|
+
*
|
|
341
|
+
* const result = extractGeneric(
|
|
342
|
+
* rootNode,
|
|
343
|
+
* tree,
|
|
344
|
+
* 'src/Main.java::__file__',
|
|
345
|
+
* JAVA_CONFIG,
|
|
346
|
+
* );
|
|
347
|
+
* ```
|
|
348
|
+
*
|
|
349
|
+
* @arch See graphify v7 `_extract_generic` at `extract.py:933` (794 lines).
|
|
350
|
+
* This implementation covers: function/class/method/import/heritage/call
|
|
351
|
+
* extraction plus an `extraWalkFn` escape hatch for language quirks.
|
|
352
|
+
*/
|
|
353
|
+
export function extractGeneric(rootNode, tree, fileNodeId, config) {
|
|
354
|
+
void tree; // reserved for future incremental-walk support
|
|
355
|
+
// Derive file path from the node ID convention `<filePath>::__file__`
|
|
356
|
+
const SUFFIX = '::__file__';
|
|
357
|
+
const filePath = fileNodeId.endsWith(SUFFIX) ? fileNodeId.slice(0, -SUFFIX.length) : fileNodeId;
|
|
358
|
+
const definitions = [];
|
|
359
|
+
const imports = [];
|
|
360
|
+
const heritage = [];
|
|
361
|
+
const calls = [];
|
|
362
|
+
/**
|
|
363
|
+
* Primary scoped walker — single pass over the AST.
|
|
364
|
+
*
|
|
365
|
+
* - Classes: emit class + methods, then return (avoid double-visiting bodies)
|
|
366
|
+
* - Top-level functions: emit immediately
|
|
367
|
+
* - Imports: delegate to processImport
|
|
368
|
+
* - Calls: delegate to emitCall
|
|
369
|
+
* - Everything else: recurse into named children
|
|
370
|
+
*/
|
|
371
|
+
function walk(node) {
|
|
372
|
+
const { type } = node;
|
|
373
|
+
// Class-like: emit class + methods (class body is handled by emitClass)
|
|
374
|
+
if (config.classNodeTypes.has(type)) {
|
|
375
|
+
emitClass(node, filePath, config, definitions, heritage);
|
|
376
|
+
return; // Do NOT recurse further — emitClass owns the body
|
|
377
|
+
}
|
|
378
|
+
// Top-level function (methods are handled inside emitClass above)
|
|
379
|
+
if (config.functionNodeTypes.has(type)) {
|
|
380
|
+
emitFunction(node, filePath, config, undefined, definitions);
|
|
381
|
+
}
|
|
382
|
+
// Import statement
|
|
383
|
+
if (config.importNodeTypes.has(type)) {
|
|
384
|
+
processImport(node, filePath, config, imports);
|
|
385
|
+
}
|
|
386
|
+
// Call expression
|
|
387
|
+
if (config.callNodeTypes.has(type)) {
|
|
388
|
+
emitCall(node, filePath, config, calls);
|
|
389
|
+
}
|
|
390
|
+
// Recurse into named children
|
|
391
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
392
|
+
const child = node.namedChild(i);
|
|
393
|
+
if (child)
|
|
394
|
+
walk(child);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
// Run the primary walker over all root-level children
|
|
398
|
+
for (let i = 0; i < rootNode.namedChildCount; i++) {
|
|
399
|
+
const child = rootNode.namedChild(i);
|
|
400
|
+
if (child)
|
|
401
|
+
walk(child);
|
|
402
|
+
}
|
|
403
|
+
// Post-pass: optional language-specific extra walk
|
|
404
|
+
if (config.extraWalkFn) {
|
|
405
|
+
const ctx = { filePath, language: config.language, definitions, imports, heritage, calls };
|
|
406
|
+
runExtraWalk(rootNode, ctx, config);
|
|
407
|
+
}
|
|
408
|
+
return { definitions, imports, heritage, calls };
|
|
409
|
+
}
|
|
410
|
+
//# sourceMappingURL=generic-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic-extractor.js","sourceRoot":"","sources":["../../../../src/pipeline/extractors/generic-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAYH,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,8DAA8D;AAC9D,SAAS,MAAM,CAAC,GAAW;IACzB,OAAO,GAAG,GAAG,CAAC,CAAC;AACjB,CAAC;AAED,8DAA8D;AAC9D,SAAS,MAAM,CAAC,QAAgB,EAAE,IAAY;IAC5C,OAAO,GAAG,QAAQ,KAAK,IAAI,EAAE,CAAC;AAChC,CAAC;AAED,oDAAoD;AACpD,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC;AAE1F;;;;;;;;;GASG;AACH,SAAS,gBAAgB,CAAC,IAAgB,EAAE,IAAY;IACtD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,OAAO,GAAsB,IAAI,CAAC;IACtC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;IAC5B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,UAAsB;IAC/C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAE9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,eAAe,EAAE,CAAC,EAAE,EAAE,CAAC;QACpD,MAAM,KAAK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CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC,EAAE,EAAE,CAAC;QAClD,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACrC,IAAI,KAAK;YAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,mDAAmD;IACnD,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC3F,YAAY,CAAC,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Java AST extractor for the parse-loop pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Implements the Java extraction configuration using the generic-extractor
|
|
5
|
+
* pattern — a thin {@link LanguageConfig} declaration that drives the shared
|
|
6
|
+
* {@link extractGeneric} walker. This is the demonstration language for the
|
|
7
|
+
* config-driven pattern port from Graphify v7 (`_JAVA_CONFIG` at
|
|
8
|
+
* `extract.py:717`, `_import_java` at `extract.py:422`).
|
|
9
|
+
*
|
|
10
|
+
* Extracts from a tree-sitter-java AST:
|
|
11
|
+
*
|
|
12
|
+
* - **Definitions**: classes, interfaces, enums, annotations, methods, and
|
|
13
|
+
* constructors.
|
|
14
|
+
* - **Imports**: `import foo.bar.Baz` and `import foo.bar.*` statements.
|
|
15
|
+
* - **Heritage**: `extends` and `implements` clauses.
|
|
16
|
+
* - **Calls**: method invocations and object creations.
|
|
17
|
+
*
|
|
18
|
+
* Grammar: `tree-sitter-java@0.23.5`
|
|
19
|
+
*
|
|
20
|
+
* tree-sitter-java grammar field facts (verified against live parse output):
|
|
21
|
+
* - `class_declaration`: fields `name`, `body` (→`class_body`), `superclass`
|
|
22
|
+
* (→`superclass` node, child `type_identifier`), `interfaces`
|
|
23
|
+
* (→`super_interfaces` node → `type_list` → `type_identifier` children).
|
|
24
|
+
* - `interface_declaration`: fields `name`, `body` (→`interface_body`).
|
|
25
|
+
* - `method_declaration`: fields `name`, `parameters` (→`formal_parameters`).
|
|
26
|
+
* - `constructor_declaration`: fields `name` (class name), `parameters`.
|
|
27
|
+
* - `import_declaration`: no named fields; first named child is `scoped_identifier`
|
|
28
|
+
* or `identifier` containing the full import path.
|
|
29
|
+
* - `method_invocation`: field `name` (→ callee identifier).
|
|
30
|
+
*
|
|
31
|
+
* @arch See graphify v7 `_JAVA_CONFIG` at `extract.py:717` and
|
|
32
|
+
* `_import_java` at `extract.py:422`.
|
|
33
|
+
*
|
|
34
|
+
* @task T1861
|
|
35
|
+
* @module pipeline/extractors/java-extractor
|
|
36
|
+
*/
|
|
37
|
+
import { extractGeneric } from './generic-extractor.js';
|
|
38
|
+
import type { LanguageConfig, SyntaxNode } from './language-config.js';
|
|
39
|
+
export type { GenericExtractionResult as JavaExtractionResult } from './language-config.js';
|
|
40
|
+
/**
|
|
41
|
+
* Declarative LanguageConfig for Java, parametrizing the generic extractor.
|
|
42
|
+
*
|
|
43
|
+
* Mirrors Graphify v7's `_JAVA_CONFIG` dataclass at `extract.py:717`.
|
|
44
|
+
*
|
|
45
|
+
* Key design decisions:
|
|
46
|
+
* - `constructor_declaration` is in `methodNodeTypes` so constructors are
|
|
47
|
+
* emitted as class members with kind `'constructor'` via the default
|
|
48
|
+
* `constructorNames` set (the generic walker checks the node type).
|
|
49
|
+
* - `super_interfaces` (Java's `implements` clause) contains a `type_list`
|
|
50
|
+
* child; the `inheritanceFieldPaths` config points to `interfaces` field
|
|
51
|
+
* on the class node. The generic walker resolves children of that node.
|
|
52
|
+
* - `superclass` field on class node contains a `superclass` wrapper node
|
|
53
|
+
* with `type_identifier` children.
|
|
54
|
+
*/
|
|
55
|
+
export declare const JAVA_CONFIG: LanguageConfig;
|
|
56
|
+
/**
|
|
57
|
+
* Extract all intelligence data from a Java AST.
|
|
58
|
+
*
|
|
59
|
+
* Delegates entirely to {@link extractGeneric} parametrized by
|
|
60
|
+
* {@link JAVA_CONFIG}. This thin wrapper matches the naming convention of the
|
|
61
|
+
* other language extractors (`extractTypeScript`, `extractPython`, etc.).
|
|
62
|
+
*
|
|
63
|
+
* @param rootNode - The root (`program` / `compilation_unit`) node of the
|
|
64
|
+
* parsed tree-sitter AST
|
|
65
|
+
* @param filePath - File path relative to the repository root
|
|
66
|
+
* @returns Full extraction result for the file
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const result = extractJava(rootNode, 'src/main/java/Main.java');
|
|
71
|
+
* console.log(result.definitions.length); // classes, methods, constructors
|
|
72
|
+
* console.log(result.imports.length); // import statements
|
|
73
|
+
* console.log(result.heritage.length); // extends / implements edges
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function extractJava(rootNode: SyntaxNode, filePath: string): ReturnType<typeof extractGeneric>;
|
|
77
|
+
//# sourceMappingURL=java-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java-extractor.d.ts","sourceRoot":"","sources":["../../../../src/pipeline/extractors/java-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAwB,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE7F,YAAY,EAAE,uBAAuB,IAAI,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAmH5F;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,EAAE,cA+HzB,CAAC;AAMF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,UAAU,EACpB,QAAQ,EAAE,MAAM,GACf,UAAU,CAAC,OAAO,cAAc,CAAC,CAEnC"}
|