gitnexus 1.5.3 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/_shared/graph/types.d.ts +1 -1
- package/dist/_shared/graph/types.d.ts.map +1 -1
- package/dist/_shared/index.d.ts +1 -0
- package/dist/_shared/index.d.ts.map +1 -1
- package/dist/_shared/language-detection.d.ts.map +1 -1
- package/dist/_shared/language-detection.js +2 -0
- package/dist/_shared/language-detection.js.map +1 -1
- package/dist/_shared/languages.d.ts +1 -0
- package/dist/_shared/languages.d.ts.map +1 -1
- package/dist/_shared/languages.js +1 -0
- package/dist/_shared/languages.js.map +1 -1
- package/dist/_shared/lbug/schema-constants.d.ts +1 -1
- package/dist/_shared/lbug/schema-constants.d.ts.map +1 -1
- package/dist/_shared/lbug/schema-constants.js +3 -1
- package/dist/_shared/lbug/schema-constants.js.map +1 -1
- package/dist/_shared/mro-strategy.d.ts +19 -0
- package/dist/_shared/mro-strategy.d.ts.map +1 -0
- package/dist/_shared/mro-strategy.js +2 -0
- package/dist/_shared/mro-strategy.js.map +1 -0
- package/dist/cli/ai-context.d.ts +1 -0
- package/dist/cli/ai-context.js +28 -4
- package/dist/cli/analyze.d.ts +2 -0
- package/dist/cli/analyze.js +2 -1
- package/dist/cli/group.d.ts +2 -0
- package/dist/cli/group.js +233 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli/serve.js +4 -1
- package/dist/cli/setup.js +34 -3
- package/dist/config/ignore-service.js +8 -3
- package/dist/core/augmentation/engine.js +1 -1
- package/dist/core/git-staleness.d.ts +13 -0
- package/dist/core/git-staleness.js +29 -0
- package/dist/core/group/bridge-db.d.ts +82 -0
- package/dist/core/group/bridge-db.js +460 -0
- package/dist/core/group/bridge-schema.d.ts +27 -0
- package/dist/core/group/bridge-schema.js +55 -0
- package/dist/core/group/config-parser.d.ts +3 -0
- package/dist/core/group/config-parser.js +83 -0
- package/dist/core/group/contract-extractor.d.ts +7 -0
- package/dist/core/group/contract-extractor.js +1 -0
- package/dist/core/group/extractors/grpc-extractor.d.ts +16 -0
- package/dist/core/group/extractors/grpc-extractor.js +264 -0
- package/dist/core/group/extractors/http-route-extractor.d.ts +24 -0
- package/dist/core/group/extractors/http-route-extractor.js +428 -0
- package/dist/core/group/extractors/topic-extractor.d.ts +9 -0
- package/dist/core/group/extractors/topic-extractor.js +234 -0
- package/dist/core/group/matching.d.ts +13 -0
- package/dist/core/group/matching.js +198 -0
- package/dist/core/group/normalization.d.ts +3 -0
- package/dist/core/group/normalization.js +115 -0
- package/dist/core/group/service-boundary-detector.d.ts +8 -0
- package/dist/core/group/service-boundary-detector.js +155 -0
- package/dist/core/group/service.d.ts +46 -0
- package/dist/core/group/service.js +160 -0
- package/dist/core/group/storage.d.ts +9 -0
- package/dist/core/group/storage.js +91 -0
- package/dist/core/group/sync.d.ts +21 -0
- package/dist/core/group/sync.js +148 -0
- package/dist/core/group/types.d.ts +130 -0
- package/dist/core/group/types.js +1 -0
- package/dist/core/ingestion/binding-accumulator.d.ts +207 -0
- package/dist/core/ingestion/binding-accumulator.js +332 -0
- package/dist/core/ingestion/call-processor.d.ts +155 -24
- package/dist/core/ingestion/call-processor.js +1129 -247
- package/dist/core/ingestion/class-extractors/generic.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/generic.js +135 -0
- package/dist/core/ingestion/class-types.d.ts +34 -0
- package/dist/core/ingestion/class-types.js +1 -0
- package/dist/core/ingestion/entry-point-scoring.d.ts +1 -0
- package/dist/core/ingestion/entry-point-scoring.js +1 -0
- package/dist/core/ingestion/field-types.d.ts +2 -2
- package/dist/core/ingestion/filesystem-walker.js +8 -0
- package/dist/core/ingestion/framework-detection.d.ts +1 -0
- package/dist/core/ingestion/framework-detection.js +1 -0
- package/dist/core/ingestion/heritage-processor.d.ts +8 -15
- package/dist/core/ingestion/heritage-processor.js +15 -28
- package/dist/core/ingestion/import-processor.d.ts +1 -11
- package/dist/core/ingestion/import-processor.js +0 -12
- package/dist/core/ingestion/import-resolvers/utils.js +1 -0
- package/dist/core/ingestion/import-resolvers/vue.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/vue.js +9 -0
- package/dist/core/ingestion/language-provider.d.ts +6 -3
- package/dist/core/ingestion/languages/c-cpp.js +168 -1
- package/dist/core/ingestion/languages/csharp.js +20 -0
- package/dist/core/ingestion/languages/dart.js +26 -4
- package/dist/core/ingestion/languages/go.js +22 -0
- package/dist/core/ingestion/languages/index.d.ts +1 -0
- package/dist/core/ingestion/languages/index.js +2 -0
- package/dist/core/ingestion/languages/java.js +17 -0
- package/dist/core/ingestion/languages/kotlin.js +24 -1
- package/dist/core/ingestion/languages/php.js +23 -11
- package/dist/core/ingestion/languages/python.js +9 -0
- package/dist/core/ingestion/languages/ruby.js +28 -0
- package/dist/core/ingestion/languages/rust.js +38 -0
- package/dist/core/ingestion/languages/swift.js +31 -0
- package/dist/core/ingestion/languages/typescript.d.ts +1 -0
- package/dist/core/ingestion/languages/typescript.js +52 -3
- package/dist/core/ingestion/languages/vue.d.ts +13 -0
- package/dist/core/ingestion/languages/vue.js +81 -0
- package/dist/core/ingestion/method-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/method-extractors/configs/c-cpp.js +387 -0
- package/dist/core/ingestion/method-extractors/configs/csharp.js +5 -1
- package/dist/core/ingestion/method-extractors/configs/dart.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/dart.js +376 -0
- package/dist/core/ingestion/method-extractors/configs/go.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/go.js +176 -0
- package/dist/core/ingestion/method-extractors/configs/jvm.js +13 -4
- package/dist/core/ingestion/method-extractors/configs/php.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/php.js +304 -0
- package/dist/core/ingestion/method-extractors/configs/python.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/python.js +309 -0
- package/dist/core/ingestion/method-extractors/configs/ruby.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/ruby.js +285 -0
- package/dist/core/ingestion/method-extractors/configs/rust.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/rust.js +195 -0
- package/dist/core/ingestion/method-extractors/configs/swift.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/swift.js +277 -0
- package/dist/core/ingestion/method-extractors/configs/typescript-javascript.js +85 -8
- package/dist/core/ingestion/method-extractors/generic.js +38 -15
- package/dist/core/ingestion/method-types.d.ts +25 -0
- package/dist/core/ingestion/model/field-registry.d.ts +18 -0
- package/dist/core/ingestion/model/field-registry.js +22 -0
- package/dist/core/ingestion/model/heritage-map.d.ts +70 -0
- package/dist/core/ingestion/model/heritage-map.js +159 -0
- package/dist/core/ingestion/model/index.d.ts +20 -0
- package/dist/core/ingestion/model/index.js +41 -0
- package/dist/core/ingestion/model/method-registry.d.ts +62 -0
- package/dist/core/ingestion/model/method-registry.js +130 -0
- package/dist/core/ingestion/model/registration-table.d.ts +139 -0
- package/dist/core/ingestion/model/registration-table.js +224 -0
- package/dist/core/ingestion/model/resolution-context.d.ts +93 -0
- package/dist/core/ingestion/model/resolution-context.js +337 -0
- package/dist/core/ingestion/model/resolve.d.ts +56 -0
- package/dist/core/ingestion/model/resolve.js +242 -0
- package/dist/core/ingestion/model/semantic-model.d.ts +86 -0
- package/dist/core/ingestion/model/semantic-model.js +120 -0
- package/dist/core/ingestion/model/symbol-table.d.ts +222 -0
- package/dist/core/ingestion/model/symbol-table.js +206 -0
- package/dist/core/ingestion/model/type-registry.d.ts +39 -0
- package/dist/core/ingestion/model/type-registry.js +62 -0
- package/dist/core/ingestion/mro-processor.d.ts +4 -3
- package/dist/core/ingestion/mro-processor.js +310 -106
- package/dist/core/ingestion/parsing-processor.d.ts +5 -4
- package/dist/core/ingestion/parsing-processor.js +210 -85
- package/dist/core/ingestion/pipeline.d.ts +2 -0
- package/dist/core/ingestion/pipeline.js +192 -68
- package/dist/core/ingestion/tree-sitter-queries.d.ts +5 -5
- package/dist/core/ingestion/tree-sitter-queries.js +21 -0
- package/dist/core/ingestion/type-env.d.ts +15 -2
- package/dist/core/ingestion/type-env.js +163 -102
- package/dist/core/ingestion/type-extractors/csharp.js +17 -0
- package/dist/core/ingestion/type-extractors/jvm.js +11 -0
- package/dist/core/ingestion/type-extractors/php.js +0 -55
- package/dist/core/ingestion/type-extractors/ruby.js +0 -32
- package/dist/core/ingestion/type-extractors/swift.js +13 -0
- package/dist/core/ingestion/type-extractors/types.d.ts +8 -8
- package/dist/core/ingestion/type-extractors/typescript.js +66 -69
- package/dist/core/ingestion/utils/ast-helpers.d.ts +33 -43
- package/dist/core/ingestion/utils/ast-helpers.js +129 -572
- package/dist/core/ingestion/utils/method-props.d.ts +32 -0
- package/dist/core/ingestion/utils/method-props.js +147 -0
- package/dist/core/ingestion/vue-sfc-extractor.d.ts +44 -0
- package/dist/core/ingestion/vue-sfc-extractor.js +94 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +31 -19
- package/dist/core/ingestion/workers/parse-worker.js +463 -198
- package/dist/core/lbug/lbug-adapter.d.ts +6 -0
- package/dist/core/lbug/lbug-adapter.js +68 -3
- package/dist/core/lbug/pool-adapter.d.ts +76 -0
- package/dist/core/lbug/pool-adapter.js +522 -0
- package/dist/core/run-analyze.d.ts +2 -0
- package/dist/core/run-analyze.js +1 -1
- package/dist/core/search/bm25-index.js +1 -1
- package/dist/core/tree-sitter/parser-loader.js +1 -0
- package/dist/core/wiki/graph-queries.js +1 -1
- package/dist/mcp/core/embedder.js +6 -5
- package/dist/mcp/core/lbug-adapter.d.ts +3 -63
- package/dist/mcp/core/lbug-adapter.js +3 -484
- package/dist/mcp/local/local-backend.d.ts +31 -2
- package/dist/mcp/local/local-backend.js +255 -46
- package/dist/mcp/resources.js +5 -4
- package/dist/mcp/staleness.d.ts +3 -13
- package/dist/mcp/staleness.js +2 -31
- package/dist/mcp/tools.js +80 -4
- package/dist/server/analyze-job.d.ts +2 -0
- package/dist/server/analyze-job.js +4 -0
- package/dist/server/api.d.ts +20 -1
- package/dist/server/api.js +306 -71
- package/dist/server/git-clone.d.ts +2 -1
- package/dist/server/git-clone.js +98 -5
- package/dist/storage/git.d.ts +13 -0
- package/dist/storage/git.js +25 -0
- package/dist/storage/repo-manager.js +1 -1
- package/package.json +8 -2
- package/scripts/patch-tree-sitter-swift.cjs +78 -0
- package/dist/core/ingestion/named-binding-processor.d.ts +0 -18
- package/dist/core/ingestion/named-binding-processor.js +0 -42
- package/dist/core/ingestion/resolution-context.d.ts +0 -58
- package/dist/core/ingestion/resolution-context.js +0 -135
- package/dist/core/ingestion/symbol-table.d.ts +0 -79
- package/dist/core/ingestion/symbol-table.js +0 -115
|
@@ -8,14 +8,27 @@
|
|
|
8
8
|
* for its left-to-right multiple inheritance resolution order.
|
|
9
9
|
*/
|
|
10
10
|
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
11
|
+
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
11
12
|
import { defineLanguage } from '../language-provider.js';
|
|
12
13
|
import { typeConfig as cCppConfig } from '../type-extractors/c-cpp.js';
|
|
13
14
|
import { cCppExportChecker } from '../export-detection.js';
|
|
14
15
|
import { resolveCImport, resolveCppImport } from '../import-resolvers/standard.js';
|
|
15
16
|
import { C_QUERIES, CPP_QUERIES } from '../tree-sitter-queries.js';
|
|
16
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Node types for standard function declarations that need C/C++ declarator handling.
|
|
19
|
+
* Used by cCppExtractFunctionName to determine how to extract the function name.
|
|
20
|
+
*/
|
|
21
|
+
const FUNCTION_DECLARATION_TYPES = new Set([
|
|
22
|
+
'function_declaration',
|
|
23
|
+
'function_definition',
|
|
24
|
+
'async_function_declaration',
|
|
25
|
+
'generator_function_declaration',
|
|
26
|
+
'function_item',
|
|
27
|
+
]);
|
|
17
28
|
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
18
29
|
import { cConfig as cFieldConfig, cppConfig as cppFieldConfig, } from '../field-extractors/configs/c-cpp.js';
|
|
30
|
+
import { createMethodExtractor } from '../method-extractors/generic.js';
|
|
31
|
+
import { cMethodConfig, cppMethodConfig } from '../method-extractors/configs/c-cpp.js';
|
|
19
32
|
const C_BUILT_INS = new Set([
|
|
20
33
|
'printf',
|
|
21
34
|
'fprintf',
|
|
@@ -122,6 +135,150 @@ const C_BUILT_INS = new Set([
|
|
|
122
135
|
'get',
|
|
123
136
|
'put',
|
|
124
137
|
]);
|
|
138
|
+
const cClassExtractor = createClassExtractor({
|
|
139
|
+
language: SupportedLanguages.C,
|
|
140
|
+
typeDeclarationNodes: ['struct_specifier', 'enum_specifier'],
|
|
141
|
+
});
|
|
142
|
+
const cppClassExtractor = createClassExtractor({
|
|
143
|
+
language: SupportedLanguages.CPlusPlus,
|
|
144
|
+
typeDeclarationNodes: ['class_specifier', 'struct_specifier', 'enum_specifier'],
|
|
145
|
+
ancestorScopeNodeTypes: ['namespace_definition', 'class_specifier', 'struct_specifier'],
|
|
146
|
+
});
|
|
147
|
+
/**
|
|
148
|
+
* C/C++ function name extraction — unwraps pointer_declarator / reference_declarator /
|
|
149
|
+
* function_declarator / qualified_identifier chains to find the actual function name.
|
|
150
|
+
* Handles field_identifier (method inside class body) and parenthesized_declarator.
|
|
151
|
+
*/
|
|
152
|
+
const cCppExtractFunctionName = (node) => {
|
|
153
|
+
if (!FUNCTION_DECLARATION_TYPES.has(node.type))
|
|
154
|
+
return null;
|
|
155
|
+
let funcName = null;
|
|
156
|
+
let label = 'Function';
|
|
157
|
+
// C/C++: function_definition -> [pointer_declarator ->] function_declarator -> qualified_identifier/identifier
|
|
158
|
+
// Unwrap pointer_declarator / reference_declarator wrappers to reach function_declarator
|
|
159
|
+
let declarator = node.childForFieldName?.('declarator');
|
|
160
|
+
if (!declarator) {
|
|
161
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
162
|
+
const c = node.child(i);
|
|
163
|
+
if (c?.type === 'function_declarator') {
|
|
164
|
+
declarator = c;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
while (declarator &&
|
|
170
|
+
(declarator.type === 'pointer_declarator' || declarator.type === 'reference_declarator')) {
|
|
171
|
+
let nextDeclarator = declarator.childForFieldName?.('declarator');
|
|
172
|
+
if (!nextDeclarator) {
|
|
173
|
+
for (let i = 0; i < declarator.childCount; i++) {
|
|
174
|
+
const c = declarator.child(i);
|
|
175
|
+
if (c?.type === 'function_declarator' ||
|
|
176
|
+
c?.type === 'pointer_declarator' ||
|
|
177
|
+
c?.type === 'reference_declarator') {
|
|
178
|
+
nextDeclarator = c;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
declarator = nextDeclarator;
|
|
184
|
+
}
|
|
185
|
+
if (declarator) {
|
|
186
|
+
let innerDeclarator = declarator.childForFieldName?.('declarator');
|
|
187
|
+
if (!innerDeclarator) {
|
|
188
|
+
for (let i = 0; i < declarator.childCount; i++) {
|
|
189
|
+
const c = declarator.child(i);
|
|
190
|
+
if (c?.type === 'qualified_identifier' ||
|
|
191
|
+
c?.type === 'identifier' ||
|
|
192
|
+
c?.type === 'field_identifier' ||
|
|
193
|
+
c?.type === 'parenthesized_declarator') {
|
|
194
|
+
innerDeclarator = c;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (innerDeclarator?.type === 'qualified_identifier') {
|
|
200
|
+
let nameNode = innerDeclarator.childForFieldName?.('name');
|
|
201
|
+
if (!nameNode) {
|
|
202
|
+
for (let i = 0; i < innerDeclarator.childCount; i++) {
|
|
203
|
+
const c = innerDeclarator.child(i);
|
|
204
|
+
if (c?.type === 'identifier') {
|
|
205
|
+
nameNode = c;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (nameNode?.text) {
|
|
211
|
+
funcName = nameNode.text;
|
|
212
|
+
label = 'Method';
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else if (innerDeclarator?.type === 'identifier' ||
|
|
216
|
+
innerDeclarator?.type === 'field_identifier') {
|
|
217
|
+
// field_identifier is used for method names inside C++ class bodies
|
|
218
|
+
funcName = innerDeclarator.text;
|
|
219
|
+
if (innerDeclarator.type === 'field_identifier')
|
|
220
|
+
label = 'Method';
|
|
221
|
+
}
|
|
222
|
+
else if (innerDeclarator?.type === 'parenthesized_declarator') {
|
|
223
|
+
let nestedId = null;
|
|
224
|
+
for (let i = 0; i < innerDeclarator.childCount; i++) {
|
|
225
|
+
const c = innerDeclarator.child(i);
|
|
226
|
+
if (c?.type === 'qualified_identifier' || c?.type === 'identifier') {
|
|
227
|
+
nestedId = c;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (nestedId?.type === 'qualified_identifier') {
|
|
232
|
+
let nameNode = nestedId.childForFieldName?.('name');
|
|
233
|
+
if (!nameNode) {
|
|
234
|
+
for (let i = 0; i < nestedId.childCount; i++) {
|
|
235
|
+
const c = nestedId.child(i);
|
|
236
|
+
if (c?.type === 'identifier') {
|
|
237
|
+
nameNode = c;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (nameNode?.text) {
|
|
243
|
+
funcName = nameNode.text;
|
|
244
|
+
label = 'Method';
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else if (nestedId?.type === 'identifier') {
|
|
248
|
+
funcName = nestedId.text;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// Fallback for other node types in FUNCTION_DECLARATION_TYPES (e.g. function_item for Rust in C++ tree)
|
|
253
|
+
if (!funcName) {
|
|
254
|
+
let nameNode = node.childForFieldName?.('name');
|
|
255
|
+
if (!nameNode) {
|
|
256
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
257
|
+
const c = node.child(i);
|
|
258
|
+
if (c?.type === 'identifier' ||
|
|
259
|
+
c?.type === 'property_identifier' ||
|
|
260
|
+
c?.type === 'simple_identifier') {
|
|
261
|
+
nameNode = c;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
funcName = nameNode?.text ?? null;
|
|
267
|
+
}
|
|
268
|
+
return { funcName, label };
|
|
269
|
+
};
|
|
270
|
+
/** Check if a C/C++ function_definition is inside a class or struct body.
|
|
271
|
+
* Used by cppLabelOverride to skip duplicate function captures
|
|
272
|
+
* that are already covered by definition.method queries. */
|
|
273
|
+
function isCppInsideClassOrStruct(functionNode) {
|
|
274
|
+
let ancestor = functionNode?.parent ?? null;
|
|
275
|
+
while (ancestor) {
|
|
276
|
+
if (ancestor.type === 'class_specifier' || ancestor.type === 'struct_specifier')
|
|
277
|
+
return true;
|
|
278
|
+
ancestor = ancestor.parent;
|
|
279
|
+
}
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
125
282
|
/** Label override shared by C and C++: skip function_definition captures inside class/struct
|
|
126
283
|
* bodies (they're duplicates of definition.method captures). */
|
|
127
284
|
const cppLabelOverride = (functionNode, defaultLabel) => {
|
|
@@ -138,6 +295,11 @@ export const cProvider = defineLanguage({
|
|
|
138
295
|
importResolver: resolveCImport,
|
|
139
296
|
importSemantics: 'wildcard',
|
|
140
297
|
fieldExtractor: createFieldExtractor(cFieldConfig),
|
|
298
|
+
methodExtractor: createMethodExtractor({
|
|
299
|
+
...cMethodConfig,
|
|
300
|
+
extractFunctionName: cCppExtractFunctionName,
|
|
301
|
+
}),
|
|
302
|
+
classExtractor: cClassExtractor,
|
|
141
303
|
labelOverride: cppLabelOverride,
|
|
142
304
|
builtInNames: C_BUILT_INS,
|
|
143
305
|
});
|
|
@@ -151,6 +313,11 @@ export const cppProvider = defineLanguage({
|
|
|
151
313
|
importSemantics: 'wildcard',
|
|
152
314
|
mroStrategy: 'leftmost-base',
|
|
153
315
|
fieldExtractor: createFieldExtractor(cppFieldConfig),
|
|
316
|
+
methodExtractor: createMethodExtractor({
|
|
317
|
+
...cppMethodConfig,
|
|
318
|
+
extractFunctionName: cCppExtractFunctionName,
|
|
319
|
+
}),
|
|
320
|
+
classExtractor: cppClassExtractor,
|
|
154
321
|
labelOverride: cppLabelOverride,
|
|
155
322
|
builtInNames: C_BUILT_INS,
|
|
156
323
|
});
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* Interface names follow the I-prefix convention (e.g., IDisposable).
|
|
7
7
|
*/
|
|
8
8
|
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
9
|
+
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
9
10
|
import { defineLanguage } from '../language-provider.js';
|
|
10
11
|
import { typeConfig as csharpConfig } from '../type-extractors/csharp.js';
|
|
11
12
|
import { csharpExportChecker } from '../export-detection.js';
|
|
@@ -122,5 +123,24 @@ export const csharpProvider = defineLanguage({
|
|
|
122
123
|
mroStrategy: 'implements-split',
|
|
123
124
|
fieldExtractor: createFieldExtractor(csharpFieldConfig),
|
|
124
125
|
methodExtractor: createMethodExtractor(csharpMethodConfig),
|
|
126
|
+
classExtractor: createClassExtractor({
|
|
127
|
+
language: SupportedLanguages.CSharp,
|
|
128
|
+
typeDeclarationNodes: [
|
|
129
|
+
'class_declaration',
|
|
130
|
+
'interface_declaration',
|
|
131
|
+
'struct_declaration',
|
|
132
|
+
'enum_declaration',
|
|
133
|
+
'record_declaration',
|
|
134
|
+
],
|
|
135
|
+
fileScopeNodeTypes: ['file_scoped_namespace_declaration'],
|
|
136
|
+
ancestorScopeNodeTypes: [
|
|
137
|
+
'namespace_declaration',
|
|
138
|
+
'class_declaration',
|
|
139
|
+
'interface_declaration',
|
|
140
|
+
'struct_declaration',
|
|
141
|
+
'enum_declaration',
|
|
142
|
+
'record_declaration',
|
|
143
|
+
],
|
|
144
|
+
}),
|
|
125
145
|
builtInNames: BUILT_INS,
|
|
126
146
|
});
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* as a sibling of function_signature/method_signature (not as a child).
|
|
10
10
|
* The hook resolves the enclosing function by inspecting the previous sibling.
|
|
11
11
|
*/
|
|
12
|
-
import { FUNCTION_NODE_TYPES
|
|
12
|
+
import { FUNCTION_NODE_TYPES } from '../utils/ast-helpers.js';
|
|
13
13
|
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
14
|
+
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
14
15
|
import { defineLanguage } from '../language-provider.js';
|
|
15
16
|
import { typeConfig as dartConfig } from '../type-extractors/dart.js';
|
|
16
17
|
import { dartExportChecker } from '../export-detection.js';
|
|
@@ -18,14 +19,16 @@ import { resolveDartImport } from '../import-resolvers/dart.js';
|
|
|
18
19
|
import { DART_QUERIES } from '../tree-sitter-queries.js';
|
|
19
20
|
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
20
21
|
import { dartConfig as dartFieldConfig } from '../field-extractors/configs/dart.js';
|
|
22
|
+
import { createMethodExtractor } from '../method-extractors/generic.js';
|
|
23
|
+
import { dartMethodConfig } from '../method-extractors/configs/dart.js';
|
|
21
24
|
/**
|
|
22
25
|
* Resolve the enclosing function from a `function_body` node by looking at its
|
|
23
26
|
* previous sibling. In Dart's tree-sitter grammar, function_signature and
|
|
24
27
|
* function_body are siblings under program or class_body, unlike most languages
|
|
25
28
|
* where the function declaration wraps both.
|
|
26
29
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
30
|
+
* Extracts the function name inline — Dart uses function_signature and
|
|
31
|
+
* method_signature (which wraps function_signature) as its FUNCTION_NODE_TYPES.
|
|
29
32
|
*/
|
|
30
33
|
const dartEnclosingFunctionFinder = (node) => {
|
|
31
34
|
if (node.type !== 'function_body')
|
|
@@ -33,7 +36,20 @@ const dartEnclosingFunctionFinder = (node) => {
|
|
|
33
36
|
const prev = node.previousSibling;
|
|
34
37
|
if (!prev || !FUNCTION_NODE_TYPES.has(prev.type))
|
|
35
38
|
return null;
|
|
36
|
-
|
|
39
|
+
// method_signature wraps function_signature — unwrap to reach the name
|
|
40
|
+
let target = prev;
|
|
41
|
+
let label = 'Function';
|
|
42
|
+
if (prev.type === 'method_signature') {
|
|
43
|
+
label = 'Method';
|
|
44
|
+
for (let i = 0; i < prev.childCount; i++) {
|
|
45
|
+
const c = prev.child(i);
|
|
46
|
+
if (c?.type === 'function_signature') {
|
|
47
|
+
target = c;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const funcName = target.childForFieldName?.('name')?.text ?? null;
|
|
37
53
|
return funcName ? { funcName, label } : null;
|
|
38
54
|
};
|
|
39
55
|
const BUILT_INS = new Set([
|
|
@@ -69,6 +85,12 @@ export const dartProvider = defineLanguage({
|
|
|
69
85
|
importResolver: resolveDartImport,
|
|
70
86
|
importSemantics: 'wildcard',
|
|
71
87
|
fieldExtractor: createFieldExtractor(dartFieldConfig),
|
|
88
|
+
methodExtractor: createMethodExtractor(dartMethodConfig),
|
|
89
|
+
classExtractor: createClassExtractor({
|
|
90
|
+
language: SupportedLanguages.Dart,
|
|
91
|
+
typeDeclarationNodes: ['class_definition', 'extension_declaration', 'enum_declaration'],
|
|
92
|
+
ancestorScopeNodeTypes: ['class_definition', 'extension_declaration', 'enum_declaration'],
|
|
93
|
+
}),
|
|
72
94
|
enclosingFunctionFinder: dartEnclosingFunctionFinder,
|
|
73
95
|
builtInNames: BUILT_INS,
|
|
74
96
|
});
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* - callRouter: present (Go method calls may need routing)
|
|
10
10
|
*/
|
|
11
11
|
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
12
|
+
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
12
13
|
import { defineLanguage } from '../language-provider.js';
|
|
13
14
|
import { typeConfig as goConfig } from '../type-extractors/go.js';
|
|
14
15
|
import { goExportChecker } from '../export-detection.js';
|
|
@@ -16,6 +17,8 @@ import { resolveGoImport } from '../import-resolvers/go.js';
|
|
|
16
17
|
import { GO_QUERIES } from '../tree-sitter-queries.js';
|
|
17
18
|
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
18
19
|
import { goConfig as goFieldConfig } from '../field-extractors/configs/go.js';
|
|
20
|
+
import { createMethodExtractor } from '../method-extractors/generic.js';
|
|
21
|
+
import { goMethodConfig } from '../method-extractors/configs/go.js';
|
|
19
22
|
export const goProvider = defineLanguage({
|
|
20
23
|
id: SupportedLanguages.Go,
|
|
21
24
|
extensions: ['.go'],
|
|
@@ -25,4 +28,23 @@ export const goProvider = defineLanguage({
|
|
|
25
28
|
importResolver: resolveGoImport,
|
|
26
29
|
importSemantics: 'wildcard',
|
|
27
30
|
fieldExtractor: createFieldExtractor(goFieldConfig),
|
|
31
|
+
methodExtractor: createMethodExtractor(goMethodConfig),
|
|
32
|
+
classExtractor: createClassExtractor({
|
|
33
|
+
language: SupportedLanguages.Go,
|
|
34
|
+
typeDeclarationNodes: ['type_declaration'],
|
|
35
|
+
fileScopeNodeTypes: ['package_clause'],
|
|
36
|
+
extractName(node) {
|
|
37
|
+
const typeSpec = node.namedChildren.find((child) => child.type === 'type_spec');
|
|
38
|
+
return typeSpec?.childForFieldName('name')?.text;
|
|
39
|
+
},
|
|
40
|
+
extractType(node) {
|
|
41
|
+
const typeSpec = node.namedChildren.find((child) => child.type === 'type_spec');
|
|
42
|
+
const typeNode = typeSpec?.childForFieldName('type');
|
|
43
|
+
if (typeNode?.type === 'struct_type')
|
|
44
|
+
return 'Struct';
|
|
45
|
+
if (typeNode?.type === 'interface_type')
|
|
46
|
+
return 'Interface';
|
|
47
|
+
return undefined;
|
|
48
|
+
},
|
|
49
|
+
}),
|
|
28
50
|
});
|
|
@@ -20,6 +20,7 @@ import { phpProvider } from './php.js';
|
|
|
20
20
|
import { rubyProvider } from './ruby.js';
|
|
21
21
|
import { swiftProvider } from './swift.js';
|
|
22
22
|
import { dartProvider } from './dart.js';
|
|
23
|
+
import { vueProvider } from './vue.js';
|
|
23
24
|
import { cobolProvider } from './cobol.js';
|
|
24
25
|
export const providers = {
|
|
25
26
|
[SupportedLanguages.JavaScript]: javascriptProvider,
|
|
@@ -36,6 +37,7 @@ export const providers = {
|
|
|
36
37
|
[SupportedLanguages.Ruby]: rubyProvider,
|
|
37
38
|
[SupportedLanguages.Swift]: swiftProvider,
|
|
38
39
|
[SupportedLanguages.Dart]: dartProvider,
|
|
40
|
+
[SupportedLanguages.Vue]: vueProvider,
|
|
39
41
|
[SupportedLanguages.Cobol]: cobolProvider,
|
|
40
42
|
};
|
|
41
43
|
/** Get provider by language enum (always succeeds for SupportedLanguages). */
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* interface implementation.
|
|
8
8
|
*/
|
|
9
9
|
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
10
|
+
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
10
11
|
import { defineLanguage } from '../language-provider.js';
|
|
11
12
|
import { javaTypeConfig } from '../type-extractors/jvm.js';
|
|
12
13
|
import { javaExportChecker } from '../export-detection.js';
|
|
@@ -29,4 +30,20 @@ export const javaProvider = defineLanguage({
|
|
|
29
30
|
mroStrategy: 'implements-split',
|
|
30
31
|
fieldExtractor: createFieldExtractor(javaConfig),
|
|
31
32
|
methodExtractor: createMethodExtractor(javaMethodConfig),
|
|
33
|
+
classExtractor: createClassExtractor({
|
|
34
|
+
language: SupportedLanguages.Java,
|
|
35
|
+
typeDeclarationNodes: [
|
|
36
|
+
'class_declaration',
|
|
37
|
+
'interface_declaration',
|
|
38
|
+
'enum_declaration',
|
|
39
|
+
'record_declaration',
|
|
40
|
+
],
|
|
41
|
+
fileScopeNodeTypes: ['package_declaration'],
|
|
42
|
+
ancestorScopeNodeTypes: [
|
|
43
|
+
'class_declaration',
|
|
44
|
+
'interface_declaration',
|
|
45
|
+
'enum_declaration',
|
|
46
|
+
'record_declaration',
|
|
47
|
+
],
|
|
48
|
+
}),
|
|
32
49
|
});
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* multiple interface implementation.
|
|
8
8
|
*/
|
|
9
9
|
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
10
|
+
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
10
11
|
import { defineLanguage } from '../language-provider.js';
|
|
11
12
|
import { kotlinTypeConfig } from '../type-extractors/jvm.js';
|
|
12
13
|
import { kotlinExportChecker } from '../export-detection.js';
|
|
@@ -14,11 +15,22 @@ import { resolveKotlinImport } from '../import-resolvers/jvm.js';
|
|
|
14
15
|
import { extractKotlinNamedBindings } from '../named-bindings/kotlin.js';
|
|
15
16
|
import { appendKotlinWildcard } from '../import-resolvers/jvm.js';
|
|
16
17
|
import { KOTLIN_QUERIES } from '../tree-sitter-queries.js';
|
|
17
|
-
import { isKotlinClassMethod } from '../utils/ast-helpers.js';
|
|
18
18
|
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
19
19
|
import { kotlinConfig } from '../field-extractors/configs/jvm.js';
|
|
20
20
|
import { createMethodExtractor } from '../method-extractors/generic.js';
|
|
21
21
|
import { kotlinMethodConfig } from '../method-extractors/configs/jvm.js';
|
|
22
|
+
/** Check if a Kotlin function_declaration capture is inside a class_body (i.e., a method).
|
|
23
|
+
* Kotlin grammar uses function_declaration for both top-level functions and class methods.
|
|
24
|
+
* Returns true when the captured definition node has a class_body ancestor. */
|
|
25
|
+
function isKotlinClassMethod(captureNode) {
|
|
26
|
+
let ancestor = captureNode?.parent;
|
|
27
|
+
while (ancestor) {
|
|
28
|
+
if (ancestor.type === 'class_body')
|
|
29
|
+
return true;
|
|
30
|
+
ancestor = ancestor.parent;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
22
34
|
const BUILT_INS = new Set([
|
|
23
35
|
'println',
|
|
24
36
|
'print',
|
|
@@ -89,6 +101,17 @@ export const kotlinProvider = defineLanguage({
|
|
|
89
101
|
mroStrategy: 'implements-split',
|
|
90
102
|
fieldExtractor: createFieldExtractor(kotlinConfig),
|
|
91
103
|
methodExtractor: createMethodExtractor(kotlinMethodConfig),
|
|
104
|
+
classExtractor: createClassExtractor({
|
|
105
|
+
language: SupportedLanguages.Kotlin,
|
|
106
|
+
typeDeclarationNodes: ['class_declaration', 'object_declaration', 'companion_object'],
|
|
107
|
+
fileScopeNodeTypes: ['package_header'],
|
|
108
|
+
ancestorScopeNodeTypes: ['class_declaration', 'object_declaration', 'companion_object'],
|
|
109
|
+
extractType(node) {
|
|
110
|
+
if (node.type !== 'class_declaration')
|
|
111
|
+
return undefined;
|
|
112
|
+
return node.children.some((child) => child?.text === 'interface') ? 'Interface' : 'Class';
|
|
113
|
+
},
|
|
114
|
+
}),
|
|
92
115
|
builtInNames: BUILT_INS,
|
|
93
116
|
labelOverride: (functionNode, defaultLabel) => {
|
|
94
117
|
if (defaultLabel !== 'Function')
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* extensions from legacy versions through modern PHP 8.
|
|
7
7
|
*/
|
|
8
8
|
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
9
|
+
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
9
10
|
import { defineLanguage } from '../language-provider.js';
|
|
10
11
|
import { typeConfig as phpConfig } from '../type-extractors/php.js';
|
|
11
12
|
import { phpExportChecker } from '../export-detection.js';
|
|
@@ -15,6 +16,8 @@ import { PHP_QUERIES } from '../tree-sitter-queries.js';
|
|
|
15
16
|
import { findDescendant, extractStringContent } from '../utils/ast-helpers.js';
|
|
16
17
|
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
17
18
|
import { phpConfig as phpFieldConfig } from '../field-extractors/configs/php.js';
|
|
19
|
+
import { createMethodExtractor } from '../method-extractors/generic.js';
|
|
20
|
+
import { phpMethodConfig } from '../method-extractors/configs/php.js';
|
|
18
21
|
const BUILT_INS = new Set([
|
|
19
22
|
'echo',
|
|
20
23
|
'isset',
|
|
@@ -153,18 +156,21 @@ function extractPhpPropertyDescription(propName, propDeclNode) {
|
|
|
153
156
|
* Returns description like "hasMany(Post)" or null.
|
|
154
157
|
*/
|
|
155
158
|
function extractEloquentRelationDescription(methodNode) {
|
|
156
|
-
function findRelationCall(
|
|
157
|
-
|
|
159
|
+
function findRelationCall(root) {
|
|
160
|
+
const stack = [root];
|
|
161
|
+
while (stack.length > 0) {
|
|
162
|
+
const node = stack.pop();
|
|
163
|
+
if (node.type === 'member_call_expression') {
|
|
164
|
+
const children = node.children ?? [];
|
|
165
|
+
const objectNode = children.find((c) => c.type === 'variable_name' && c.text === '$this');
|
|
166
|
+
const nameNode = children.find((c) => c.type === 'name');
|
|
167
|
+
if (objectNode && nameNode && ELOQUENT_RELATIONS.has(nameNode.text))
|
|
168
|
+
return node;
|
|
169
|
+
}
|
|
158
170
|
const children = node.children ?? [];
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return node;
|
|
163
|
-
}
|
|
164
|
-
for (const child of node.children ?? []) {
|
|
165
|
-
const found = findRelationCall(child);
|
|
166
|
-
if (found)
|
|
167
|
-
return found;
|
|
171
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
172
|
+
stack.push(children[i]);
|
|
173
|
+
}
|
|
168
174
|
}
|
|
169
175
|
return null;
|
|
170
176
|
}
|
|
@@ -216,6 +222,12 @@ export const phpProvider = defineLanguage({
|
|
|
216
222
|
importResolver: resolvePhpImport,
|
|
217
223
|
namedBindingExtractor: extractPhpNamedBindings,
|
|
218
224
|
fieldExtractor: createFieldExtractor(phpFieldConfig),
|
|
225
|
+
methodExtractor: createMethodExtractor(phpMethodConfig),
|
|
226
|
+
classExtractor: createClassExtractor({
|
|
227
|
+
language: SupportedLanguages.PHP,
|
|
228
|
+
typeDeclarationNodes: ['class_declaration', 'interface_declaration', 'enum_declaration'],
|
|
229
|
+
ancestorScopeNodeTypes: ['namespace_definition'],
|
|
230
|
+
}),
|
|
219
231
|
descriptionExtractor: phpDescriptionExtractor,
|
|
220
232
|
isRouteFile: isPhpRouteFile,
|
|
221
233
|
builtInNames: BUILT_INS,
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - namedBindingExtractor: present (from X import Y)
|
|
11
11
|
*/
|
|
12
12
|
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
13
|
+
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
13
14
|
import { defineLanguage } from '../language-provider.js';
|
|
14
15
|
import { typeConfig as pythonConfig } from '../type-extractors/python.js';
|
|
15
16
|
import { pythonExportChecker } from '../export-detection.js';
|
|
@@ -18,6 +19,8 @@ import { extractPythonNamedBindings } from '../named-bindings/python.js';
|
|
|
18
19
|
import { PYTHON_QUERIES } from '../tree-sitter-queries.js';
|
|
19
20
|
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
20
21
|
import { pythonConfig as pythonFieldConfig } from '../field-extractors/configs/python.js';
|
|
22
|
+
import { createMethodExtractor } from '../method-extractors/generic.js';
|
|
23
|
+
import { pythonMethodConfig } from '../method-extractors/configs/python.js';
|
|
21
24
|
const BUILT_INS = new Set([
|
|
22
25
|
'print',
|
|
23
26
|
'len',
|
|
@@ -58,5 +61,11 @@ export const pythonProvider = defineLanguage({
|
|
|
58
61
|
importSemantics: 'namespace',
|
|
59
62
|
mroStrategy: 'c3',
|
|
60
63
|
fieldExtractor: createFieldExtractor(pythonFieldConfig),
|
|
64
|
+
methodExtractor: createMethodExtractor(pythonMethodConfig),
|
|
65
|
+
classExtractor: createClassExtractor({
|
|
66
|
+
language: SupportedLanguages.Python,
|
|
67
|
+
typeDeclarationNodes: ['class_definition'],
|
|
68
|
+
ancestorScopeNodeTypes: ['class_definition'],
|
|
69
|
+
}),
|
|
61
70
|
builtInNames: BUILT_INS,
|
|
62
71
|
});
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* attr_reader/attr_writer (property definitions) as call expressions.
|
|
8
8
|
*/
|
|
9
9
|
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
10
|
+
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
10
11
|
import { defineLanguage } from '../language-provider.js';
|
|
11
12
|
import { typeConfig as rubyConfig } from '../type-extractors/ruby.js';
|
|
12
13
|
import { routeRubyCall } from '../call-routing.js';
|
|
@@ -15,6 +16,24 @@ import { resolveRubyImport } from '../import-resolvers/ruby.js';
|
|
|
15
16
|
import { RUBY_QUERIES } from '../tree-sitter-queries.js';
|
|
16
17
|
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
17
18
|
import { rubyConfig as rubyFieldConfig } from '../field-extractors/configs/ruby.js';
|
|
19
|
+
import { createMethodExtractor } from '../method-extractors/generic.js';
|
|
20
|
+
import { rubyMethodConfig } from '../method-extractors/configs/ruby.js';
|
|
21
|
+
/** Ruby method/singleton_method: extract name from 'name' field, label as Method. */
|
|
22
|
+
const rubyExtractFunctionName = (node) => {
|
|
23
|
+
if (node.type !== 'method' && node.type !== 'singleton_method')
|
|
24
|
+
return null;
|
|
25
|
+
let nameNode = node.childForFieldName?.('name');
|
|
26
|
+
if (!nameNode) {
|
|
27
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
28
|
+
const c = node.child(i);
|
|
29
|
+
if (c?.type === 'identifier') {
|
|
30
|
+
nameNode = c;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return { funcName: nameNode?.text ?? null, label: 'Method' };
|
|
36
|
+
};
|
|
18
37
|
const BUILT_INS = new Set([
|
|
19
38
|
'puts',
|
|
20
39
|
'p',
|
|
@@ -82,5 +101,14 @@ export const rubyProvider = defineLanguage({
|
|
|
82
101
|
callRouter: routeRubyCall,
|
|
83
102
|
importSemantics: 'wildcard',
|
|
84
103
|
fieldExtractor: createFieldExtractor(rubyFieldConfig),
|
|
104
|
+
methodExtractor: createMethodExtractor({
|
|
105
|
+
...rubyMethodConfig,
|
|
106
|
+
extractFunctionName: rubyExtractFunctionName,
|
|
107
|
+
}),
|
|
108
|
+
classExtractor: createClassExtractor({
|
|
109
|
+
language: SupportedLanguages.Ruby,
|
|
110
|
+
typeDeclarationNodes: ['class'],
|
|
111
|
+
ancestorScopeNodeTypes: ['module', 'class'],
|
|
112
|
+
}),
|
|
85
113
|
builtInNames: BUILT_INS,
|
|
86
114
|
});
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - namedBindingExtractor: present (use X::{a, b} extracts named bindings)
|
|
11
11
|
*/
|
|
12
12
|
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
13
|
+
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
13
14
|
import { defineLanguage } from '../language-provider.js';
|
|
14
15
|
import { typeConfig as rustConfig } from '../type-extractors/rust.js';
|
|
15
16
|
import { rustExportChecker } from '../export-detection.js';
|
|
@@ -18,6 +19,34 @@ import { extractRustNamedBindings } from '../named-bindings/rust.js';
|
|
|
18
19
|
import { RUST_QUERIES } from '../tree-sitter-queries.js';
|
|
19
20
|
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
20
21
|
import { rustConfig as rustFieldConfig } from '../field-extractors/configs/rust.js';
|
|
22
|
+
import { createMethodExtractor } from '../method-extractors/generic.js';
|
|
23
|
+
import { rustMethodConfig } from '../method-extractors/configs/rust.js';
|
|
24
|
+
/** Rust impl_item: find the function_item child and extract its name as a Method. */
|
|
25
|
+
const rustExtractFunctionName = (node) => {
|
|
26
|
+
if (node.type !== 'impl_item')
|
|
27
|
+
return null;
|
|
28
|
+
let funcItem = null;
|
|
29
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
30
|
+
const c = node.child(i);
|
|
31
|
+
if (c?.type === 'function_item') {
|
|
32
|
+
funcItem = c;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!funcItem)
|
|
37
|
+
return null;
|
|
38
|
+
let nameNode = funcItem.childForFieldName?.('name');
|
|
39
|
+
if (!nameNode) {
|
|
40
|
+
for (let i = 0; i < funcItem.childCount; i++) {
|
|
41
|
+
const c = funcItem.child(i);
|
|
42
|
+
if (c?.type === 'identifier') {
|
|
43
|
+
nameNode = c;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { funcName: nameNode?.text ?? null, label: 'Method' };
|
|
49
|
+
};
|
|
21
50
|
const BUILT_INS = new Set([
|
|
22
51
|
'unwrap',
|
|
23
52
|
'expect',
|
|
@@ -84,5 +113,14 @@ export const rustProvider = defineLanguage({
|
|
|
84
113
|
namedBindingExtractor: extractRustNamedBindings,
|
|
85
114
|
mroStrategy: 'qualified-syntax',
|
|
86
115
|
fieldExtractor: createFieldExtractor(rustFieldConfig),
|
|
116
|
+
methodExtractor: createMethodExtractor({
|
|
117
|
+
...rustMethodConfig,
|
|
118
|
+
extractFunctionName: rustExtractFunctionName,
|
|
119
|
+
}),
|
|
120
|
+
classExtractor: createClassExtractor({
|
|
121
|
+
language: SupportedLanguages.Rust,
|
|
122
|
+
typeDeclarationNodes: ['struct_item', 'enum_item'],
|
|
123
|
+
ancestorScopeNodeTypes: ['mod_item', 'struct_item', 'enum_item'],
|
|
124
|
+
}),
|
|
87
125
|
builtInNames: BUILT_INS,
|
|
88
126
|
});
|