gitnexus 1.5.3 → 1.6.1
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 +30 -4
- 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/fs-utils.d.ts +10 -0
- package/dist/core/group/extractors/fs-utils.js +24 -0
- package/dist/core/group/extractors/grpc-extractor.d.ts +25 -0
- package/dist/core/group/extractors/grpc-extractor.js +386 -0
- package/dist/core/group/extractors/grpc-patterns/go.d.ts +2 -0
- package/dist/core/group/extractors/grpc-patterns/go.js +97 -0
- package/dist/core/group/extractors/grpc-patterns/index.d.ts +19 -0
- package/dist/core/group/extractors/grpc-patterns/index.js +46 -0
- package/dist/core/group/extractors/grpc-patterns/java.d.ts +2 -0
- package/dist/core/group/extractors/grpc-patterns/java.js +173 -0
- package/dist/core/group/extractors/grpc-patterns/node.d.ts +4 -0
- package/dist/core/group/extractors/grpc-patterns/node.js +290 -0
- package/dist/core/group/extractors/grpc-patterns/proto.d.ts +9 -0
- package/dist/core/group/extractors/grpc-patterns/proto.js +134 -0
- package/dist/core/group/extractors/grpc-patterns/python.d.ts +2 -0
- package/dist/core/group/extractors/grpc-patterns/python.js +67 -0
- package/dist/core/group/extractors/grpc-patterns/types.d.ts +50 -0
- package/dist/core/group/extractors/grpc-patterns/types.js +1 -0
- package/dist/core/group/extractors/http-patterns/go.d.ts +2 -0
- package/dist/core/group/extractors/http-patterns/go.js +215 -0
- package/dist/core/group/extractors/http-patterns/index.d.ts +17 -0
- package/dist/core/group/extractors/http-patterns/index.js +44 -0
- package/dist/core/group/extractors/http-patterns/java.d.ts +2 -0
- package/dist/core/group/extractors/http-patterns/java.js +253 -0
- package/dist/core/group/extractors/http-patterns/node.d.ts +4 -0
- package/dist/core/group/extractors/http-patterns/node.js +354 -0
- package/dist/core/group/extractors/http-patterns/php.d.ts +2 -0
- package/dist/core/group/extractors/http-patterns/php.js +70 -0
- package/dist/core/group/extractors/http-patterns/python.d.ts +2 -0
- package/dist/core/group/extractors/http-patterns/python.js +133 -0
- package/dist/core/group/extractors/http-patterns/types.d.ts +61 -0
- package/dist/core/group/extractors/http-patterns/types.js +1 -0
- package/dist/core/group/extractors/http-route-extractor.d.ts +21 -0
- package/dist/core/group/extractors/http-route-extractor.js +391 -0
- package/dist/core/group/extractors/manifest-extractor.d.ts +54 -0
- package/dist/core/group/extractors/manifest-extractor.js +235 -0
- package/dist/core/group/extractors/topic-extractor.d.ts +8 -0
- package/dist/core/group/extractors/topic-extractor.js +97 -0
- package/dist/core/group/extractors/topic-patterns/go.d.ts +2 -0
- package/dist/core/group/extractors/topic-patterns/go.js +120 -0
- package/dist/core/group/extractors/topic-patterns/index.d.ts +14 -0
- package/dist/core/group/extractors/topic-patterns/index.js +38 -0
- package/dist/core/group/extractors/topic-patterns/java.d.ts +2 -0
- package/dist/core/group/extractors/topic-patterns/java.js +80 -0
- package/dist/core/group/extractors/topic-patterns/node.d.ts +4 -0
- package/dist/core/group/extractors/topic-patterns/node.js +155 -0
- package/dist/core/group/extractors/topic-patterns/python.d.ts +2 -0
- package/dist/core/group/extractors/topic-patterns/python.js +116 -0
- package/dist/core/group/extractors/topic-patterns/types.d.ts +25 -0
- package/dist/core/group/extractors/topic-patterns/types.js +10 -0
- package/dist/core/group/extractors/tree-sitter-scanner.d.ts +113 -0
- package/dist/core/group/extractors/tree-sitter-scanner.js +94 -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 +212 -0
- package/dist/core/ingestion/binding-accumulator.js +336 -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/cobol-processor.d.ts +1 -1
- 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 +1 -13
- 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-config.js +1 -1
- package/dist/core/ingestion/language-provider.d.ts +14 -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 +43 -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/markdown-processor.d.ts +1 -1
- 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 +14 -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 +286 -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.d.ts +6 -0
- package/dist/core/ingestion/method-extractors/generic.js +84 -17
- package/dist/core/ingestion/method-types.d.ts +29 -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 +297 -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 +5 -4
- package/dist/core/ingestion/mro-processor.js +311 -107
- package/dist/core/ingestion/parsing-processor.d.ts +5 -4
- package/dist/core/ingestion/parsing-processor.js +224 -87
- package/dist/core/ingestion/pipeline-phases/cobol.d.ts +16 -0
- package/dist/core/ingestion/pipeline-phases/cobol.js +45 -0
- package/dist/core/ingestion/pipeline-phases/communities.d.ts +16 -0
- package/dist/core/ingestion/pipeline-phases/communities.js +62 -0
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.d.ts +17 -0
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.js +156 -0
- package/dist/core/ingestion/pipeline-phases/cross-file.d.ts +37 -0
- package/dist/core/ingestion/pipeline-phases/cross-file.js +63 -0
- package/dist/core/ingestion/pipeline-phases/index.d.ts +21 -0
- package/dist/core/ingestion/pipeline-phases/index.js +22 -0
- package/dist/core/ingestion/pipeline-phases/markdown.d.ts +17 -0
- package/dist/core/ingestion/pipeline-phases/markdown.js +33 -0
- package/dist/core/ingestion/pipeline-phases/mro.d.ts +18 -0
- package/dist/core/ingestion/pipeline-phases/mro.js +36 -0
- package/dist/core/ingestion/pipeline-phases/orm-extraction.d.ts +22 -0
- package/dist/core/ingestion/pipeline-phases/orm-extraction.js +92 -0
- package/dist/core/ingestion/pipeline-phases/orm.d.ts +15 -0
- package/dist/core/ingestion/pipeline-phases/orm.js +74 -0
- package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +47 -0
- package/dist/core/ingestion/pipeline-phases/parse-impl.js +437 -0
- package/dist/core/ingestion/pipeline-phases/parse.d.ts +49 -0
- package/dist/core/ingestion/pipeline-phases/parse.js +33 -0
- package/dist/core/ingestion/pipeline-phases/processes.d.ts +16 -0
- package/dist/core/ingestion/pipeline-phases/processes.js +143 -0
- package/dist/core/ingestion/pipeline-phases/routes.d.ts +21 -0
- package/dist/core/ingestion/pipeline-phases/routes.js +243 -0
- package/dist/core/ingestion/pipeline-phases/runner.d.ts +22 -0
- package/dist/core/ingestion/pipeline-phases/runner.js +203 -0
- package/dist/core/ingestion/pipeline-phases/scan.d.ts +21 -0
- package/dist/core/ingestion/pipeline-phases/scan.js +46 -0
- package/dist/core/ingestion/pipeline-phases/structure.d.ts +27 -0
- package/dist/core/ingestion/pipeline-phases/structure.js +35 -0
- package/dist/core/ingestion/pipeline-phases/tools.d.ts +20 -0
- package/dist/core/ingestion/pipeline-phases/tools.js +79 -0
- package/dist/core/ingestion/pipeline-phases/types.d.ts +79 -0
- package/dist/core/ingestion/pipeline-phases/types.js +37 -0
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.d.ts +35 -0
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.js +174 -0
- package/dist/core/ingestion/pipeline.d.ts +18 -10
- package/dist/core/ingestion/pipeline.js +66 -1410
- package/dist/core/ingestion/process-processor.js +1 -1
- package/dist/core/ingestion/tree-sitter-queries.d.ts +5 -5
- package/dist/core/ingestion/tree-sitter-queries.js +90 -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 +32 -44
- package/dist/core/ingestion/utils/ast-helpers.js +157 -573
- package/dist/core/ingestion/utils/env.d.ts +10 -0
- package/dist/core/ingestion/utils/env.js +10 -0
- package/dist/core/ingestion/utils/graph-sort.d.ts +58 -0
- package/dist/core/ingestion/utils/graph-sort.js +100 -0
- 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 +469 -200
- package/dist/core/lbug/lbug-adapter.d.ts +6 -0
- package/dist/core/lbug/lbug-adapter.js +134 -27
- 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 +9 -3
- package/scripts/patch-tree-sitter-swift.cjs +78 -0
- package/vendor/tree-sitter-proto/binding.gyp +30 -0
- package/vendor/tree-sitter-proto/bindings/node/binding.cc +20 -0
- package/vendor/tree-sitter-proto/bindings/node/index.d.ts +28 -0
- package/vendor/tree-sitter-proto/bindings/node/index.js +7 -0
- package/vendor/tree-sitter-proto/package.json +18 -0
- package/vendor/tree-sitter-proto/src/node-types.json +1145 -0
- package/vendor/tree-sitter-proto/src/parser.c +10149 -0
- package/vendor/tree-sitter-proto/src/tree_sitter/alloc.h +54 -0
- package/vendor/tree-sitter-proto/src/tree_sitter/array.h +291 -0
- package/vendor/tree-sitter-proto/src/tree_sitter/parser.h +266 -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
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - implicitImportWirer: all files in the same SPM target see each other
|
|
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 swiftConfig } from '../type-extractors/swift.js';
|
|
15
16
|
import { swiftExportChecker } from '../export-detection.js';
|
|
@@ -17,6 +18,8 @@ import { resolveSwiftImport } from '../import-resolvers/swift.js';
|
|
|
17
18
|
import { SWIFT_QUERIES } from '../tree-sitter-queries.js';
|
|
18
19
|
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
19
20
|
import { swiftConfig as swiftFieldConfig } from '../field-extractors/configs/swift.js';
|
|
21
|
+
import { createMethodExtractor } from '../method-extractors/generic.js';
|
|
22
|
+
import { swiftMethodConfig } from '../method-extractors/configs/swift.js';
|
|
20
23
|
/**
|
|
21
24
|
* Group Swift files by SPM target for implicit module visibility.
|
|
22
25
|
* If SwiftPackageConfig is available, use target -> directory mappings.
|
|
@@ -94,6 +97,14 @@ function wireSwiftImplicitImports(swiftFiles, importMap, addImportEdge, projectC
|
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
}
|
|
100
|
+
/** Swift init/deinit declarations have special names and Constructor label. */
|
|
101
|
+
const swiftExtractFunctionName = (node) => {
|
|
102
|
+
if (node.type === 'init_declaration')
|
|
103
|
+
return { funcName: 'init', label: 'Constructor' };
|
|
104
|
+
if (node.type === 'deinit_declaration')
|
|
105
|
+
return { funcName: 'deinit', label: 'Constructor' };
|
|
106
|
+
return null; // fall through to generic
|
|
107
|
+
};
|
|
97
108
|
const BUILT_INS = new Set([
|
|
98
109
|
'print',
|
|
99
110
|
'debugPrint',
|
|
@@ -213,6 +224,26 @@ export const swiftProvider = defineLanguage({
|
|
|
213
224
|
importSemantics: 'wildcard',
|
|
214
225
|
heritageDefaultEdge: 'IMPLEMENTS',
|
|
215
226
|
fieldExtractor: createFieldExtractor(swiftFieldConfig),
|
|
227
|
+
methodExtractor: createMethodExtractor({
|
|
228
|
+
...swiftMethodConfig,
|
|
229
|
+
extractFunctionName: swiftExtractFunctionName,
|
|
230
|
+
}),
|
|
231
|
+
classExtractor: createClassExtractor({
|
|
232
|
+
language: SupportedLanguages.Swift,
|
|
233
|
+
typeDeclarationNodes: ['class_declaration', 'protocol_declaration'],
|
|
234
|
+
ancestorScopeNodeTypes: ['class_declaration', 'protocol_declaration'],
|
|
235
|
+
extractType(node) {
|
|
236
|
+
if (node.type === 'protocol_declaration')
|
|
237
|
+
return 'Interface';
|
|
238
|
+
if (node.type !== 'class_declaration')
|
|
239
|
+
return undefined;
|
|
240
|
+
if (node.children.some((child) => child?.text === 'struct'))
|
|
241
|
+
return 'Struct';
|
|
242
|
+
if (node.children.some((child) => child?.text === 'enum'))
|
|
243
|
+
return 'Enum';
|
|
244
|
+
return 'Class';
|
|
245
|
+
},
|
|
246
|
+
}),
|
|
216
247
|
implicitImportWirer: wireSwiftImplicitImports,
|
|
217
248
|
builtInNames: BUILT_INS,
|
|
218
249
|
});
|
|
@@ -6,5 +6,6 @@
|
|
|
6
6
|
* (extractTsNamedBindings). They differ in file extensions, tree-sitter
|
|
7
7
|
* queries (TypeScript grammar has interface/type nodes), and language ID.
|
|
8
8
|
*/
|
|
9
|
+
export declare const BUILT_INS: ReadonlySet<string>;
|
|
9
10
|
export declare const typescriptProvider: import("../language-provider.js").LanguageProvider;
|
|
10
11
|
export declare const javascriptProvider: import("../language-provider.js").LanguageProvider;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
10
10
|
import { defineLanguage } from '../language-provider.js';
|
|
11
|
+
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
11
12
|
import { typeConfig as typescriptConfig } from '../type-extractors/typescript.js';
|
|
12
13
|
import { tsExportChecker } from '../export-detection.js';
|
|
13
14
|
import { resolveTypescriptImport, resolveJavascriptImport } from '../import-resolvers/standard.js';
|
|
@@ -18,7 +19,29 @@ import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
|
18
19
|
import { javascriptConfig } from '../field-extractors/configs/typescript-javascript.js';
|
|
19
20
|
import { createMethodExtractor } from '../method-extractors/generic.js';
|
|
20
21
|
import { typescriptMethodConfig, javascriptMethodConfig, } from '../method-extractors/configs/typescript-javascript.js';
|
|
21
|
-
|
|
22
|
+
/**
|
|
23
|
+
* TypeScript/JavaScript: arrow_function and function_expression get their name
|
|
24
|
+
* from the parent variable_declarator (e.g. `const foo = () => {}`).
|
|
25
|
+
*/
|
|
26
|
+
const tsExtractFunctionName = (node) => {
|
|
27
|
+
if (node.type !== 'arrow_function' && node.type !== 'function_expression')
|
|
28
|
+
return null;
|
|
29
|
+
const parent = node.parent;
|
|
30
|
+
if (parent?.type !== 'variable_declarator')
|
|
31
|
+
return null;
|
|
32
|
+
let nameNode = parent.childForFieldName?.('name');
|
|
33
|
+
if (!nameNode) {
|
|
34
|
+
for (let i = 0; i < parent.childCount; i++) {
|
|
35
|
+
const c = parent.child(i);
|
|
36
|
+
if (c?.type === 'identifier') {
|
|
37
|
+
nameNode = c;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { funcName: nameNode?.text ?? null, label: 'Function' };
|
|
43
|
+
};
|
|
44
|
+
export const BUILT_INS = new Set([
|
|
22
45
|
'console',
|
|
23
46
|
'log',
|
|
24
47
|
'warn',
|
|
@@ -114,6 +137,21 @@ const BUILT_INS = new Set([
|
|
|
114
137
|
'toString',
|
|
115
138
|
'valueOf',
|
|
116
139
|
]);
|
|
140
|
+
const tsJsClassConfig = {
|
|
141
|
+
language: SupportedLanguages.TypeScript,
|
|
142
|
+
typeDeclarationNodes: [
|
|
143
|
+
'class_declaration',
|
|
144
|
+
'abstract_class_declaration',
|
|
145
|
+
'interface_declaration',
|
|
146
|
+
'enum_declaration',
|
|
147
|
+
],
|
|
148
|
+
ancestorScopeNodeTypes: [
|
|
149
|
+
'class_declaration',
|
|
150
|
+
'abstract_class_declaration',
|
|
151
|
+
'interface_declaration',
|
|
152
|
+
'enum_declaration',
|
|
153
|
+
],
|
|
154
|
+
};
|
|
117
155
|
export const typescriptProvider = defineLanguage({
|
|
118
156
|
id: SupportedLanguages.TypeScript,
|
|
119
157
|
extensions: ['.ts', '.tsx'],
|
|
@@ -123,7 +161,11 @@ export const typescriptProvider = defineLanguage({
|
|
|
123
161
|
importResolver: resolveTypescriptImport,
|
|
124
162
|
namedBindingExtractor: extractTsNamedBindings,
|
|
125
163
|
fieldExtractor: typescriptFieldExtractor,
|
|
126
|
-
methodExtractor: createMethodExtractor(
|
|
164
|
+
methodExtractor: createMethodExtractor({
|
|
165
|
+
...typescriptMethodConfig,
|
|
166
|
+
extractFunctionName: tsExtractFunctionName,
|
|
167
|
+
}),
|
|
168
|
+
classExtractor: createClassExtractor(tsJsClassConfig),
|
|
127
169
|
builtInNames: BUILT_INS,
|
|
128
170
|
});
|
|
129
171
|
export const javascriptProvider = defineLanguage({
|
|
@@ -135,6 +177,13 @@ export const javascriptProvider = defineLanguage({
|
|
|
135
177
|
importResolver: resolveJavascriptImport,
|
|
136
178
|
namedBindingExtractor: extractTsNamedBindings,
|
|
137
179
|
fieldExtractor: createFieldExtractor(javascriptConfig),
|
|
138
|
-
methodExtractor: createMethodExtractor(
|
|
180
|
+
methodExtractor: createMethodExtractor({
|
|
181
|
+
...javascriptMethodConfig,
|
|
182
|
+
extractFunctionName: tsExtractFunctionName,
|
|
183
|
+
}),
|
|
184
|
+
classExtractor: createClassExtractor({
|
|
185
|
+
...tsJsClassConfig,
|
|
186
|
+
language: SupportedLanguages.JavaScript,
|
|
187
|
+
}),
|
|
139
188
|
builtInNames: BUILT_INS,
|
|
140
189
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue language provider.
|
|
3
|
+
*
|
|
4
|
+
* Vue SFCs are preprocessed by extracting the <script> / <script setup>
|
|
5
|
+
* block content, which is then parsed as TypeScript. This provider reuses
|
|
6
|
+
* nearly all TypeScript infrastructure — queries, type config, field
|
|
7
|
+
* extraction, and named binding extraction.
|
|
8
|
+
*
|
|
9
|
+
* Export detection for <script setup> is handled directly in the parse
|
|
10
|
+
* worker (all top-level bindings are implicitly exported). The export
|
|
11
|
+
* checker here is used as fallback for non-setup <script> blocks.
|
|
12
|
+
*/
|
|
13
|
+
export declare const vueProvider: import("../language-provider.js").LanguageProvider;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue language provider.
|
|
3
|
+
*
|
|
4
|
+
* Vue SFCs are preprocessed by extracting the <script> / <script setup>
|
|
5
|
+
* block content, which is then parsed as TypeScript. This provider reuses
|
|
6
|
+
* nearly all TypeScript infrastructure — queries, type config, field
|
|
7
|
+
* extraction, and named binding extraction.
|
|
8
|
+
*
|
|
9
|
+
* Export detection for <script setup> is handled directly in the parse
|
|
10
|
+
* worker (all top-level bindings are implicitly exported). The export
|
|
11
|
+
* checker here is used as fallback for non-setup <script> blocks.
|
|
12
|
+
*/
|
|
13
|
+
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
14
|
+
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
15
|
+
import { defineLanguage } from '../language-provider.js';
|
|
16
|
+
import { typeConfig as typescriptConfig } from '../type-extractors/typescript.js';
|
|
17
|
+
import { tsExportChecker } from '../export-detection.js';
|
|
18
|
+
import { resolveVueImport } from '../import-resolvers/vue.js';
|
|
19
|
+
import { extractTsNamedBindings } from '../named-bindings/typescript.js';
|
|
20
|
+
import { TYPESCRIPT_QUERIES } from '../tree-sitter-queries.js';
|
|
21
|
+
import { typescriptFieldExtractor } from '../field-extractors/typescript.js';
|
|
22
|
+
import { BUILT_INS as TS_BUILT_INS } from './typescript.js';
|
|
23
|
+
const VUE_SPECIFIC_BUILT_INS = [
|
|
24
|
+
'ref',
|
|
25
|
+
'reactive',
|
|
26
|
+
'computed',
|
|
27
|
+
'watch',
|
|
28
|
+
'watchEffect',
|
|
29
|
+
'onMounted',
|
|
30
|
+
'onUnmounted',
|
|
31
|
+
'onBeforeMount',
|
|
32
|
+
'onBeforeUnmount',
|
|
33
|
+
'onUpdated',
|
|
34
|
+
'onBeforeUpdate',
|
|
35
|
+
'nextTick',
|
|
36
|
+
'defineProps',
|
|
37
|
+
'defineEmits',
|
|
38
|
+
'defineExpose',
|
|
39
|
+
'defineOptions',
|
|
40
|
+
'defineSlots',
|
|
41
|
+
'defineModel',
|
|
42
|
+
'withDefaults',
|
|
43
|
+
'toRef',
|
|
44
|
+
'toRefs',
|
|
45
|
+
'unref',
|
|
46
|
+
'isRef',
|
|
47
|
+
'shallowRef',
|
|
48
|
+
'triggerRef',
|
|
49
|
+
'provide',
|
|
50
|
+
'inject',
|
|
51
|
+
'useSlots',
|
|
52
|
+
'useAttrs',
|
|
53
|
+
];
|
|
54
|
+
const VUE_BUILT_INS = new Set([...TS_BUILT_INS, ...VUE_SPECIFIC_BUILT_INS]);
|
|
55
|
+
const vueClassExtractor = createClassExtractor({
|
|
56
|
+
language: SupportedLanguages.Vue,
|
|
57
|
+
typeDeclarationNodes: [
|
|
58
|
+
'class_declaration',
|
|
59
|
+
'abstract_class_declaration',
|
|
60
|
+
'interface_declaration',
|
|
61
|
+
'enum_declaration',
|
|
62
|
+
],
|
|
63
|
+
ancestorScopeNodeTypes: [
|
|
64
|
+
'class_declaration',
|
|
65
|
+
'abstract_class_declaration',
|
|
66
|
+
'interface_declaration',
|
|
67
|
+
'enum_declaration',
|
|
68
|
+
],
|
|
69
|
+
});
|
|
70
|
+
export const vueProvider = defineLanguage({
|
|
71
|
+
id: SupportedLanguages.Vue,
|
|
72
|
+
extensions: ['.vue'],
|
|
73
|
+
treeSitterQueries: TYPESCRIPT_QUERIES,
|
|
74
|
+
typeConfig: typescriptConfig,
|
|
75
|
+
exportChecker: tsExportChecker,
|
|
76
|
+
importResolver: resolveVueImport,
|
|
77
|
+
namedBindingExtractor: extractTsNamedBindings,
|
|
78
|
+
fieldExtractor: typescriptFieldExtractor,
|
|
79
|
+
classExtractor: vueClassExtractor,
|
|
80
|
+
builtInNames: VUE_BUILT_INS,
|
|
81
|
+
});
|
|
@@ -10,7 +10,7 @@ interface MdFile {
|
|
|
10
10
|
path: string;
|
|
11
11
|
content: string;
|
|
12
12
|
}
|
|
13
|
-
export declare const processMarkdown: (graph: KnowledgeGraph, files: MdFile[], allPathSet:
|
|
13
|
+
export declare const processMarkdown: (graph: KnowledgeGraph, files: MdFile[], allPathSet: ReadonlySet<string>) => {
|
|
14
14
|
sections: number;
|
|
15
15
|
links: number;
|
|
16
16
|
};
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
// gitnexus/src/core/ingestion/method-extractors/configs/c-cpp.ts
|
|
2
|
+
// Verified against tree-sitter-cpp ^0.23.4
|
|
3
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
4
|
+
import { hasKeyword } from '../../field-extractors/configs/helpers.js';
|
|
5
|
+
import { extractSimpleTypeName } from '../../type-extractors/shared.js';
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// C/C++ helpers
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
/**
|
|
10
|
+
* Find the function_declarator inside a method node, handling pointer/reference
|
|
11
|
+
* return types where the function_declarator is nested inside a pointer_declarator
|
|
12
|
+
* or reference_declarator.
|
|
13
|
+
*/
|
|
14
|
+
function findFunctionDeclarator(node) {
|
|
15
|
+
const declarator = node.childForFieldName('declarator');
|
|
16
|
+
if (!declarator)
|
|
17
|
+
return null;
|
|
18
|
+
if (declarator.type === 'function_declarator')
|
|
19
|
+
return declarator;
|
|
20
|
+
// Recursively unwrap pointer_declarator / reference_declarator chains
|
|
21
|
+
// (e.g. int** (*pfn)() has pointer_declarator → pointer_declarator → function_declarator)
|
|
22
|
+
let current = declarator;
|
|
23
|
+
while (current) {
|
|
24
|
+
for (let i = 0; i < current.namedChildCount; i++) {
|
|
25
|
+
const child = current.namedChild(i);
|
|
26
|
+
if (child?.type === 'function_declarator')
|
|
27
|
+
return child;
|
|
28
|
+
}
|
|
29
|
+
// Go deeper into nested pointer/reference declarators
|
|
30
|
+
const next = current.namedChildren.find((c) => c.type === 'pointer_declarator' || c.type === 'reference_declarator');
|
|
31
|
+
current = next ?? null;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Detect `= delete` and `= default` special member function declarations.
|
|
37
|
+
* These are not callable methods and should be suppressed from extraction.
|
|
38
|
+
* tree-sitter-cpp ^0.23.4 emits `delete_method_clause` / `default_method_clause`
|
|
39
|
+
* as named children of the function_definition node.
|
|
40
|
+
*/
|
|
41
|
+
function isDeletedOrDefaulted(node) {
|
|
42
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
43
|
+
const child = node.namedChild(i);
|
|
44
|
+
if (child?.type === 'delete_method_clause' || child?.type === 'default_method_clause') {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Extract method name from a function_declarator.
|
|
52
|
+
* The name is the `declarator` field of the function_declarator — typically a
|
|
53
|
+
* field_identifier, but can be a destructor_name (~ClassName) or operator name.
|
|
54
|
+
*/
|
|
55
|
+
function extractCppMethodName(node) {
|
|
56
|
+
const funcDecl = findFunctionDeclarator(node);
|
|
57
|
+
if (!funcDecl)
|
|
58
|
+
return undefined;
|
|
59
|
+
// Suppress `= delete` and `= default` special members — these are not callable
|
|
60
|
+
// methods and should not appear in HAS_METHOD edges.
|
|
61
|
+
if (isDeletedOrDefaulted(node))
|
|
62
|
+
return undefined;
|
|
63
|
+
const nameNode = funcDecl.childForFieldName('declarator');
|
|
64
|
+
if (!nameNode)
|
|
65
|
+
return undefined;
|
|
66
|
+
// destructor_name: ~ClassName
|
|
67
|
+
if (nameNode.type === 'destructor_name')
|
|
68
|
+
return nameNode.text;
|
|
69
|
+
// operator_name: operator==, operator+, etc.
|
|
70
|
+
if (nameNode.type === 'operator_name')
|
|
71
|
+
return nameNode.text;
|
|
72
|
+
return nameNode.text;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Extract return type from the `type` field of the method node.
|
|
76
|
+
* tree-sitter-cpp puts the return type as the `type` field on field_declaration
|
|
77
|
+
* and function_definition nodes.
|
|
78
|
+
*/
|
|
79
|
+
function extractCppReturnType(node) {
|
|
80
|
+
const typeNode = node.childForFieldName('type');
|
|
81
|
+
if (typeNode) {
|
|
82
|
+
const typeText = typeNode.text?.trim();
|
|
83
|
+
// C++11 trailing return type: `auto foo() -> ReturnType`
|
|
84
|
+
// When the declared type is `auto`, check for a trailing_return_type on the
|
|
85
|
+
// function_declarator which holds the actual return type.
|
|
86
|
+
if (typeText === 'auto') {
|
|
87
|
+
const funcDecl = findFunctionDeclarator(node);
|
|
88
|
+
if (funcDecl) {
|
|
89
|
+
for (let i = 0; i < funcDecl.namedChildCount; i++) {
|
|
90
|
+
const child = funcDecl.namedChild(i);
|
|
91
|
+
if (child?.type === 'trailing_return_type') {
|
|
92
|
+
// trailing_return_type contains a type_descriptor with the real type
|
|
93
|
+
const typeDesc = child.firstNamedChild;
|
|
94
|
+
if (typeDesc)
|
|
95
|
+
return typeDesc.text?.trim();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return typeText;
|
|
101
|
+
}
|
|
102
|
+
// Fallback: first type-like named child (for declarations without type field)
|
|
103
|
+
const first = node.firstNamedChild;
|
|
104
|
+
if (first &&
|
|
105
|
+
(first.type === 'primitive_type' ||
|
|
106
|
+
first.type === 'type_identifier' ||
|
|
107
|
+
first.type === 'sized_type_specifier' ||
|
|
108
|
+
first.type === 'template_type')) {
|
|
109
|
+
return first.text?.trim();
|
|
110
|
+
}
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Extract parameters from the parameter_list inside the function_declarator.
|
|
115
|
+
*
|
|
116
|
+
* C/C++ uses parameter_declaration (required) and optional_parameter_declaration
|
|
117
|
+
* (with default value). Variadic `...` appears as a variadic_parameter_declaration.
|
|
118
|
+
*/
|
|
119
|
+
function extractCppParameters(node) {
|
|
120
|
+
const funcDecl = findFunctionDeclarator(node);
|
|
121
|
+
if (!funcDecl)
|
|
122
|
+
return [];
|
|
123
|
+
const paramList = funcDecl.childForFieldName('parameters');
|
|
124
|
+
if (!paramList)
|
|
125
|
+
return [];
|
|
126
|
+
const params = [];
|
|
127
|
+
for (let i = 0; i < paramList.namedChildCount; i++) {
|
|
128
|
+
const param = paramList.namedChild(i);
|
|
129
|
+
if (!param)
|
|
130
|
+
continue;
|
|
131
|
+
switch (param.type) {
|
|
132
|
+
case 'parameter_declaration': {
|
|
133
|
+
const typeNode = param.childForFieldName('type');
|
|
134
|
+
const declNode = param.childForFieldName('declarator');
|
|
135
|
+
// Extract name — may be wrapped in pointer_declarator or reference_declarator
|
|
136
|
+
const name = extractParamName(declNode);
|
|
137
|
+
params.push({
|
|
138
|
+
name: name ?? typeNode?.text?.trim() ?? '?',
|
|
139
|
+
type: typeNode
|
|
140
|
+
? (extractSimpleTypeName(typeNode) ?? typeNode.text?.trim() ?? null)
|
|
141
|
+
: null,
|
|
142
|
+
rawType: typeNode?.text?.trim() ?? null,
|
|
143
|
+
isOptional: false,
|
|
144
|
+
isVariadic: false,
|
|
145
|
+
});
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
case 'optional_parameter_declaration': {
|
|
149
|
+
const typeNode = param.childForFieldName('type');
|
|
150
|
+
const declNode = param.childForFieldName('declarator');
|
|
151
|
+
const name = extractParamName(declNode);
|
|
152
|
+
params.push({
|
|
153
|
+
name: name ?? typeNode?.text?.trim() ?? '?',
|
|
154
|
+
type: typeNode
|
|
155
|
+
? (extractSimpleTypeName(typeNode) ?? typeNode.text?.trim() ?? null)
|
|
156
|
+
: null,
|
|
157
|
+
rawType: typeNode?.text?.trim() ?? null,
|
|
158
|
+
isOptional: true,
|
|
159
|
+
isVariadic: false,
|
|
160
|
+
});
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
case 'variadic_parameter_declaration': {
|
|
164
|
+
// C-style `...` or typed variadic `T... args`
|
|
165
|
+
const typeNode = param.childForFieldName('type');
|
|
166
|
+
const declNode = param.childForFieldName('declarator');
|
|
167
|
+
const name = extractParamName(declNode);
|
|
168
|
+
params.push({
|
|
169
|
+
name: name ?? '...',
|
|
170
|
+
type: typeNode
|
|
171
|
+
? (extractSimpleTypeName(typeNode) ?? typeNode.text?.trim() ?? null)
|
|
172
|
+
: null,
|
|
173
|
+
rawType: typeNode?.text?.trim() ?? null,
|
|
174
|
+
isOptional: false,
|
|
175
|
+
isVariadic: true,
|
|
176
|
+
});
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case 'variadic_parameter': {
|
|
180
|
+
// Bare `...` (C-style)
|
|
181
|
+
params.push({
|
|
182
|
+
name: '...',
|
|
183
|
+
type: null,
|
|
184
|
+
rawType: null,
|
|
185
|
+
isOptional: false,
|
|
186
|
+
isVariadic: true,
|
|
187
|
+
});
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// C/C++: bare `...` token in parameter list is an unnamed child (not a named node).
|
|
193
|
+
// Check all children for the unnamed `...` token when no variadic was detected above.
|
|
194
|
+
if (!params.some((p) => p.isVariadic)) {
|
|
195
|
+
for (let i = 0; i < paramList.childCount; i++) {
|
|
196
|
+
const child = paramList.child(i);
|
|
197
|
+
if (child && !child.isNamed && child.text === '...') {
|
|
198
|
+
params.push({
|
|
199
|
+
name: '...',
|
|
200
|
+
type: null,
|
|
201
|
+
rawType: null,
|
|
202
|
+
isOptional: false,
|
|
203
|
+
isVariadic: true,
|
|
204
|
+
});
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return params;
|
|
210
|
+
}
|
|
211
|
+
/** Extract parameter name, recursively unwrapping pointer/reference declarators. */
|
|
212
|
+
function extractParamName(declNode) {
|
|
213
|
+
if (!declNode)
|
|
214
|
+
return undefined;
|
|
215
|
+
if (declNode.type === 'identifier')
|
|
216
|
+
return declNode.text;
|
|
217
|
+
// Recursively unwrap pointer_declarator / reference_declarator chains (e.g. int** ptr)
|
|
218
|
+
for (let i = 0; i < declNode.namedChildCount; i++) {
|
|
219
|
+
const child = declNode.namedChild(i);
|
|
220
|
+
if (!child)
|
|
221
|
+
continue;
|
|
222
|
+
if (child.type === 'identifier')
|
|
223
|
+
return child.text;
|
|
224
|
+
if (child.type === 'pointer_declarator' || child.type === 'reference_declarator') {
|
|
225
|
+
return extractParamName(child);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Detect C++ access specifier by walking backwards through siblings.
|
|
232
|
+
* Mirrors the field extractor pattern in c-cpp.ts.
|
|
233
|
+
*/
|
|
234
|
+
function extractCppVisibility(node) {
|
|
235
|
+
// If this node was unwrapped from a template_declaration, the access_specifier
|
|
236
|
+
// is a sibling of the template_declaration in field_declaration_list, not of
|
|
237
|
+
// this node — climb up one level before walking backward.
|
|
238
|
+
const startNode = node.parent?.type === 'template_declaration' ? node.parent : node;
|
|
239
|
+
let sibling = startNode.previousNamedSibling;
|
|
240
|
+
while (sibling) {
|
|
241
|
+
if (sibling.type === 'access_specifier') {
|
|
242
|
+
const text = sibling.text.replace(':', '').trim();
|
|
243
|
+
if (text === 'public' || text === 'private' || text === 'protected')
|
|
244
|
+
return text;
|
|
245
|
+
}
|
|
246
|
+
sibling = sibling.previousNamedSibling;
|
|
247
|
+
}
|
|
248
|
+
// Default: struct/union = public, class = private
|
|
249
|
+
const parent = startNode.parent?.parent;
|
|
250
|
+
return parent?.type === 'struct_specifier' || parent?.type === 'union_specifier'
|
|
251
|
+
? 'public'
|
|
252
|
+
: 'private';
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Detect pure virtual methods (`= 0`).
|
|
256
|
+
* tree-sitter-cpp emits `=` (unnamed) followed by `number_literal` with text `0`.
|
|
257
|
+
*/
|
|
258
|
+
function isPureVirtual(node) {
|
|
259
|
+
let foundEquals = false;
|
|
260
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
261
|
+
const child = node.child(i);
|
|
262
|
+
if (!child)
|
|
263
|
+
continue;
|
|
264
|
+
if (child.text === '=') {
|
|
265
|
+
foundEquals = true;
|
|
266
|
+
}
|
|
267
|
+
else if (foundEquals && child.type === 'number_literal' && child.text === '0') {
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
else if (foundEquals) {
|
|
271
|
+
foundEquals = false; // Reset if something else follows `=`
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Check for a virtual_specifier ('final' or 'override') inside the function_declarator.
|
|
278
|
+
* In tree-sitter-cpp, these are named children of the function_declarator, not the
|
|
279
|
+
* method node itself.
|
|
280
|
+
*/
|
|
281
|
+
function hasVirtualSpecifier(node, keyword) {
|
|
282
|
+
const funcDecl = findFunctionDeclarator(node);
|
|
283
|
+
if (!funcDecl)
|
|
284
|
+
return false;
|
|
285
|
+
for (let i = 0; i < funcDecl.namedChildCount; i++) {
|
|
286
|
+
const child = funcDecl.namedChild(i);
|
|
287
|
+
if (child?.type === 'virtual_specifier' && child.text === keyword)
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
// ---------------------------------------------------------------------------
|
|
293
|
+
// C++ config
|
|
294
|
+
// ---------------------------------------------------------------------------
|
|
295
|
+
// C++ methods appear as field_declaration (declarations) or function_definition
|
|
296
|
+
// (inline definitions) inside field_declaration_list. The generic extractor
|
|
297
|
+
// iterates bodyNodeTypes children and matches against methodNodeTypes.
|
|
298
|
+
//
|
|
299
|
+
// Key difference from TS/JVM/C#: C++ has no dedicated method_declaration node.
|
|
300
|
+
// A field_declaration is a method if it contains a function_declarator.
|
|
301
|
+
// The generic extractor calls extractName() on every methodNodeType node — if
|
|
302
|
+
// extractName returns undefined (no function_declarator), the method is skipped.
|
|
303
|
+
//
|
|
304
|
+
// Known gaps:
|
|
305
|
+
// - Out-of-class method definitions (void Foo::bar() {}) are not linked as
|
|
306
|
+
// HAS_METHOD — they appear as top-level function_definition nodes.
|
|
307
|
+
// This includes namespace-wrapped and nested classes.
|
|
308
|
+
// - Friend declarations are not extracted.
|
|
309
|
+
// - Template method declarations with explicit specialization.
|
|
310
|
+
// - const-qualified method overloads (e.g. begin() vs begin() const) are
|
|
311
|
+
// disambiguated via isConst flag and $const ID suffix.
|
|
312
|
+
export const cppMethodConfig = {
|
|
313
|
+
language: SupportedLanguages.CPlusPlus,
|
|
314
|
+
typeDeclarationNodes: ['class_specifier', 'struct_specifier', 'union_specifier'],
|
|
315
|
+
// declaration covers constructors/destructors; field_declaration covers method
|
|
316
|
+
// declarations; function_definition covers inline method definitions.
|
|
317
|
+
// Non-method declarations (variables, typedefs) are filtered by extractName
|
|
318
|
+
// returning undefined when no function_declarator is found.
|
|
319
|
+
methodNodeTypes: ['field_declaration', 'function_definition', 'declaration'],
|
|
320
|
+
bodyNodeTypes: ['field_declaration_list'],
|
|
321
|
+
extractName: extractCppMethodName,
|
|
322
|
+
extractReturnType: extractCppReturnType,
|
|
323
|
+
extractParameters: extractCppParameters,
|
|
324
|
+
extractVisibility: extractCppVisibility,
|
|
325
|
+
isStatic(node) {
|
|
326
|
+
return hasKeyword(node, 'static');
|
|
327
|
+
},
|
|
328
|
+
isAbstract(node) {
|
|
329
|
+
return isPureVirtual(node);
|
|
330
|
+
},
|
|
331
|
+
isFinal(node) {
|
|
332
|
+
return hasVirtualSpecifier(node, 'final');
|
|
333
|
+
},
|
|
334
|
+
isVirtual(node) {
|
|
335
|
+
// In C++, override and method-level final are only legal on virtual functions,
|
|
336
|
+
// so they imply virtual even without the explicit keyword.
|
|
337
|
+
return (hasKeyword(node, 'virtual') ||
|
|
338
|
+
hasVirtualSpecifier(node, 'override') ||
|
|
339
|
+
hasVirtualSpecifier(node, 'final'));
|
|
340
|
+
},
|
|
341
|
+
isOverride(node) {
|
|
342
|
+
return hasVirtualSpecifier(node, 'override');
|
|
343
|
+
},
|
|
344
|
+
isConst(node) {
|
|
345
|
+
// const qualifier appears as a type_qualifier child of function_declarator,
|
|
346
|
+
// after the parameter_list: e.g. `int size() const` → funcDecl has
|
|
347
|
+
// type_qualifier child with text "const". Not to be confused with return-type
|
|
348
|
+
// const (e.g. `const int& begin()`) which is at a different AST level.
|
|
349
|
+
const funcDecl = findFunctionDeclarator(node);
|
|
350
|
+
if (!funcDecl)
|
|
351
|
+
return false;
|
|
352
|
+
for (let i = 0; i < funcDecl.namedChildCount; i++) {
|
|
353
|
+
const child = funcDecl.namedChild(i);
|
|
354
|
+
if (child?.type === 'type_qualifier' && child.text === 'const')
|
|
355
|
+
return true;
|
|
356
|
+
}
|
|
357
|
+
return false;
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
// ---------------------------------------------------------------------------
|
|
361
|
+
// C config (minimal — C has no classes/methods, only struct function pointers)
|
|
362
|
+
// Verified against tree-sitter-c 0.23.2
|
|
363
|
+
// ---------------------------------------------------------------------------
|
|
364
|
+
// C does not have methods in the OOP sense. Structs with function pointer fields
|
|
365
|
+
// are handled by the field extractor. This config exists for completeness but
|
|
366
|
+
// will rarely match since C structs don't contain function_definition nodes.
|
|
367
|
+
export const cMethodConfig = {
|
|
368
|
+
language: SupportedLanguages.C,
|
|
369
|
+
typeDeclarationNodes: ['struct_specifier'],
|
|
370
|
+
methodNodeTypes: ['function_definition'],
|
|
371
|
+
bodyNodeTypes: ['field_declaration_list'],
|
|
372
|
+
extractName: extractCppMethodName,
|
|
373
|
+
extractReturnType: extractCppReturnType,
|
|
374
|
+
extractParameters: extractCppParameters,
|
|
375
|
+
extractVisibility() {
|
|
376
|
+
return 'public'; // C has no access control
|
|
377
|
+
},
|
|
378
|
+
isStatic(node) {
|
|
379
|
+
return hasKeyword(node, 'static');
|
|
380
|
+
},
|
|
381
|
+
isAbstract() {
|
|
382
|
+
return false; // C has no virtual/abstract
|
|
383
|
+
},
|
|
384
|
+
isFinal() {
|
|
385
|
+
return false;
|
|
386
|
+
},
|
|
387
|
+
};
|