@cleocode/nexus 2026.5.27 → 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,290 @@
|
|
|
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
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Export predicate
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
/**
|
|
42
|
+
* Return `true` if the Java AST node has a `public` visibility modifier.
|
|
43
|
+
*
|
|
44
|
+
* In tree-sitter-java, visibility appears as a `modifiers` named child whose
|
|
45
|
+
* text contains `"public"`.
|
|
46
|
+
*/
|
|
47
|
+
function isJavaPublic(node, _name) {
|
|
48
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
49
|
+
const child = node.namedChild(i);
|
|
50
|
+
if (!child)
|
|
51
|
+
continue;
|
|
52
|
+
if (child.type === 'modifiers') {
|
|
53
|
+
// Modifiers text is something like "public abstract" or "public static"
|
|
54
|
+
if (child.text.includes('public'))
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
// Import handler
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
/**
|
|
64
|
+
* Java import handler for `import_declaration` AST nodes.
|
|
65
|
+
*
|
|
66
|
+
* Handles:
|
|
67
|
+
* - `import foo.bar.Baz;` → rawImportPath=`"foo.bar"`, binding `{Baz, Baz}`
|
|
68
|
+
* - `import foo.bar.*;` → rawImportPath=`"foo.bar"`, wildcard binding
|
|
69
|
+
* - `import static foo.Bar.METHOD;` → rawImportPath=`"foo.Bar"`, binding `METHOD`
|
|
70
|
+
*
|
|
71
|
+
* In tree-sitter-java the `import_declaration` node's first named child is
|
|
72
|
+
* a `scoped_identifier` (e.g. `java.util.List`) or `identifier` (bare name).
|
|
73
|
+
* The asterisk import (`import java.util.*`) produces a `scoped_identifier`
|
|
74
|
+
* for `java.util` plus an `asterisk` unnamed child.
|
|
75
|
+
*
|
|
76
|
+
* Mirrors graphify's `_import_java` at `extract.py:422`.
|
|
77
|
+
*/
|
|
78
|
+
function javaImportHandler(ctx, results) {
|
|
79
|
+
const { node, filePath } = ctx;
|
|
80
|
+
// Detect wildcard: `import java.util.*`
|
|
81
|
+
// In tree-sitter-java, the asterisk is an `asterisk` named child node.
|
|
82
|
+
let isWildcard = false;
|
|
83
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
84
|
+
const child = node.namedChild(i);
|
|
85
|
+
if (child && (child.type === 'asterisk' || child.text === '*')) {
|
|
86
|
+
isWildcard = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Find the scoped_identifier or identifier child (skip asterisk)
|
|
90
|
+
let pathNode = null;
|
|
91
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
92
|
+
const child = node.namedChild(i);
|
|
93
|
+
if (!child)
|
|
94
|
+
continue;
|
|
95
|
+
if (child.type === 'scoped_identifier' || child.type === 'identifier') {
|
|
96
|
+
pathNode = child;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// For wildcard imports, the path is already the package path in pathNode
|
|
101
|
+
// (e.g. `java.util` from `import java.util.*`)
|
|
102
|
+
if (!pathNode) {
|
|
103
|
+
// Fallback: strip `import` and semicolon from raw text
|
|
104
|
+
const raw = node.text
|
|
105
|
+
.replace(/^import\s+(?:static\s+)?/, '')
|
|
106
|
+
.replace(/;$/, '')
|
|
107
|
+
.trim();
|
|
108
|
+
if (raw)
|
|
109
|
+
results.push({ filePath, rawImportPath: raw });
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const fullPath = pathNode.text; // e.g. "java.util.List"
|
|
113
|
+
if (isWildcard) {
|
|
114
|
+
// `import foo.bar.*` — import whole package
|
|
115
|
+
const namedBindings = [{ local: '*', exported: '*' }];
|
|
116
|
+
results.push({ filePath, rawImportPath: fullPath, namedBindings });
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// Split `java.util.List` → basePath=`java.util`, leaf=`List`
|
|
120
|
+
const lastDot = fullPath.lastIndexOf('.');
|
|
121
|
+
if (lastDot === -1) {
|
|
122
|
+
// Bare identifier — rare in Java (default package)
|
|
123
|
+
results.push({
|
|
124
|
+
filePath,
|
|
125
|
+
rawImportPath: fullPath,
|
|
126
|
+
namedBindings: [{ local: fullPath, exported: fullPath }],
|
|
127
|
+
});
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const basePath = fullPath.slice(0, lastDot); // `java.util`
|
|
131
|
+
const leaf = fullPath.slice(lastDot + 1); // `List`
|
|
132
|
+
results.push({
|
|
133
|
+
filePath,
|
|
134
|
+
rawImportPath: basePath,
|
|
135
|
+
namedBindings: [{ local: leaf, exported: leaf }],
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
// ---------------------------------------------------------------------------
|
|
139
|
+
// JAVA_CONFIG — declarative LanguageConfig for Java
|
|
140
|
+
// ---------------------------------------------------------------------------
|
|
141
|
+
/**
|
|
142
|
+
* Declarative LanguageConfig for Java, parametrizing the generic extractor.
|
|
143
|
+
*
|
|
144
|
+
* Mirrors Graphify v7's `_JAVA_CONFIG` dataclass at `extract.py:717`.
|
|
145
|
+
*
|
|
146
|
+
* Key design decisions:
|
|
147
|
+
* - `constructor_declaration` is in `methodNodeTypes` so constructors are
|
|
148
|
+
* emitted as class members with kind `'constructor'` via the default
|
|
149
|
+
* `constructorNames` set (the generic walker checks the node type).
|
|
150
|
+
* - `super_interfaces` (Java's `implements` clause) contains a `type_list`
|
|
151
|
+
* child; the `inheritanceFieldPaths` config points to `interfaces` field
|
|
152
|
+
* on the class node. The generic walker resolves children of that node.
|
|
153
|
+
* - `superclass` field on class node contains a `superclass` wrapper node
|
|
154
|
+
* with `type_identifier` children.
|
|
155
|
+
*/
|
|
156
|
+
export const JAVA_CONFIG = {
|
|
157
|
+
language: 'java',
|
|
158
|
+
// -------------------------------------------------------------------------
|
|
159
|
+
// Definition node types
|
|
160
|
+
// -------------------------------------------------------------------------
|
|
161
|
+
/**
|
|
162
|
+
* Node types for standalone function-like definitions.
|
|
163
|
+
* Java does not have standalone functions — all functions are methods or
|
|
164
|
+
* constructors. We omit `constructor_declaration` here so it is only
|
|
165
|
+
* processed inside class bodies via `methodNodeTypes`.
|
|
166
|
+
*/
|
|
167
|
+
functionNodeTypes: new Set([
|
|
168
|
+
// Java has no standalone functions outside classes; keep empty to avoid
|
|
169
|
+
// top-level constructor_declaration processing that duplicates the class body pass
|
|
170
|
+
]),
|
|
171
|
+
/**
|
|
172
|
+
* Node types for class-like declarations at the top level.
|
|
173
|
+
*/
|
|
174
|
+
classNodeTypes: new Set([
|
|
175
|
+
'class_declaration',
|
|
176
|
+
'interface_declaration',
|
|
177
|
+
'enum_declaration',
|
|
178
|
+
'annotation_type_declaration',
|
|
179
|
+
'record_declaration',
|
|
180
|
+
]),
|
|
181
|
+
/**
|
|
182
|
+
* Method-like node types found inside a class body.
|
|
183
|
+
* `constructor_declaration` is included so constructors are emitted.
|
|
184
|
+
*/
|
|
185
|
+
methodNodeTypes: new Set(['method_declaration', 'constructor_declaration']),
|
|
186
|
+
// -------------------------------------------------------------------------
|
|
187
|
+
// Field paths (verified against tree-sitter-java@0.23.5 parse output)
|
|
188
|
+
// -------------------------------------------------------------------------
|
|
189
|
+
nameFieldPath: 'name',
|
|
190
|
+
bodyFieldPath: 'body',
|
|
191
|
+
parametersFieldPath: 'parameters',
|
|
192
|
+
// -------------------------------------------------------------------------
|
|
193
|
+
// Inheritance / heritage
|
|
194
|
+
// -------------------------------------------------------------------------
|
|
195
|
+
/**
|
|
196
|
+
* Inheritance field paths for Java class declarations.
|
|
197
|
+
*
|
|
198
|
+
* - `superclass` field → `superclass` node → direct `type_identifier` child
|
|
199
|
+
* - `interfaces` field → `super_interfaces` node → `type_list` → `type_identifier`
|
|
200
|
+
*
|
|
201
|
+
* The generic walker calls `childForFieldName(fieldName)` on the class node,
|
|
202
|
+
* then walks the result's named children looking for `inheritanceNameNodeTypes`.
|
|
203
|
+
*/
|
|
204
|
+
inheritanceFieldPaths: [
|
|
205
|
+
{ fieldName: 'superclass', kind: 'extends' },
|
|
206
|
+
{ fieldName: 'interfaces', kind: 'implements' },
|
|
207
|
+
],
|
|
208
|
+
/**
|
|
209
|
+
* Node types within an inheritance specifier that hold the parent type name.
|
|
210
|
+
* In tree-sitter-java: `type_identifier` for simple names, `generic_type`
|
|
211
|
+
* for parameterized types like `Comparable<String>`.
|
|
212
|
+
*
|
|
213
|
+
* NOTE: `super_interfaces` contains a `type_list` which in turn contains
|
|
214
|
+
* `type_identifier` children. The generic walker needs to descend through
|
|
215
|
+
* `type_list`. We handle this via the `extraWalkFn` for inheritance resolution,
|
|
216
|
+
* OR we extend `inheritanceNameNodeTypes` to include `type_list` and handle
|
|
217
|
+
* the two-level descent. The simplest fix: add `type_list` to the set and
|
|
218
|
+
* handle it specially in the heritage walk.
|
|
219
|
+
*/
|
|
220
|
+
inheritanceNameNodeTypes: new Set(['type_identifier', 'generic_type']),
|
|
221
|
+
// -------------------------------------------------------------------------
|
|
222
|
+
// Call extraction
|
|
223
|
+
// -------------------------------------------------------------------------
|
|
224
|
+
callNodeTypes: new Set(['method_invocation', 'object_creation_expression']),
|
|
225
|
+
/**
|
|
226
|
+
* For `method_invocation`, the callee name is in the `name` field
|
|
227
|
+
* (verified: `method_invocation.childForFieldName('name')` → `identifier`).
|
|
228
|
+
* For `object_creation_expression`, we use `type` field (handled via extraWalkFn).
|
|
229
|
+
*/
|
|
230
|
+
callFunctionPath: 'name',
|
|
231
|
+
// -------------------------------------------------------------------------
|
|
232
|
+
// Import extraction
|
|
233
|
+
// -------------------------------------------------------------------------
|
|
234
|
+
importNodeTypes: new Set(['import_declaration']),
|
|
235
|
+
importHandler: javaImportHandler,
|
|
236
|
+
// -------------------------------------------------------------------------
|
|
237
|
+
// Export predicate
|
|
238
|
+
// -------------------------------------------------------------------------
|
|
239
|
+
isExported: isJavaPublic,
|
|
240
|
+
// -------------------------------------------------------------------------
|
|
241
|
+
// Kind overrides
|
|
242
|
+
// -------------------------------------------------------------------------
|
|
243
|
+
kindOverrides: new Map([
|
|
244
|
+
['interface_declaration', 'interface'],
|
|
245
|
+
['enum_declaration', 'enum'],
|
|
246
|
+
['annotation_type_declaration', 'interface'],
|
|
247
|
+
['record_declaration', 'class'],
|
|
248
|
+
]),
|
|
249
|
+
/**
|
|
250
|
+
* Constructor node types: `constructor_declaration` nodes are always emitted
|
|
251
|
+
* with kind `'constructor'` regardless of the method name.
|
|
252
|
+
*
|
|
253
|
+
* In tree-sitter-java, `constructor_declaration` uses the class name as the
|
|
254
|
+
* `name` field (e.g. `Shape` for `public Shape(...)`), not `<init>`.
|
|
255
|
+
* Using `constructorNodeTypes` bypasses the name-based check and detects
|
|
256
|
+
* constructors by AST node type.
|
|
257
|
+
*/
|
|
258
|
+
constructorNodeTypes: new Set(['constructor_declaration']),
|
|
259
|
+
/**
|
|
260
|
+
* Leave `constructorNames` as the default set — unused for Java since
|
|
261
|
+
* `constructorNodeTypes` handles constructor detection by node type.
|
|
262
|
+
*/
|
|
263
|
+
};
|
|
264
|
+
// ---------------------------------------------------------------------------
|
|
265
|
+
// Public extraction entry point
|
|
266
|
+
// ---------------------------------------------------------------------------
|
|
267
|
+
/**
|
|
268
|
+
* Extract all intelligence data from a Java AST.
|
|
269
|
+
*
|
|
270
|
+
* Delegates entirely to {@link extractGeneric} parametrized by
|
|
271
|
+
* {@link JAVA_CONFIG}. This thin wrapper matches the naming convention of the
|
|
272
|
+
* other language extractors (`extractTypeScript`, `extractPython`, etc.).
|
|
273
|
+
*
|
|
274
|
+
* @param rootNode - The root (`program` / `compilation_unit`) node of the
|
|
275
|
+
* parsed tree-sitter AST
|
|
276
|
+
* @param filePath - File path relative to the repository root
|
|
277
|
+
* @returns Full extraction result for the file
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```ts
|
|
281
|
+
* const result = extractJava(rootNode, 'src/main/java/Main.java');
|
|
282
|
+
* console.log(result.definitions.length); // classes, methods, constructors
|
|
283
|
+
* console.log(result.imports.length); // import statements
|
|
284
|
+
* console.log(result.heritage.length); // extends / implements edges
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
export function extractJava(rootNode, filePath) {
|
|
288
|
+
return extractGeneric(rootNode, null, `${filePath}::__file__`, JAVA_CONFIG);
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=java-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java-extractor.js","sourceRoot":"","sources":["../../../../src/pipeline/extractors/java-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAKxD,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;GAKG;AACH,SAAS,YAAY,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ACH,wBAAwB,EAAE,IAAI,GAAG,CAAC,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;IAEtE,4EAA4E;IAC5E,kBAAkB;IAClB,4EAA4E;IAE5E,aAAa,EAAE,IAAI,GAAG,CAAC,CAAC,mBAAmB,EAAE,4BAA4B,CAAC,CAAC;IAE3E;;;;OAIG;IACH,gBAAgB,EAAE,MAAM;IAExB,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E,eAAe,EAAE,IAAI,GAAG,CAAC,CAAC,oBAAoB,CAAC,CAAC;IAChD,aAAa,EAAE,iBAAiB;IAEhC,4EAA4E;IAC5E,mBAAmB;IACnB,4EAA4E;IAE5E,UAAU,EAAE,YAAY;IAExB,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E,aAAa,EAAE,IAAI,GAAG,CAAwB;QAC5C,CAAC,uBAAuB,EAAE,WAAW,CAAC;QACtC,CAAC,kBAAkB,EAAE,MAAM,CAAC;QAC5B,CAAC,6BAA6B,EAAE,WAAW,CAAC;QAC5C,CAAC,oBAAoB,EAAE,OAAO,CAAC;KAChC,CAAC;IAEF;;;;;;;;OAQG;IACH,oBAAoB,EAAE,IAAI,GAAG,CAAC,CAAC,yBAAyB,CAAC,CAAC;IAE1D;;;OAGG;CACJ,CAAC;AAEF,8EAA8E;AAC9E,gCAAgC;AAChC,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,WAAW,CACzB,QAAoB,EACpB,QAAgB;IAEhB,OAAO,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,QAAQ,YAAY,EAAE,WAAW,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LanguageConfig — declarative per-language AST extraction configuration.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the `LanguageConfig` dataclass pattern from Graphify v7
|
|
5
|
+
* (`graphify/extract.py:147–192`, branch `v7`, HEAD `ee85bbfb`). Each language
|
|
6
|
+
* is described by a small declarative record of tree-sitter node type sets and
|
|
7
|
+
* optional callbacks, which is then driven by the single
|
|
8
|
+
* {@link ./generic-extractor.ts | generic-extractor} walker.
|
|
9
|
+
*
|
|
10
|
+
* In Graphify, 13 of 26 languages share one 794-line `_extract_generic` walker
|
|
11
|
+
* parametrized by this structure. This port adopts the same model:
|
|
12
|
+
* one walker per language category (mainstream OO / C-family / scripting),
|
|
13
|
+
* reducing per-language code to a 20–40 line config declaration.
|
|
14
|
+
*
|
|
15
|
+
* @arch See graphify v7 inspiration: https://github.com/safishamsi/graphify
|
|
16
|
+
* branch v7, `extract.py` lines 147–192 and `_JAVA_CONFIG` at line 717.
|
|
17
|
+
*
|
|
18
|
+
* @module pipeline/extractors/language-config
|
|
19
|
+
*/
|
|
20
|
+
import type { GraphNode, GraphNodeKind } from '@cleocode/contracts';
|
|
21
|
+
import type { ExtractedImport } from '../import-processor.js';
|
|
22
|
+
import type { ExtractedCall, ExtractedHeritage } from './typescript-extractor.js';
|
|
23
|
+
/**
|
|
24
|
+
* Minimal tree-sitter SyntaxNode shape required by all extractors.
|
|
25
|
+
* Avoids a hard dependency on any particular tree-sitter type package.
|
|
26
|
+
*/
|
|
27
|
+
export interface SyntaxNode {
|
|
28
|
+
type: string;
|
|
29
|
+
text: string;
|
|
30
|
+
startPosition: {
|
|
31
|
+
row: number;
|
|
32
|
+
column: number;
|
|
33
|
+
};
|
|
34
|
+
endPosition: {
|
|
35
|
+
row: number;
|
|
36
|
+
column: number;
|
|
37
|
+
};
|
|
38
|
+
children: SyntaxNode[];
|
|
39
|
+
namedChildren: SyntaxNode[];
|
|
40
|
+
namedChildCount: number;
|
|
41
|
+
isNamed: boolean;
|
|
42
|
+
parent: SyntaxNode | null;
|
|
43
|
+
previousSibling: SyntaxNode | null;
|
|
44
|
+
childForFieldName(fieldName: string): SyntaxNode | null;
|
|
45
|
+
namedChild(index: number): SyntaxNode | null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Full extraction result for one source file.
|
|
49
|
+
*
|
|
50
|
+
* Matches the shape returned by the language-specific extractors
|
|
51
|
+
* ({@link TypeScriptExtractionResult}, {@link PythonExtractionResult}, etc.)
|
|
52
|
+
* minus the TS-only `reExports` field, which is not part of the generic path.
|
|
53
|
+
*
|
|
54
|
+
* @see {@link ./generic-extractor.ts | extractGeneric}
|
|
55
|
+
*/
|
|
56
|
+
export interface GenericExtractionResult {
|
|
57
|
+
/** Symbol definition nodes extracted from the file. */
|
|
58
|
+
definitions: GraphNode[];
|
|
59
|
+
/** Raw import records for the import-processor fast-path. */
|
|
60
|
+
imports: ExtractedImport[];
|
|
61
|
+
/** Heritage clauses (extends / implements) for heritage edge emission. */
|
|
62
|
+
heritage: ExtractedHeritage[];
|
|
63
|
+
/** Call expressions for CALLS edge emission. */
|
|
64
|
+
calls: ExtractedCall[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Context bag passed to {@link LanguageConfig.importHandler} when the generic
|
|
68
|
+
* walker encounters an import-bearing node.
|
|
69
|
+
*
|
|
70
|
+
* Mirrors graphify's pattern of passing the raw node plus accumulated context
|
|
71
|
+
* to allow language-specific resolution (e.g. tsconfig alias expansion for JS,
|
|
72
|
+
* package prefix for Java).
|
|
73
|
+
*/
|
|
74
|
+
export interface ImportHandlerContext {
|
|
75
|
+
/** The AST node that triggered the import handler (e.g. `import_declaration`). */
|
|
76
|
+
node: SyntaxNode;
|
|
77
|
+
/** File path relative to repo root. */
|
|
78
|
+
filePath: string;
|
|
79
|
+
/** Raw import path string before any resolution. */
|
|
80
|
+
rawPath: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Context bag passed to {@link LanguageConfig.extraWalkFn} for each AST node
|
|
84
|
+
* visited during the generic walker's post-pass.
|
|
85
|
+
*
|
|
86
|
+
* The callback may push additional {@link GraphNode}, {@link ExtractedImport},
|
|
87
|
+
* {@link ExtractedHeritage}, or {@link ExtractedCall} records into the
|
|
88
|
+
* corresponding result arrays.
|
|
89
|
+
*
|
|
90
|
+
* Mirrors graphify's `extra_walk_fn` escape hatch used for JS arrow functions,
|
|
91
|
+
* C# namespace traversal, and Swift enum cases (`extract.py:191`).
|
|
92
|
+
*/
|
|
93
|
+
export interface ExtraWalkContext {
|
|
94
|
+
/** The current AST node being visited. */
|
|
95
|
+
node: SyntaxNode;
|
|
96
|
+
/** File path relative to repo root. */
|
|
97
|
+
filePath: string;
|
|
98
|
+
/** Language string (e.g. `'java'`). */
|
|
99
|
+
language: string;
|
|
100
|
+
/** Mutable accumulator for additional definition nodes. */
|
|
101
|
+
definitions: GraphNode[];
|
|
102
|
+
/** Mutable accumulator for additional import records. */
|
|
103
|
+
imports: ExtractedImport[];
|
|
104
|
+
/** Mutable accumulator for additional heritage records. */
|
|
105
|
+
heritage: ExtractedHeritage[];
|
|
106
|
+
/** Mutable accumulator for additional call records. */
|
|
107
|
+
calls: ExtractedCall[];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Declarative configuration that parametrizes the generic AST walker for one
|
|
111
|
+
* source language.
|
|
112
|
+
*
|
|
113
|
+
* Fields mirror Graphify v7's `LanguageConfig` dataclass
|
|
114
|
+
* (`extract.py:147–192`) with TypeScript idioms:
|
|
115
|
+
* - Python `frozenset` → `ReadonlySet<string>`
|
|
116
|
+
* - Python `Callable | None` → optional function type
|
|
117
|
+
* - Python `str` field paths → string literals (used by `childForFieldName`)
|
|
118
|
+
*
|
|
119
|
+
* Not every field is required — optional fields default to safe no-ops in the
|
|
120
|
+
* generic walker.
|
|
121
|
+
*
|
|
122
|
+
* @example Minimal config for a hypothetical language:
|
|
123
|
+
* ```ts
|
|
124
|
+
* const MY_LANG_CONFIG: LanguageConfig = {
|
|
125
|
+
* language: 'mylang',
|
|
126
|
+
* functionNodeTypes: new Set(['function_definition']),
|
|
127
|
+
* classNodeTypes: new Set(['class_definition']),
|
|
128
|
+
* methodNodeTypes: new Set(['method_definition']),
|
|
129
|
+
* nameFieldPath: 'name',
|
|
130
|
+
* bodyFieldPath: 'body',
|
|
131
|
+
* parametersFieldPath: 'parameters',
|
|
132
|
+
* };
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @arch See graphify v7 inspiration — `LanguageConfig` dataclass at
|
|
136
|
+
* `extract.py:147–192` and `_JAVA_CONFIG` at `extract.py:717`.
|
|
137
|
+
*/
|
|
138
|
+
export interface LanguageConfig {
|
|
139
|
+
/**
|
|
140
|
+
* Language string stored on every emitted {@link GraphNode}.
|
|
141
|
+
* Examples: `'java'`, `'kotlin'`, `'c_sharp'`.
|
|
142
|
+
*/
|
|
143
|
+
language: string;
|
|
144
|
+
/**
|
|
145
|
+
* AST node types that represent top-level or nested function definitions.
|
|
146
|
+
*
|
|
147
|
+
* graphify equivalent: `function_types`
|
|
148
|
+
* @example `new Set(['method_declaration', 'constructor_declaration'])` for Java
|
|
149
|
+
*/
|
|
150
|
+
functionNodeTypes: ReadonlySet<string>;
|
|
151
|
+
/**
|
|
152
|
+
* AST node types that represent class or class-like declarations.
|
|
153
|
+
*
|
|
154
|
+
* graphify equivalent: `class_types`
|
|
155
|
+
* @example `new Set(['class_declaration', 'interface_declaration', 'enum_declaration'])` for Java
|
|
156
|
+
*/
|
|
157
|
+
classNodeTypes: ReadonlySet<string>;
|
|
158
|
+
/**
|
|
159
|
+
* AST node types that represent methods defined inside a class body.
|
|
160
|
+
* Often overlaps with {@link functionNodeTypes} in languages like Java.
|
|
161
|
+
*
|
|
162
|
+
* graphify equivalent: `method_node_types`
|
|
163
|
+
* @example `new Set(['method_declaration'])` for Java
|
|
164
|
+
*/
|
|
165
|
+
methodNodeTypes: ReadonlySet<string>;
|
|
166
|
+
/**
|
|
167
|
+
* Tree-sitter field name used to extract the symbol's identifier node.
|
|
168
|
+
* Passed directly to `node.childForFieldName(nameFieldPath)`.
|
|
169
|
+
*
|
|
170
|
+
* graphify equivalent: `name_field`
|
|
171
|
+
* @example `'name'` for most languages
|
|
172
|
+
*/
|
|
173
|
+
nameFieldPath: string;
|
|
174
|
+
/**
|
|
175
|
+
* Tree-sitter field name used to locate the class/function body.
|
|
176
|
+
* Passed to `node.childForFieldName(bodyFieldPath)`.
|
|
177
|
+
*
|
|
178
|
+
* graphify equivalent: `body_field`
|
|
179
|
+
* @example `'body'` for most languages
|
|
180
|
+
*/
|
|
181
|
+
bodyFieldPath: string;
|
|
182
|
+
/**
|
|
183
|
+
* Tree-sitter field name used to locate the parameter list.
|
|
184
|
+
* Passed to `node.childForFieldName(parametersFieldPath)`.
|
|
185
|
+
*
|
|
186
|
+
* graphify equivalent: implicit in `function_types` handling
|
|
187
|
+
* @example `'parameters'` for Java, Python; `'formal_parameters'` for some grammars
|
|
188
|
+
*/
|
|
189
|
+
parametersFieldPath: string;
|
|
190
|
+
/**
|
|
191
|
+
* Tree-sitter field name(s) on the class node that hold the superclass /
|
|
192
|
+
* interface list. Used to emit {@link ExtractedHeritage} records.
|
|
193
|
+
*
|
|
194
|
+
* In Java: `'superclass'` → `extends Foo`; `'interfaces'` → `implements Bar, Baz`.
|
|
195
|
+
* Set to an empty array if the language has no nominal inheritance (e.g. Go).
|
|
196
|
+
*
|
|
197
|
+
* graphify equivalent: `inheritance_specifier_search`
|
|
198
|
+
*/
|
|
199
|
+
inheritanceFieldPaths: ReadonlyArray<{
|
|
200
|
+
/** Tree-sitter field name on the class node. */
|
|
201
|
+
fieldName: string;
|
|
202
|
+
/** Heritage kind to emit for nodes found under this field. */
|
|
203
|
+
kind: 'extends' | 'implements';
|
|
204
|
+
}>;
|
|
205
|
+
/**
|
|
206
|
+
* AST node types within an inheritance specifier list that hold the actual
|
|
207
|
+
* parent type name. Used alongside {@link inheritanceFieldPaths}.
|
|
208
|
+
*
|
|
209
|
+
* graphify equivalent: `field_specifier_search`
|
|
210
|
+
* @example `new Set(['type_identifier'])` for Java
|
|
211
|
+
*/
|
|
212
|
+
inheritanceNameNodeTypes: ReadonlySet<string>;
|
|
213
|
+
/**
|
|
214
|
+
* AST node types that represent a call expression.
|
|
215
|
+
*
|
|
216
|
+
* graphify equivalent: `call_node_types`
|
|
217
|
+
* @example `new Set(['method_invocation', 'object_creation_expression'])` for Java
|
|
218
|
+
*/
|
|
219
|
+
callNodeTypes: ReadonlySet<string>;
|
|
220
|
+
/**
|
|
221
|
+
* Tree-sitter field path on a call node to reach the callee identifier.
|
|
222
|
+
* May be a dot-path like `'name'` or `'function.name'` (resolved by the
|
|
223
|
+
* generic walker as a sequence of `childForFieldName` calls).
|
|
224
|
+
*
|
|
225
|
+
* graphify equivalent: `call_function_path`
|
|
226
|
+
* @example `'name'` for Java `method_invocation`
|
|
227
|
+
*/
|
|
228
|
+
callFunctionPath: string;
|
|
229
|
+
/**
|
|
230
|
+
* AST node types that represent import/use/include statements at the top of
|
|
231
|
+
* a file.
|
|
232
|
+
*
|
|
233
|
+
* graphify equivalent: `import_types`
|
|
234
|
+
* @example `new Set(['import_declaration'])` for Java
|
|
235
|
+
*/
|
|
236
|
+
importNodeTypes: ReadonlySet<string>;
|
|
237
|
+
/**
|
|
238
|
+
* Optional language-specific import handler callback.
|
|
239
|
+
*
|
|
240
|
+
* When present, invoked for each node whose type is in {@link importNodeTypes}.
|
|
241
|
+
* The callback MUST push zero or more {@link ExtractedImport} records into the
|
|
242
|
+
* provided results array. If absent, the generic walker applies a default
|
|
243
|
+
* text-extraction strategy.
|
|
244
|
+
*
|
|
245
|
+
* Mirrors graphify's `import_handler: Callable | None` pattern
|
|
246
|
+
* (`extract.py:189`) — the escape hatch for complex import semantics (tsconfig
|
|
247
|
+
* aliases, namespace prefixes, Java package paths).
|
|
248
|
+
*
|
|
249
|
+
* @param ctx - Import handler context
|
|
250
|
+
* @param results - Mutable results array; push records here
|
|
251
|
+
*/
|
|
252
|
+
importHandler?: (ctx: ImportHandlerContext, results: ExtractedImport[]) => void;
|
|
253
|
+
/**
|
|
254
|
+
* AST node types that represent "uses" or "references" to a symbol (e.g.
|
|
255
|
+
* `identifier` in an expression context). Used for potential future ACCESSES
|
|
256
|
+
* edge extraction. Optional; set to empty if not needed.
|
|
257
|
+
*
|
|
258
|
+
* graphify equivalent: `use_node_types`
|
|
259
|
+
*/
|
|
260
|
+
useNodeTypes?: ReadonlySet<string>;
|
|
261
|
+
/**
|
|
262
|
+
* AST node types that represent explicit references (e.g. a type annotation
|
|
263
|
+
* or qualified name reference). Optional.
|
|
264
|
+
*
|
|
265
|
+
* graphify equivalent: `reference_node_types`
|
|
266
|
+
*/
|
|
267
|
+
referenceNodeTypes?: ReadonlySet<string>;
|
|
268
|
+
/**
|
|
269
|
+
* Optional post-pass callback invoked for every AST node after the primary
|
|
270
|
+
* walker has finished.
|
|
271
|
+
*
|
|
272
|
+
* Used for language quirks that don't fit the generic model:
|
|
273
|
+
* - JS: arrow-function constants (`const foo = () => {}`)
|
|
274
|
+
* - C#: namespace traversal
|
|
275
|
+
* - Swift: enum `case_of` edges and extension declarations
|
|
276
|
+
*
|
|
277
|
+
* Mirrors graphify's `extra_walk_fn` field (`extract.py:191`).
|
|
278
|
+
*
|
|
279
|
+
* @param ctx - Extra walk context with mutable result arrays
|
|
280
|
+
*/
|
|
281
|
+
extraWalkFn?: (ctx: ExtraWalkContext) => void;
|
|
282
|
+
/**
|
|
283
|
+
* Optional predicate to determine whether a given node or name should be
|
|
284
|
+
* marked `exported: true` on the emitted {@link GraphNode}.
|
|
285
|
+
*
|
|
286
|
+
* If absent, the generic walker defaults to `true` for all top-level symbols
|
|
287
|
+
* (consistent with Python's convention that all public names are exported).
|
|
288
|
+
*
|
|
289
|
+
* @param node - The AST node representing the symbol declaration
|
|
290
|
+
* @param name - The symbol's extracted name
|
|
291
|
+
* @returns `true` if the symbol should be considered exported
|
|
292
|
+
*/
|
|
293
|
+
isExported?: (node: SyntaxNode, name: string) => boolean;
|
|
294
|
+
/**
|
|
295
|
+
* Optional map from a class-level AST node type to the {@link GraphNodeKind}
|
|
296
|
+
* that should be emitted for that node.
|
|
297
|
+
*
|
|
298
|
+
* When absent, the generic walker defaults to:
|
|
299
|
+
* - nodes in {@link classNodeTypes} → `'class'`
|
|
300
|
+
* - nodes in {@link methodNodeTypes} → `'method'` (or `'constructor'` for `<init>`)
|
|
301
|
+
* - nodes in {@link functionNodeTypes} → `'function'`
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```ts
|
|
305
|
+
* kindOverrides: new Map([
|
|
306
|
+
* ['interface_declaration', 'interface'],
|
|
307
|
+
* ['enum_declaration', 'enum'],
|
|
308
|
+
* ])
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
kindOverrides?: ReadonlyMap<string, GraphNodeKind>;
|
|
312
|
+
/**
|
|
313
|
+
* Optional set of method names that should be emitted with kind `'constructor'`
|
|
314
|
+
* instead of `'method'`.
|
|
315
|
+
*
|
|
316
|
+
* Defaults to `new Set(['<init>', 'constructor'])` if absent.
|
|
317
|
+
*
|
|
318
|
+
* @example `new Set(['<init>'])` for Java
|
|
319
|
+
*/
|
|
320
|
+
constructorNames?: ReadonlySet<string>;
|
|
321
|
+
/**
|
|
322
|
+
* Optional set of AST node types that always emit as kind `'constructor'`,
|
|
323
|
+
* regardless of the method name.
|
|
324
|
+
*
|
|
325
|
+
* Useful for languages like Java where constructor nodes have a distinct
|
|
326
|
+
* tree-sitter node type (`constructor_declaration`) but use the class name
|
|
327
|
+
* as the method name (not `<init>` or `constructor`).
|
|
328
|
+
*
|
|
329
|
+
* @example `new Set(['constructor_declaration'])` for Java
|
|
330
|
+
*/
|
|
331
|
+
constructorNodeTypes?: ReadonlySet<string>;
|
|
332
|
+
}
|
|
333
|
+
//# sourceMappingURL=language-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-config.d.ts","sourceRoot":"","sources":["../../../../src/pipeline/extractors/language-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,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IAMzB;;;;;;OAMG;IACH,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAErC;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IAMhF;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAEnC;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAMzC;;;;;;;;;;;;OAYG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAM9C;;;;;;;;;;OAUG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAMzD;;;;;;;;;;;;;;;;OAgBG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAEnD;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAEvC;;;;;;;;;OASG;IACH,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC5C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LanguageConfig — declarative per-language AST extraction configuration.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the `LanguageConfig` dataclass pattern from Graphify v7
|
|
5
|
+
* (`graphify/extract.py:147–192`, branch `v7`, HEAD `ee85bbfb`). Each language
|
|
6
|
+
* is described by a small declarative record of tree-sitter node type sets and
|
|
7
|
+
* optional callbacks, which is then driven by the single
|
|
8
|
+
* {@link ./generic-extractor.ts | generic-extractor} walker.
|
|
9
|
+
*
|
|
10
|
+
* In Graphify, 13 of 26 languages share one 794-line `_extract_generic` walker
|
|
11
|
+
* parametrized by this structure. This port adopts the same model:
|
|
12
|
+
* one walker per language category (mainstream OO / C-family / scripting),
|
|
13
|
+
* reducing per-language code to a 20–40 line config declaration.
|
|
14
|
+
*
|
|
15
|
+
* @arch See graphify v7 inspiration: https://github.com/safishamsi/graphify
|
|
16
|
+
* branch v7, `extract.py` lines 147–192 and `_JAVA_CONFIG` at line 717.
|
|
17
|
+
*
|
|
18
|
+
* @module pipeline/extractors/language-config
|
|
19
|
+
*/
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=language-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-config.js","sourceRoot":"","sources":["../../../../src/pipeline/extractors/language-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG"}
|