driftdetect-core 0.5.0 → 0.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/dist/boundaries/types.d.ts +1 -1
- package/dist/boundaries/types.d.ts.map +1 -1
- package/dist/call-graph/analysis/graph-builder.d.ts.map +1 -1
- package/dist/call-graph/analysis/graph-builder.js +1 -0
- package/dist/call-graph/analysis/graph-builder.js.map +1 -1
- package/dist/call-graph/extractors/go-data-access-extractor.d.ts +80 -0
- package/dist/call-graph/extractors/go-data-access-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/go-data-access-extractor.js +457 -0
- package/dist/call-graph/extractors/go-data-access-extractor.js.map +1 -0
- package/dist/call-graph/extractors/go-extractor.d.ts +103 -0
- package/dist/call-graph/extractors/go-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/go-extractor.js +509 -0
- package/dist/call-graph/extractors/go-extractor.js.map +1 -0
- package/dist/call-graph/extractors/go-hybrid-extractor.d.ts +97 -0
- package/dist/call-graph/extractors/go-hybrid-extractor.d.ts.map +1 -0
- package/dist/call-graph/extractors/go-hybrid-extractor.js +496 -0
- package/dist/call-graph/extractors/go-hybrid-extractor.js.map +1 -0
- package/dist/call-graph/extractors/regex/go-regex.d.ts +51 -0
- package/dist/call-graph/extractors/regex/go-regex.d.ts.map +1 -0
- package/dist/call-graph/extractors/regex/go-regex.js +435 -0
- package/dist/call-graph/extractors/regex/go-regex.js.map +1 -0
- package/dist/call-graph/extractors/regex/index.d.ts +1 -0
- package/dist/call-graph/extractors/regex/index.d.ts.map +1 -1
- package/dist/call-graph/extractors/regex/index.js +8 -0
- package/dist/call-graph/extractors/regex/index.js.map +1 -1
- package/dist/call-graph/index.d.ts +3 -0
- package/dist/call-graph/index.d.ts.map +1 -1
- package/dist/call-graph/index.js +5 -0
- package/dist/call-graph/index.js.map +1 -1
- package/dist/call-graph/types.d.ts +1 -1
- package/dist/call-graph/types.d.ts.map +1 -1
- package/dist/constraints/extraction/constraint-synthesizer.d.ts +72 -0
- package/dist/constraints/extraction/constraint-synthesizer.d.ts.map +1 -0
- package/dist/constraints/extraction/constraint-synthesizer.js +336 -0
- package/dist/constraints/extraction/constraint-synthesizer.js.map +1 -0
- package/dist/constraints/extraction/index.d.ts +10 -0
- package/dist/constraints/extraction/index.d.ts.map +1 -0
- package/dist/constraints/extraction/index.js +10 -0
- package/dist/constraints/extraction/index.js.map +1 -0
- package/dist/constraints/extraction/invariant-detector.d.ts +109 -0
- package/dist/constraints/extraction/invariant-detector.d.ts.map +1 -0
- package/dist/constraints/extraction/invariant-detector.js +979 -0
- package/dist/constraints/extraction/invariant-detector.js.map +1 -0
- package/dist/constraints/index.d.ts +15 -0
- package/dist/constraints/index.d.ts.map +1 -0
- package/dist/constraints/index.js +16 -0
- package/dist/constraints/index.js.map +1 -0
- package/dist/constraints/store/constraint-store.d.ts +110 -0
- package/dist/constraints/store/constraint-store.d.ts.map +1 -0
- package/dist/constraints/store/constraint-store.js +584 -0
- package/dist/constraints/store/constraint-store.js.map +1 -0
- package/dist/constraints/types.d.ts +605 -0
- package/dist/constraints/types.d.ts.map +1 -0
- package/dist/constraints/types.js +57 -0
- package/dist/constraints/types.js.map +1 -0
- package/dist/constraints/verification/constraint-verifier.d.ts +100 -0
- package/dist/constraints/verification/constraint-verifier.d.ts.map +1 -0
- package/dist/constraints/verification/constraint-verifier.js +638 -0
- package/dist/constraints/verification/constraint-verifier.js.map +1 -0
- package/dist/constraints/verification/index.d.ts +8 -0
- package/dist/constraints/verification/index.d.ts.map +1 -0
- package/dist/constraints/verification/index.js +8 -0
- package/dist/constraints/verification/index.js.map +1 -0
- package/dist/decisions/analyzer/decision-mining-analyzer.d.ts +121 -0
- package/dist/decisions/analyzer/decision-mining-analyzer.d.ts.map +1 -0
- package/dist/decisions/analyzer/decision-mining-analyzer.js +904 -0
- package/dist/decisions/analyzer/decision-mining-analyzer.js.map +1 -0
- package/dist/decisions/analyzer/index.d.ts +5 -0
- package/dist/decisions/analyzer/index.d.ts.map +1 -0
- package/dist/decisions/analyzer/index.js +5 -0
- package/dist/decisions/analyzer/index.js.map +1 -0
- package/dist/decisions/extractors/base-commit-extractor.d.ts +104 -0
- package/dist/decisions/extractors/base-commit-extractor.d.ts.map +1 -0
- package/dist/decisions/extractors/base-commit-extractor.js +305 -0
- package/dist/decisions/extractors/base-commit-extractor.js.map +1 -0
- package/dist/decisions/extractors/csharp-commit-extractor.d.ts +18 -0
- package/dist/decisions/extractors/csharp-commit-extractor.d.ts.map +1 -0
- package/dist/decisions/extractors/csharp-commit-extractor.js +281 -0
- package/dist/decisions/extractors/csharp-commit-extractor.js.map +1 -0
- package/dist/decisions/extractors/index.d.ts +31 -0
- package/dist/decisions/extractors/index.d.ts.map +1 -0
- package/dist/decisions/extractors/index.js +63 -0
- package/dist/decisions/extractors/index.js.map +1 -0
- package/dist/decisions/extractors/java-commit-extractor.d.ts +18 -0
- package/dist/decisions/extractors/java-commit-extractor.d.ts.map +1 -0
- package/dist/decisions/extractors/java-commit-extractor.js +248 -0
- package/dist/decisions/extractors/java-commit-extractor.js.map +1 -0
- package/dist/decisions/extractors/php-commit-extractor.d.ts +18 -0
- package/dist/decisions/extractors/php-commit-extractor.d.ts.map +1 -0
- package/dist/decisions/extractors/php-commit-extractor.js +280 -0
- package/dist/decisions/extractors/php-commit-extractor.js.map +1 -0
- package/dist/decisions/extractors/python-commit-extractor.d.ts +18 -0
- package/dist/decisions/extractors/python-commit-extractor.d.ts.map +1 -0
- package/dist/decisions/extractors/python-commit-extractor.js +248 -0
- package/dist/decisions/extractors/python-commit-extractor.js.map +1 -0
- package/dist/decisions/extractors/typescript-commit-extractor.d.ts +37 -0
- package/dist/decisions/extractors/typescript-commit-extractor.d.ts.map +1 -0
- package/dist/decisions/extractors/typescript-commit-extractor.js +229 -0
- package/dist/decisions/extractors/typescript-commit-extractor.js.map +1 -0
- package/dist/decisions/git/commit-parser.d.ts +58 -0
- package/dist/decisions/git/commit-parser.d.ts.map +1 -0
- package/dist/decisions/git/commit-parser.js +344 -0
- package/dist/decisions/git/commit-parser.js.map +1 -0
- package/dist/decisions/git/diff-analyzer.d.ts +30 -0
- package/dist/decisions/git/diff-analyzer.d.ts.map +1 -0
- package/dist/decisions/git/diff-analyzer.js +492 -0
- package/dist/decisions/git/diff-analyzer.js.map +1 -0
- package/dist/decisions/git/git-walker.d.ts +64 -0
- package/dist/decisions/git/git-walker.d.ts.map +1 -0
- package/dist/decisions/git/git-walker.js +441 -0
- package/dist/decisions/git/git-walker.js.map +1 -0
- package/dist/decisions/git/index.d.ts +11 -0
- package/dist/decisions/git/index.d.ts.map +1 -0
- package/dist/decisions/git/index.js +13 -0
- package/dist/decisions/git/index.js.map +1 -0
- package/dist/decisions/git/types.d.ts +223 -0
- package/dist/decisions/git/types.d.ts.map +1 -0
- package/dist/decisions/git/types.js +7 -0
- package/dist/decisions/git/types.js.map +1 -0
- package/dist/decisions/index.d.ts +27 -0
- package/dist/decisions/index.d.ts.map +1 -0
- package/dist/decisions/index.js +45 -0
- package/dist/decisions/index.js.map +1 -0
- package/dist/decisions/types.d.ts +530 -0
- package/dist/decisions/types.d.ts.map +1 -0
- package/dist/decisions/types.js +8 -0
- package/dist/decisions/types.js.map +1 -0
- package/dist/go/go-analyzer.d.ts +203 -0
- package/dist/go/go-analyzer.d.ts.map +1 -0
- package/dist/go/go-analyzer.js +509 -0
- package/dist/go/go-analyzer.js.map +1 -0
- package/dist/go/index.d.ts +7 -0
- package/dist/go/index.d.ts.map +1 -0
- package/dist/go/index.js +8 -0
- package/dist/go/index.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -1
- package/dist/parsers/tree-sitter/go-loader.d.ts +50 -0
- package/dist/parsers/tree-sitter/go-loader.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/go-loader.js +161 -0
- package/dist/parsers/tree-sitter/go-loader.js.map +1 -0
- package/dist/parsers/tree-sitter/tree-sitter-go-parser.d.ts +250 -0
- package/dist/parsers/tree-sitter/tree-sitter-go-parser.d.ts.map +1 -0
- package/dist/parsers/tree-sitter/tree-sitter-go-parser.js +707 -0
- package/dist/parsers/tree-sitter/tree-sitter-go-parser.js.map +1 -0
- package/dist/parsers/types.d.ts +1 -1
- package/dist/parsers/types.d.ts.map +1 -1
- package/dist/simulation/approach-generator.d.ts +73 -0
- package/dist/simulation/approach-generator.d.ts.map +1 -0
- package/dist/simulation/approach-generator.js +371 -0
- package/dist/simulation/approach-generator.js.map +1 -0
- package/dist/simulation/index.d.ts +14 -0
- package/dist/simulation/index.d.ts.map +1 -0
- package/dist/simulation/index.js +19 -0
- package/dist/simulation/index.js.map +1 -0
- package/dist/simulation/language-strategies/csharp-strategies.d.ts +17 -0
- package/dist/simulation/language-strategies/csharp-strategies.d.ts.map +1 -0
- package/dist/simulation/language-strategies/csharp-strategies.js +118 -0
- package/dist/simulation/language-strategies/csharp-strategies.js.map +1 -0
- package/dist/simulation/language-strategies/index.d.ts +41 -0
- package/dist/simulation/language-strategies/index.d.ts.map +1 -0
- package/dist/simulation/language-strategies/index.js +92 -0
- package/dist/simulation/language-strategies/index.js.map +1 -0
- package/dist/simulation/language-strategies/java-strategies.d.ts +17 -0
- package/dist/simulation/language-strategies/java-strategies.d.ts.map +1 -0
- package/dist/simulation/language-strategies/java-strategies.js +119 -0
- package/dist/simulation/language-strategies/java-strategies.js.map +1 -0
- package/dist/simulation/language-strategies/php-strategies.d.ts +17 -0
- package/dist/simulation/language-strategies/php-strategies.d.ts.map +1 -0
- package/dist/simulation/language-strategies/php-strategies.js +129 -0
- package/dist/simulation/language-strategies/php-strategies.js.map +1 -0
- package/dist/simulation/language-strategies/python-strategies.d.ts +17 -0
- package/dist/simulation/language-strategies/python-strategies.d.ts.map +1 -0
- package/dist/simulation/language-strategies/python-strategies.js +208 -0
- package/dist/simulation/language-strategies/python-strategies.js.map +1 -0
- package/dist/simulation/language-strategies/types.d.ts +67 -0
- package/dist/simulation/language-strategies/types.d.ts.map +1 -0
- package/dist/simulation/language-strategies/types.js +23 -0
- package/dist/simulation/language-strategies/types.js.map +1 -0
- package/dist/simulation/language-strategies/typescript-strategies.d.ts +17 -0
- package/dist/simulation/language-strategies/typescript-strategies.d.ts.map +1 -0
- package/dist/simulation/language-strategies/typescript-strategies.js +251 -0
- package/dist/simulation/language-strategies/typescript-strategies.js.map +1 -0
- package/dist/simulation/scorers/friction-scorer.d.ts +45 -0
- package/dist/simulation/scorers/friction-scorer.d.ts.map +1 -0
- package/dist/simulation/scorers/friction-scorer.js +336 -0
- package/dist/simulation/scorers/friction-scorer.js.map +1 -0
- package/dist/simulation/scorers/impact-scorer.d.ts +56 -0
- package/dist/simulation/scorers/impact-scorer.d.ts.map +1 -0
- package/dist/simulation/scorers/impact-scorer.js +273 -0
- package/dist/simulation/scorers/impact-scorer.js.map +1 -0
- package/dist/simulation/scorers/index.d.ts +12 -0
- package/dist/simulation/scorers/index.d.ts.map +1 -0
- package/dist/simulation/scorers/index.js +12 -0
- package/dist/simulation/scorers/index.js.map +1 -0
- package/dist/simulation/scorers/pattern-alignment-scorer.d.ts +83 -0
- package/dist/simulation/scorers/pattern-alignment-scorer.d.ts.map +1 -0
- package/dist/simulation/scorers/pattern-alignment-scorer.js +367 -0
- package/dist/simulation/scorers/pattern-alignment-scorer.js.map +1 -0
- package/dist/simulation/scorers/security-scorer.d.ts +63 -0
- package/dist/simulation/scorers/security-scorer.d.ts.map +1 -0
- package/dist/simulation/scorers/security-scorer.js +346 -0
- package/dist/simulation/scorers/security-scorer.js.map +1 -0
- package/dist/simulation/simulation-engine.d.ts +89 -0
- package/dist/simulation/simulation-engine.d.ts.map +1 -0
- package/dist/simulation/simulation-engine.js +480 -0
- package/dist/simulation/simulation-engine.js.map +1 -0
- package/dist/simulation/types.d.ts +200 -0
- package/dist/simulation/types.d.ts.map +1 -0
- package/dist/simulation/types.js +23 -0
- package/dist/simulation/types.js.map +1 -0
- package/dist/speculative/approach-generator.d.ts +2 -0
- package/dist/speculative/approach-generator.d.ts.map +1 -0
- package/dist/speculative/approach-generator.js +2 -0
- package/dist/speculative/approach-generator.js.map +1 -0
- package/dist/speculative/templates/types.d.ts +133 -0
- package/dist/speculative/templates/types.d.ts.map +1 -0
- package/dist/speculative/templates/types.js +208 -0
- package/dist/speculative/templates/types.js.map +1 -0
- package/dist/speculative/types.d.ts +523 -0
- package/dist/speculative/types.d.ts.map +1 -0
- package/dist/speculative/types.js +71 -0
- package/dist/speculative/types.js.map +1 -0
- package/dist/test-topology/extractors/base-test-extractor.d.ts +1 -1
- package/dist/test-topology/extractors/base-test-extractor.d.ts.map +1 -1
- package/dist/test-topology/extractors/base-test-extractor.js.map +1 -1
- package/dist/test-topology/extractors/go-test-extractor.d.ts +33 -0
- package/dist/test-topology/extractors/go-test-extractor.d.ts.map +1 -0
- package/dist/test-topology/extractors/go-test-extractor.js +436 -0
- package/dist/test-topology/extractors/go-test-extractor.js.map +1 -0
- package/dist/test-topology/extractors/index.d.ts +1 -0
- package/dist/test-topology/extractors/index.d.ts.map +1 -1
- package/dist/test-topology/extractors/index.js +1 -0
- package/dist/test-topology/extractors/index.js.map +1 -1
- package/dist/test-topology/extractors/regex/go-test-regex.d.ts +62 -0
- package/dist/test-topology/extractors/regex/go-test-regex.d.ts.map +1 -0
- package/dist/test-topology/extractors/regex/go-test-regex.js +528 -0
- package/dist/test-topology/extractors/regex/go-test-regex.js.map +1 -0
- package/dist/test-topology/extractors/regex/index.d.ts +1 -0
- package/dist/test-topology/extractors/regex/index.d.ts.map +1 -1
- package/dist/test-topology/extractors/regex/index.js +4 -0
- package/dist/test-topology/extractors/regex/index.js.map +1 -1
- package/dist/test-topology/hybrid-test-topology-analyzer.d.ts.map +1 -1
- package/dist/test-topology/hybrid-test-topology-analyzer.js +1 -0
- package/dist/test-topology/hybrid-test-topology-analyzer.js.map +1 -1
- package/dist/test-topology/test-topology-analyzer.d.ts.map +1 -1
- package/dist/test-topology/test-topology-analyzer.js +1 -0
- package/dist/test-topology/test-topology-analyzer.js.map +1 -1
- package/dist/test-topology/types.d.ts +2 -2
- package/dist/test-topology/types.d.ts.map +1 -1
- package/dist/unified-provider/matching/database-sql-matcher.d.ts +42 -0
- package/dist/unified-provider/matching/database-sql-matcher.d.ts.map +1 -0
- package/dist/unified-provider/matching/database-sql-matcher.js +282 -0
- package/dist/unified-provider/matching/database-sql-matcher.js.map +1 -0
- package/dist/unified-provider/matching/gorm-matcher.d.ts +41 -0
- package/dist/unified-provider/matching/gorm-matcher.d.ts.map +1 -0
- package/dist/unified-provider/matching/gorm-matcher.js +222 -0
- package/dist/unified-provider/matching/gorm-matcher.js.map +1 -0
- package/dist/unified-provider/matching/index.d.ts +3 -0
- package/dist/unified-provider/matching/index.d.ts.map +1 -1
- package/dist/unified-provider/matching/index.js +4 -0
- package/dist/unified-provider/matching/index.js.map +1 -1
- package/dist/unified-provider/matching/matcher-registry.d.ts.map +1 -1
- package/dist/unified-provider/matching/matcher-registry.js +7 -0
- package/dist/unified-provider/matching/matcher-registry.js.map +1 -1
- package/dist/unified-provider/matching/sqlx-matcher.d.ts +40 -0
- package/dist/unified-provider/matching/sqlx-matcher.d.ts.map +1 -0
- package/dist/unified-provider/matching/sqlx-matcher.js +214 -0
- package/dist/unified-provider/matching/sqlx-matcher.js.map +1 -0
- package/dist/unified-provider/normalization/go-normalizer.d.ts +62 -0
- package/dist/unified-provider/normalization/go-normalizer.d.ts.map +1 -0
- package/dist/unified-provider/normalization/go-normalizer.js +608 -0
- package/dist/unified-provider/normalization/go-normalizer.js.map +1 -0
- package/dist/unified-provider/normalization/index.d.ts +1 -0
- package/dist/unified-provider/normalization/index.d.ts.map +1 -1
- package/dist/unified-provider/normalization/index.js +6 -1
- package/dist/unified-provider/normalization/index.js.map +1 -1
- package/dist/unified-provider/types.d.ts +1 -1
- package/dist/unified-provider/types.d.ts.map +1 -1
- package/dist/wpf/extractors/binding-error-detector.d.ts +75 -0
- package/dist/wpf/extractors/binding-error-detector.d.ts.map +1 -0
- package/dist/wpf/extractors/binding-error-detector.js +290 -0
- package/dist/wpf/extractors/binding-error-detector.js.map +1 -0
- package/dist/wpf/extractors/code-behind-linker.d.ts +70 -0
- package/dist/wpf/extractors/code-behind-linker.d.ts.map +1 -0
- package/dist/wpf/extractors/code-behind-linker.js +172 -0
- package/dist/wpf/extractors/code-behind-linker.js.map +1 -0
- package/dist/wpf/extractors/dependency-property-extractor.d.ts +61 -0
- package/dist/wpf/extractors/dependency-property-extractor.d.ts.map +1 -0
- package/dist/wpf/extractors/dependency-property-extractor.js +201 -0
- package/dist/wpf/extractors/dependency-property-extractor.js.map +1 -0
- package/dist/wpf/extractors/regex/viewmodel-regex.d.ts +82 -0
- package/dist/wpf/extractors/regex/viewmodel-regex.d.ts.map +1 -0
- package/dist/wpf/extractors/regex/viewmodel-regex.js +412 -0
- package/dist/wpf/extractors/regex/viewmodel-regex.js.map +1 -0
- package/dist/wpf/extractors/regex/xaml-regex.d.ts +77 -0
- package/dist/wpf/extractors/regex/xaml-regex.d.ts.map +1 -0
- package/dist/wpf/extractors/regex/xaml-regex.js +353 -0
- package/dist/wpf/extractors/regex/xaml-regex.js.map +1 -0
- package/dist/wpf/extractors/resource-dictionary-parser.d.ts +103 -0
- package/dist/wpf/extractors/resource-dictionary-parser.d.ts.map +1 -0
- package/dist/wpf/extractors/resource-dictionary-parser.js +296 -0
- package/dist/wpf/extractors/resource-dictionary-parser.js.map +1 -0
- package/dist/wpf/extractors/value-converter-extractor.d.ts +128 -0
- package/dist/wpf/extractors/value-converter-extractor.d.ts.map +1 -0
- package/dist/wpf/extractors/value-converter-extractor.js +312 -0
- package/dist/wpf/extractors/value-converter-extractor.js.map +1 -0
- package/dist/wpf/extractors/viewmodel-hybrid-extractor.d.ts +104 -0
- package/dist/wpf/extractors/viewmodel-hybrid-extractor.d.ts.map +1 -0
- package/dist/wpf/extractors/viewmodel-hybrid-extractor.js +513 -0
- package/dist/wpf/extractors/viewmodel-hybrid-extractor.js.map +1 -0
- package/dist/wpf/extractors/xaml-hybrid-extractor.d.ts +98 -0
- package/dist/wpf/extractors/xaml-hybrid-extractor.d.ts.map +1 -0
- package/dist/wpf/extractors/xaml-hybrid-extractor.js +444 -0
- package/dist/wpf/extractors/xaml-hybrid-extractor.js.map +1 -0
- package/dist/wpf/index.d.ts +25 -0
- package/dist/wpf/index.d.ts.map +1 -0
- package/dist/wpf/index.js +31 -0
- package/dist/wpf/index.js.map +1 -0
- package/dist/wpf/integration/wpf-callgraph-adapter.d.ts +82 -0
- package/dist/wpf/integration/wpf-callgraph-adapter.d.ts.map +1 -0
- package/dist/wpf/integration/wpf-callgraph-adapter.js +311 -0
- package/dist/wpf/integration/wpf-callgraph-adapter.js.map +1 -0
- package/dist/wpf/integration/wpf-data-flow-tracer.d.ts +129 -0
- package/dist/wpf/integration/wpf-data-flow-tracer.d.ts.map +1 -0
- package/dist/wpf/integration/wpf-data-flow-tracer.js +367 -0
- package/dist/wpf/integration/wpf-data-flow-tracer.js.map +1 -0
- package/dist/wpf/linkers/datacontext-resolver.d.ts +66 -0
- package/dist/wpf/linkers/datacontext-resolver.d.ts.map +1 -0
- package/dist/wpf/linkers/datacontext-resolver.js +240 -0
- package/dist/wpf/linkers/datacontext-resolver.js.map +1 -0
- package/dist/wpf/linkers/viewmodel-linker.d.ts +71 -0
- package/dist/wpf/linkers/viewmodel-linker.d.ts.map +1 -0
- package/dist/wpf/linkers/viewmodel-linker.js +268 -0
- package/dist/wpf/linkers/viewmodel-linker.js.map +1 -0
- package/dist/wpf/types.d.ts +451 -0
- package/dist/wpf/types.d.ts.map +1 -0
- package/dist/wpf/types.js +8 -0
- package/dist/wpf/types.js.map +1 -0
- package/dist/wpf/wpf-analyzer.d.ts +114 -0
- package/dist/wpf/wpf-analyzer.d.ts.map +1 -0
- package/dist/wpf/wpf-analyzer.js +332 -0
- package/dist/wpf/wpf-analyzer.js.map +1 -0
- package/dist/wrappers/integration/adapter.d.ts.map +1 -1
- package/dist/wrappers/integration/adapter.js +1 -0
- package/dist/wrappers/integration/adapter.js.map +1 -1
- package/package.json +29 -18
- package/LICENSE +0 -21
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Call Chain Normalizer
|
|
3
|
+
*
|
|
4
|
+
* Converts Go AST into unified call chains.
|
|
5
|
+
* Handles Go-specific patterns including:
|
|
6
|
+
* - Method chaining: obj.Method1().Method2()
|
|
7
|
+
* - Selector expressions: pkg.Function()
|
|
8
|
+
* - Struct literals: Type{field: value}
|
|
9
|
+
* - Goroutines: go func()
|
|
10
|
+
* - Defer statements: defer func()
|
|
11
|
+
* - Error handling: if err != nil
|
|
12
|
+
*
|
|
13
|
+
* @requirements Go Language Support
|
|
14
|
+
*/
|
|
15
|
+
import type { TreeSitterNode } from '../../parsers/tree-sitter/types.js';
|
|
16
|
+
import { BaseNormalizer } from './base-normalizer.js';
|
|
17
|
+
import type { UnifiedCallChain, UnifiedFunction, UnifiedClass, UnifiedImport, UnifiedExport } from '../types.js';
|
|
18
|
+
/**
|
|
19
|
+
* Go normalizer
|
|
20
|
+
*/
|
|
21
|
+
export declare class GoNormalizer extends BaseNormalizer {
|
|
22
|
+
readonly language: "go";
|
|
23
|
+
normalizeCallChains(rootNode: TreeSitterNode, _source: string, filePath: string): UnifiedCallChain[];
|
|
24
|
+
/**
|
|
25
|
+
* Extract a call chain from a call expression
|
|
26
|
+
*/
|
|
27
|
+
private extractCallChain;
|
|
28
|
+
/**
|
|
29
|
+
* Normalize arguments from an argument_list node
|
|
30
|
+
*/
|
|
31
|
+
private normalizeArguments;
|
|
32
|
+
/**
|
|
33
|
+
* Normalize a single argument
|
|
34
|
+
*/
|
|
35
|
+
private normalizeArgument;
|
|
36
|
+
/**
|
|
37
|
+
* Normalize a composite literal (struct, map, slice)
|
|
38
|
+
*/
|
|
39
|
+
private normalizeCompositeLiteral;
|
|
40
|
+
/**
|
|
41
|
+
* Check if a composite literal is a struct literal
|
|
42
|
+
*/
|
|
43
|
+
private isStructLiteral;
|
|
44
|
+
/**
|
|
45
|
+
* Mark all nodes in a chain as processed
|
|
46
|
+
*/
|
|
47
|
+
private markChainNodesProcessed;
|
|
48
|
+
extractFunctions(rootNode: TreeSitterNode, _source: string, filePath: string): UnifiedFunction[];
|
|
49
|
+
private extractPackageName;
|
|
50
|
+
private extractFunctionDeclaration;
|
|
51
|
+
private extractMethodDeclaration;
|
|
52
|
+
private extractReceiverType;
|
|
53
|
+
private extractParameters;
|
|
54
|
+
private isTypeNode;
|
|
55
|
+
extractClasses(rootNode: TreeSitterNode, _source: string, filePath: string): UnifiedClass[];
|
|
56
|
+
private extractTypeSpec;
|
|
57
|
+
extractImports(rootNode: TreeSitterNode, _source: string, _filePath: string): UnifiedImport[];
|
|
58
|
+
private extractImportSpec;
|
|
59
|
+
private findNodesOfTypeGo;
|
|
60
|
+
extractExports(rootNode: TreeSitterNode, _source: string, _filePath: string): UnifiedExport[];
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=go-normalizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"go-normalizer.d.ts","sourceRoot":"","sources":["../../../src/unified-provider/normalization/go-normalizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EACV,gBAAgB,EAGhB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,qBAAa,YAAa,SAAQ,cAAc;IAC9C,QAAQ,CAAC,QAAQ,EAAG,IAAI,CAAU;IAMlC,mBAAmB,CACjB,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,gBAAgB,EAAE;IAuBrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAkFxB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAc1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAyDzB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IA+CjC;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAa/B,gBAAgB,CACd,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,eAAe,EAAE;IAiBpB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,0BAA0B;IAyClC,OAAO,CAAC,wBAAwB;IAgDhC,OAAO,CAAC,mBAAmB;IAiB3B,OAAO,CAAC,iBAAiB;IAwCzB,OAAO,CAAC,UAAU;IAoBlB,cAAc,CACZ,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,YAAY,EAAE;IAiBjB,OAAO,CAAC,eAAe;IAoEvB,cAAc,CACZ,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,aAAa,EAAE;IAgBlB,OAAO,CAAC,iBAAiB;IA4CzB,OAAO,CAAC,iBAAiB;IAoBzB,cAAc,CACZ,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,aAAa,EAAE;CAmDnB"}
|
|
@@ -0,0 +1,608 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go Call Chain Normalizer
|
|
3
|
+
*
|
|
4
|
+
* Converts Go AST into unified call chains.
|
|
5
|
+
* Handles Go-specific patterns including:
|
|
6
|
+
* - Method chaining: obj.Method1().Method2()
|
|
7
|
+
* - Selector expressions: pkg.Function()
|
|
8
|
+
* - Struct literals: Type{field: value}
|
|
9
|
+
* - Goroutines: go func()
|
|
10
|
+
* - Defer statements: defer func()
|
|
11
|
+
* - Error handling: if err != nil
|
|
12
|
+
*
|
|
13
|
+
* @requirements Go Language Support
|
|
14
|
+
*/
|
|
15
|
+
import { BaseNormalizer } from './base-normalizer.js';
|
|
16
|
+
/**
|
|
17
|
+
* Go normalizer
|
|
18
|
+
*/
|
|
19
|
+
export class GoNormalizer extends BaseNormalizer {
|
|
20
|
+
language = 'go';
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Call Chain Normalization
|
|
23
|
+
// ============================================================================
|
|
24
|
+
normalizeCallChains(rootNode, _source, filePath) {
|
|
25
|
+
const chains = [];
|
|
26
|
+
const processedNodes = new Set();
|
|
27
|
+
this.traverseNode(rootNode, node => {
|
|
28
|
+
if (node.type === 'call_expression' && !processedNodes.has(node)) {
|
|
29
|
+
// Check if this call is part of a larger chain
|
|
30
|
+
const parent = node.parent;
|
|
31
|
+
if (parent?.type === 'selector_expression' || parent?.type === 'call_expression') {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const chain = this.extractCallChain(node, filePath);
|
|
35
|
+
if (chain && chain.segments.length > 0) {
|
|
36
|
+
chains.push(chain);
|
|
37
|
+
this.markChainNodesProcessed(node, processedNodes);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return chains;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Extract a call chain from a call expression
|
|
45
|
+
*/
|
|
46
|
+
extractCallChain(node, filePath) {
|
|
47
|
+
const segments = [];
|
|
48
|
+
let receiver = '';
|
|
49
|
+
let current = node;
|
|
50
|
+
while (current) {
|
|
51
|
+
if (current.type === 'call_expression') {
|
|
52
|
+
const funcNode = this.getChildByField(current, 'function');
|
|
53
|
+
const argsNode = this.getChildByField(current, 'arguments');
|
|
54
|
+
if (!funcNode)
|
|
55
|
+
break;
|
|
56
|
+
const args = argsNode ? this.normalizeArguments(argsNode) : [];
|
|
57
|
+
if (funcNode.type === 'selector_expression') {
|
|
58
|
+
// obj.Method() or pkg.Function()
|
|
59
|
+
const fieldNode = this.getChildByField(funcNode, 'field');
|
|
60
|
+
const operandNode = this.getChildByField(funcNode, 'operand');
|
|
61
|
+
if (fieldNode) {
|
|
62
|
+
const pos = this.getPosition(fieldNode);
|
|
63
|
+
segments.unshift(this.createSegment(fieldNode.text, true, args, pos.line, pos.column));
|
|
64
|
+
}
|
|
65
|
+
current = operandNode;
|
|
66
|
+
}
|
|
67
|
+
else if (funcNode.type === 'identifier') {
|
|
68
|
+
// Direct function call: Function()
|
|
69
|
+
const pos = this.getPosition(funcNode);
|
|
70
|
+
segments.unshift(this.createSegment(funcNode.text, true, args, pos.line, pos.column));
|
|
71
|
+
receiver = funcNode.text;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (current.type === 'selector_expression') {
|
|
79
|
+
// Property access without call: obj.field
|
|
80
|
+
const fieldNode = this.getChildByField(current, 'field');
|
|
81
|
+
const operandNode = this.getChildByField(current, 'operand');
|
|
82
|
+
if (fieldNode) {
|
|
83
|
+
const pos = this.getPosition(fieldNode);
|
|
84
|
+
segments.unshift(this.createSegment(fieldNode.text, false, [], pos.line, pos.column));
|
|
85
|
+
}
|
|
86
|
+
current = operandNode;
|
|
87
|
+
}
|
|
88
|
+
else if (current.type === 'identifier') {
|
|
89
|
+
receiver = current.text;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
else if (current.type === 'index_expression') {
|
|
93
|
+
// array[index].Method()
|
|
94
|
+
const operandNode = this.getChildByField(current, 'operand');
|
|
95
|
+
current = operandNode;
|
|
96
|
+
}
|
|
97
|
+
else if (current.type === 'type_assertion_expression') {
|
|
98
|
+
// obj.(Type).Method()
|
|
99
|
+
const operandNode = this.getChildByField(current, 'operand');
|
|
100
|
+
current = operandNode;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
receiver = current.text;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (segments.length === 0) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const pos = this.getPosition(node);
|
|
111
|
+
const endPos = this.getEndPosition(node);
|
|
112
|
+
return this.createCallChain(receiver, segments, node.text, filePath, pos.line, pos.column, endPos.line, endPos.column, node);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Normalize arguments from an argument_list node
|
|
116
|
+
*/
|
|
117
|
+
normalizeArguments(argsNode) {
|
|
118
|
+
const args = [];
|
|
119
|
+
for (const child of argsNode.children) {
|
|
120
|
+
if (child.type === '(' || child.type === ')' || child.type === ',') {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
args.push(this.normalizeArgument(child));
|
|
124
|
+
}
|
|
125
|
+
return args;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Normalize a single argument
|
|
129
|
+
*/
|
|
130
|
+
normalizeArgument(node) {
|
|
131
|
+
const pos = this.getPosition(node);
|
|
132
|
+
switch (node.type) {
|
|
133
|
+
case 'interpreted_string_literal':
|
|
134
|
+
case 'raw_string_literal':
|
|
135
|
+
return this.createStringArg(node.text, pos.line, pos.column);
|
|
136
|
+
case 'int_literal':
|
|
137
|
+
case 'float_literal':
|
|
138
|
+
return this.createNumberArg(node.text, pos.line, pos.column);
|
|
139
|
+
case 'true':
|
|
140
|
+
case 'false':
|
|
141
|
+
return this.createBooleanArg(node.text, pos.line, pos.column);
|
|
142
|
+
case 'nil':
|
|
143
|
+
return this.createUnknownArg('nil', pos.line, pos.column);
|
|
144
|
+
case 'identifier':
|
|
145
|
+
// Check for Go boolean literals
|
|
146
|
+
if (node.text === 'true' || node.text === 'false') {
|
|
147
|
+
return this.createBooleanArg(node.text, pos.line, pos.column);
|
|
148
|
+
}
|
|
149
|
+
if (node.text === 'nil') {
|
|
150
|
+
return this.createUnknownArg('nil', pos.line, pos.column);
|
|
151
|
+
}
|
|
152
|
+
return this.createIdentifierArg(node.text, pos.line, pos.column);
|
|
153
|
+
case 'composite_literal':
|
|
154
|
+
return this.normalizeCompositeLiteral(node);
|
|
155
|
+
case 'slice_expression':
|
|
156
|
+
case 'index_expression':
|
|
157
|
+
return this.createUnknownArg(node.text, pos.line, pos.column);
|
|
158
|
+
case 'call_expression':
|
|
159
|
+
return this.createUnknownArg(node.text, pos.line, pos.column);
|
|
160
|
+
case 'func_literal':
|
|
161
|
+
return this.createUnknownArg(node.text, pos.line, pos.column);
|
|
162
|
+
case 'unary_expression':
|
|
163
|
+
// Handle &obj, *ptr, etc.
|
|
164
|
+
return this.createUnknownArg(node.text, pos.line, pos.column);
|
|
165
|
+
case 'binary_expression':
|
|
166
|
+
return this.createUnknownArg(node.text, pos.line, pos.column);
|
|
167
|
+
case 'selector_expression':
|
|
168
|
+
return this.createIdentifierArg(node.text, pos.line, pos.column);
|
|
169
|
+
default:
|
|
170
|
+
return this.createUnknownArg(node.text, pos.line, pos.column);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Normalize a composite literal (struct, map, slice)
|
|
175
|
+
*/
|
|
176
|
+
normalizeCompositeLiteral(node) {
|
|
177
|
+
const pos = this.getPosition(node);
|
|
178
|
+
const typeNode = this.getChildByField(node, 'type');
|
|
179
|
+
const bodyNode = this.getChildByField(node, 'body');
|
|
180
|
+
// Check if it's a map or struct
|
|
181
|
+
if (typeNode?.type === 'map_type' || this.isStructLiteral(node)) {
|
|
182
|
+
const properties = {};
|
|
183
|
+
if (bodyNode) {
|
|
184
|
+
for (const child of bodyNode.children) {
|
|
185
|
+
if (child.type === 'keyed_element') {
|
|
186
|
+
const keyNode = child.children.find(c => c.type === 'literal_element' || c.type === 'identifier');
|
|
187
|
+
const valueNode = child.children.find(c => c !== keyNode && c.type !== ':');
|
|
188
|
+
if (keyNode && valueNode) {
|
|
189
|
+
const key = this.unquoteString(keyNode.text);
|
|
190
|
+
properties[key] = this.normalizeArgument(valueNode);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return this.createObjectArg(node.text, properties, pos.line, pos.column);
|
|
196
|
+
}
|
|
197
|
+
// Slice/array literal
|
|
198
|
+
const elements = [];
|
|
199
|
+
if (bodyNode) {
|
|
200
|
+
for (const child of bodyNode.children) {
|
|
201
|
+
if (child.type !== '{' && child.type !== '}' && child.type !== ',') {
|
|
202
|
+
if (child.type === 'literal_element') {
|
|
203
|
+
elements.push(this.normalizeArgument(child.children[0] ?? child));
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
elements.push(this.normalizeArgument(child));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return this.createArrayArg(node.text, elements, pos.line, pos.column);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Check if a composite literal is a struct literal
|
|
215
|
+
*/
|
|
216
|
+
isStructLiteral(node) {
|
|
217
|
+
const typeNode = this.getChildByField(node, 'type');
|
|
218
|
+
if (!typeNode)
|
|
219
|
+
return false;
|
|
220
|
+
// Type identifier (struct name) or qualified type (pkg.Struct)
|
|
221
|
+
return typeNode.type === 'type_identifier' ||
|
|
222
|
+
typeNode.type === 'qualified_type';
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Mark all nodes in a chain as processed
|
|
226
|
+
*/
|
|
227
|
+
markChainNodesProcessed(node, processed) {
|
|
228
|
+
processed.add(node);
|
|
229
|
+
for (const child of node.children) {
|
|
230
|
+
if (child.type === 'call_expression' || child.type === 'selector_expression') {
|
|
231
|
+
this.markChainNodesProcessed(child, processed);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// ============================================================================
|
|
236
|
+
// Function Extraction
|
|
237
|
+
// ============================================================================
|
|
238
|
+
extractFunctions(rootNode, _source, filePath) {
|
|
239
|
+
const functions = [];
|
|
240
|
+
const packageName = this.extractPackageName(rootNode);
|
|
241
|
+
this.traverseNode(rootNode, node => {
|
|
242
|
+
if (node.type === 'function_declaration') {
|
|
243
|
+
const func = this.extractFunctionDeclaration(node, filePath, packageName);
|
|
244
|
+
if (func)
|
|
245
|
+
functions.push(func);
|
|
246
|
+
}
|
|
247
|
+
else if (node.type === 'method_declaration') {
|
|
248
|
+
const func = this.extractMethodDeclaration(node, filePath, packageName);
|
|
249
|
+
if (func)
|
|
250
|
+
functions.push(func);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
return functions;
|
|
254
|
+
}
|
|
255
|
+
extractPackageName(rootNode) {
|
|
256
|
+
for (const child of rootNode.children) {
|
|
257
|
+
if (child.type === 'package_clause') {
|
|
258
|
+
const nameNode = this.getChildByField(child, 'name') ??
|
|
259
|
+
child.children.find(c => c.type === 'package_identifier');
|
|
260
|
+
return nameNode?.text ?? 'main';
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return 'main';
|
|
264
|
+
}
|
|
265
|
+
extractFunctionDeclaration(node, filePath, packageName) {
|
|
266
|
+
const nameNode = this.getChildByField(node, 'name');
|
|
267
|
+
if (!nameNode)
|
|
268
|
+
return null;
|
|
269
|
+
const name = nameNode.text;
|
|
270
|
+
const params = this.extractParameters(this.getChildByField(node, 'parameters'));
|
|
271
|
+
const resultNode = this.getChildByField(node, 'result');
|
|
272
|
+
const returnType = resultNode?.text;
|
|
273
|
+
const bodyNode = this.getChildByField(node, 'body');
|
|
274
|
+
const isExported = /^[A-Z]/.test(name);
|
|
275
|
+
const isConstructor = name === 'New' || name.startsWith('New');
|
|
276
|
+
const pos = this.getPosition(node);
|
|
277
|
+
const endPos = this.getEndPosition(node);
|
|
278
|
+
return this.createFunction({
|
|
279
|
+
name,
|
|
280
|
+
qualifiedName: `${packageName}.${name}`,
|
|
281
|
+
file: filePath,
|
|
282
|
+
startLine: pos.line,
|
|
283
|
+
endLine: endPos.line,
|
|
284
|
+
startColumn: pos.column,
|
|
285
|
+
endColumn: endPos.column,
|
|
286
|
+
parameters: params,
|
|
287
|
+
returnType,
|
|
288
|
+
isMethod: false,
|
|
289
|
+
isStatic: true, // Go functions are effectively static
|
|
290
|
+
isExported,
|
|
291
|
+
isConstructor,
|
|
292
|
+
isAsync: false, // Go uses goroutines, not async
|
|
293
|
+
decorators: [],
|
|
294
|
+
bodyStartLine: bodyNode ? this.getPosition(bodyNode).line : pos.line,
|
|
295
|
+
bodyEndLine: bodyNode ? this.getEndPosition(bodyNode).line : endPos.line,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
extractMethodDeclaration(node, filePath, packageName) {
|
|
299
|
+
const nameNode = this.getChildByField(node, 'name');
|
|
300
|
+
const receiverNode = this.getChildByField(node, 'receiver');
|
|
301
|
+
if (!nameNode)
|
|
302
|
+
return null;
|
|
303
|
+
const name = nameNode.text;
|
|
304
|
+
const params = this.extractParameters(this.getChildByField(node, 'parameters'));
|
|
305
|
+
const resultNode = this.getChildByField(node, 'result');
|
|
306
|
+
const returnType = resultNode?.text;
|
|
307
|
+
const bodyNode = this.getChildByField(node, 'body');
|
|
308
|
+
// Extract receiver type
|
|
309
|
+
let className;
|
|
310
|
+
if (receiverNode) {
|
|
311
|
+
className = this.extractReceiverType(receiverNode);
|
|
312
|
+
}
|
|
313
|
+
const isExported = /^[A-Z]/.test(name);
|
|
314
|
+
const pos = this.getPosition(node);
|
|
315
|
+
const endPos = this.getEndPosition(node);
|
|
316
|
+
return this.createFunction({
|
|
317
|
+
name,
|
|
318
|
+
qualifiedName: className ? `${packageName}.${className}.${name}` : `${packageName}.${name}`,
|
|
319
|
+
file: filePath,
|
|
320
|
+
startLine: pos.line,
|
|
321
|
+
endLine: endPos.line,
|
|
322
|
+
startColumn: pos.column,
|
|
323
|
+
endColumn: endPos.column,
|
|
324
|
+
parameters: params,
|
|
325
|
+
returnType,
|
|
326
|
+
isMethod: true,
|
|
327
|
+
isStatic: false,
|
|
328
|
+
isExported,
|
|
329
|
+
isConstructor: false,
|
|
330
|
+
isAsync: false,
|
|
331
|
+
className,
|
|
332
|
+
decorators: [],
|
|
333
|
+
bodyStartLine: bodyNode ? this.getPosition(bodyNode).line : pos.line,
|
|
334
|
+
bodyEndLine: bodyNode ? this.getEndPosition(bodyNode).line : endPos.line,
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
extractReceiverType(receiverNode) {
|
|
338
|
+
for (const child of receiverNode.children) {
|
|
339
|
+
if (child.type === 'parameter_declaration') {
|
|
340
|
+
const typeNode = this.getChildByField(child, 'type');
|
|
341
|
+
if (typeNode) {
|
|
342
|
+
// Handle pointer types: *Server -> Server
|
|
343
|
+
if (typeNode.type === 'pointer_type') {
|
|
344
|
+
const innerType = typeNode.namedChildren[0];
|
|
345
|
+
return innerType?.text;
|
|
346
|
+
}
|
|
347
|
+
return typeNode.text;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
extractParameters(paramsNode) {
|
|
354
|
+
if (!paramsNode)
|
|
355
|
+
return [];
|
|
356
|
+
const params = [];
|
|
357
|
+
for (const child of paramsNode.children) {
|
|
358
|
+
if (child.type === 'parameter_declaration') {
|
|
359
|
+
const names = [];
|
|
360
|
+
let type;
|
|
361
|
+
let isVariadic = false;
|
|
362
|
+
for (const paramChild of child.children) {
|
|
363
|
+
if (paramChild.type === 'identifier') {
|
|
364
|
+
names.push(paramChild.text);
|
|
365
|
+
}
|
|
366
|
+
else if (paramChild.type === 'variadic_parameter_declaration') {
|
|
367
|
+
isVariadic = true;
|
|
368
|
+
const variadicType = this.getChildByField(paramChild, 'type');
|
|
369
|
+
type = variadicType?.text;
|
|
370
|
+
}
|
|
371
|
+
else if (this.isTypeNode(paramChild)) {
|
|
372
|
+
type = paramChild.text;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (names.length === 0) {
|
|
376
|
+
params.push(this.createParameter('_', type, false, isVariadic));
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
for (const name of names) {
|
|
380
|
+
params.push(this.createParameter(name, type, false, isVariadic));
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
else if (child.type === 'variadic_parameter_declaration') {
|
|
385
|
+
const nameNode = child.children.find(c => c.type === 'identifier');
|
|
386
|
+
const typeNode = this.getChildByField(child, 'type');
|
|
387
|
+
params.push(this.createParameter(nameNode?.text ?? '_', typeNode?.text, false, true));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return params;
|
|
391
|
+
}
|
|
392
|
+
isTypeNode(node) {
|
|
393
|
+
const typeNodes = [
|
|
394
|
+
'type_identifier',
|
|
395
|
+
'pointer_type',
|
|
396
|
+
'slice_type',
|
|
397
|
+
'array_type',
|
|
398
|
+
'map_type',
|
|
399
|
+
'channel_type',
|
|
400
|
+
'function_type',
|
|
401
|
+
'qualified_type',
|
|
402
|
+
'struct_type',
|
|
403
|
+
'interface_type',
|
|
404
|
+
];
|
|
405
|
+
return typeNodes.includes(node.type);
|
|
406
|
+
}
|
|
407
|
+
// ============================================================================
|
|
408
|
+
// Class (Struct/Interface) Extraction
|
|
409
|
+
// ============================================================================
|
|
410
|
+
extractClasses(rootNode, _source, filePath) {
|
|
411
|
+
const classes = [];
|
|
412
|
+
this.traverseNode(rootNode, node => {
|
|
413
|
+
if (node.type === 'type_declaration') {
|
|
414
|
+
for (const child of node.children) {
|
|
415
|
+
if (child.type === 'type_spec') {
|
|
416
|
+
const cls = this.extractTypeSpec(child, filePath);
|
|
417
|
+
if (cls)
|
|
418
|
+
classes.push(cls);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
return classes;
|
|
424
|
+
}
|
|
425
|
+
extractTypeSpec(node, filePath) {
|
|
426
|
+
const nameNode = this.getChildByField(node, 'name');
|
|
427
|
+
const typeNode = this.getChildByField(node, 'type');
|
|
428
|
+
if (!nameNode || !typeNode)
|
|
429
|
+
return null;
|
|
430
|
+
// Only extract structs and interfaces
|
|
431
|
+
if (typeNode.type !== 'struct_type' && typeNode.type !== 'interface_type') {
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
const name = nameNode.text;
|
|
435
|
+
const isExported = /^[A-Z]/.test(name);
|
|
436
|
+
const baseClasses = [];
|
|
437
|
+
const methods = [];
|
|
438
|
+
if (typeNode.type === 'struct_type') {
|
|
439
|
+
// Extract embedded types from struct
|
|
440
|
+
const fieldListNode = this.getChildByField(typeNode, 'fields') ??
|
|
441
|
+
typeNode.children.find(c => c.type === 'field_declaration_list');
|
|
442
|
+
if (fieldListNode) {
|
|
443
|
+
for (const field of fieldListNode.children) {
|
|
444
|
+
if (field.type === 'field_declaration') {
|
|
445
|
+
// Check for embedded type (no field name)
|
|
446
|
+
const hasName = field.children.some(c => c.type === 'field_identifier');
|
|
447
|
+
if (!hasName) {
|
|
448
|
+
const typeChild = field.children.find(c => this.isTypeNode(c));
|
|
449
|
+
if (typeChild) {
|
|
450
|
+
baseClasses.push(typeChild.text.replace(/^\*/, ''));
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
else if (typeNode.type === 'interface_type') {
|
|
458
|
+
// Extract method signatures and embedded interfaces
|
|
459
|
+
for (const child of typeNode.children) {
|
|
460
|
+
if (child.type === 'method_spec') {
|
|
461
|
+
const methodNameNode = this.getChildByField(child, 'name');
|
|
462
|
+
if (methodNameNode) {
|
|
463
|
+
methods.push(methodNameNode.text);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
else if (child.type === 'type_identifier' || child.type === 'qualified_type') {
|
|
467
|
+
// Embedded interface
|
|
468
|
+
baseClasses.push(child.text);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const pos = this.getPosition(node);
|
|
473
|
+
const endPos = this.getEndPosition(node);
|
|
474
|
+
return this.createClass({
|
|
475
|
+
name,
|
|
476
|
+
file: filePath,
|
|
477
|
+
startLine: pos.line,
|
|
478
|
+
endLine: endPos.line,
|
|
479
|
+
baseClasses,
|
|
480
|
+
methods,
|
|
481
|
+
isExported,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
// ============================================================================
|
|
485
|
+
// Import Extraction
|
|
486
|
+
// ============================================================================
|
|
487
|
+
extractImports(rootNode, _source, _filePath) {
|
|
488
|
+
const imports = [];
|
|
489
|
+
this.traverseNode(rootNode, node => {
|
|
490
|
+
if (node.type === 'import_declaration') {
|
|
491
|
+
const importSpecs = this.findNodesOfTypeGo(node, 'import_spec');
|
|
492
|
+
for (const spec of importSpecs) {
|
|
493
|
+
const imp = this.extractImportSpec(spec);
|
|
494
|
+
if (imp)
|
|
495
|
+
imports.push(imp);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
return imports;
|
|
500
|
+
}
|
|
501
|
+
extractImportSpec(node) {
|
|
502
|
+
const pathNode = this.getChildByField(node, 'path') ??
|
|
503
|
+
node.children.find(c => c.type === 'interpreted_string_literal');
|
|
504
|
+
if (!pathNode)
|
|
505
|
+
return null;
|
|
506
|
+
const path = this.unquoteString(pathNode.text);
|
|
507
|
+
const packageName = path.split('/').pop() ?? path;
|
|
508
|
+
// Check for alias
|
|
509
|
+
const nameNode = this.getChildByField(node, 'name') ??
|
|
510
|
+
node.children.find(c => c.type === 'package_identifier' ||
|
|
511
|
+
c.type === 'blank_identifier' ||
|
|
512
|
+
c.type === 'dot');
|
|
513
|
+
let alias = null;
|
|
514
|
+
let isDotImport = false;
|
|
515
|
+
if (nameNode) {
|
|
516
|
+
if (nameNode.type === 'blank_identifier' || nameNode.text === '_') {
|
|
517
|
+
alias = '_';
|
|
518
|
+
}
|
|
519
|
+
else if (nameNode.type === 'dot' || nameNode.text === '.') {
|
|
520
|
+
isDotImport = true;
|
|
521
|
+
alias = '.';
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
alias = nameNode.text;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return this.createImport({
|
|
528
|
+
source: path,
|
|
529
|
+
names: [{
|
|
530
|
+
imported: packageName,
|
|
531
|
+
local: alias ?? packageName,
|
|
532
|
+
isDefault: false,
|
|
533
|
+
isNamespace: isDotImport,
|
|
534
|
+
}],
|
|
535
|
+
line: this.getPosition(node).line,
|
|
536
|
+
isTypeOnly: false,
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
findNodesOfTypeGo(node, type) {
|
|
540
|
+
const results = [];
|
|
541
|
+
const visit = (n) => {
|
|
542
|
+
if (n.type === type) {
|
|
543
|
+
results.push(n);
|
|
544
|
+
}
|
|
545
|
+
for (const child of n.children) {
|
|
546
|
+
visit(child);
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
visit(node);
|
|
550
|
+
return results;
|
|
551
|
+
}
|
|
552
|
+
// ============================================================================
|
|
553
|
+
// Export Extraction
|
|
554
|
+
// ============================================================================
|
|
555
|
+
extractExports(rootNode, _source, _filePath) {
|
|
556
|
+
// Go exports are determined by capitalization
|
|
557
|
+
// All public (capitalized) top-level declarations are exports
|
|
558
|
+
const exports = [];
|
|
559
|
+
for (const child of rootNode.children) {
|
|
560
|
+
if (child.type === 'function_declaration') {
|
|
561
|
+
const nameNode = this.getChildByField(child, 'name');
|
|
562
|
+
if (nameNode && /^[A-Z]/.test(nameNode.text)) {
|
|
563
|
+
exports.push(this.createExport({
|
|
564
|
+
name: nameNode.text,
|
|
565
|
+
line: this.getPosition(child).line,
|
|
566
|
+
}));
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
else if (child.type === 'method_declaration') {
|
|
570
|
+
const nameNode = this.getChildByField(child, 'name');
|
|
571
|
+
if (nameNode && /^[A-Z]/.test(nameNode.text)) {
|
|
572
|
+
exports.push(this.createExport({
|
|
573
|
+
name: nameNode.text,
|
|
574
|
+
line: this.getPosition(child).line,
|
|
575
|
+
}));
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
else if (child.type === 'type_declaration') {
|
|
579
|
+
for (const typeSpec of child.children) {
|
|
580
|
+
if (typeSpec.type === 'type_spec') {
|
|
581
|
+
const nameNode = this.getChildByField(typeSpec, 'name');
|
|
582
|
+
if (nameNode && /^[A-Z]/.test(nameNode.text)) {
|
|
583
|
+
exports.push(this.createExport({
|
|
584
|
+
name: nameNode.text,
|
|
585
|
+
line: this.getPosition(typeSpec).line,
|
|
586
|
+
}));
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
else if (child.type === 'var_declaration' || child.type === 'const_declaration') {
|
|
592
|
+
for (const spec of child.children) {
|
|
593
|
+
if (spec.type === 'var_spec' || spec.type === 'const_spec') {
|
|
594
|
+
const nameNode = spec.children.find(c => c.type === 'identifier');
|
|
595
|
+
if (nameNode && /^[A-Z]/.test(nameNode.text)) {
|
|
596
|
+
exports.push(this.createExport({
|
|
597
|
+
name: nameNode.text,
|
|
598
|
+
line: this.getPosition(spec).line,
|
|
599
|
+
}));
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return exports;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
//# sourceMappingURL=go-normalizer.js.map
|