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,707 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-sitter Go Parser
|
|
3
|
+
*
|
|
4
|
+
* Full Go parser using tree-sitter-go for semantic extraction.
|
|
5
|
+
* Extracts packages, imports, structs, interfaces, functions,
|
|
6
|
+
* methods, and type declarations from Go source files.
|
|
7
|
+
*
|
|
8
|
+
* Supports Go-specific features including receivers, embedded types,
|
|
9
|
+
* multiple return values, and interface embedding.
|
|
10
|
+
*
|
|
11
|
+
* @requirements Go Language Support
|
|
12
|
+
*/
|
|
13
|
+
import { isGoTreeSitterAvailable, createGoParser, getGoLoadingError, } from './go-loader.js';
|
|
14
|
+
// ============================================
|
|
15
|
+
// Parser Class
|
|
16
|
+
// ============================================
|
|
17
|
+
/**
|
|
18
|
+
* Go parser using tree-sitter-go.
|
|
19
|
+
*
|
|
20
|
+
* Provides full semantic extraction for Go source files including:
|
|
21
|
+
* - Package declarations
|
|
22
|
+
* - Import statements
|
|
23
|
+
* - Function and method declarations
|
|
24
|
+
* - Struct and interface declarations
|
|
25
|
+
* - Type aliases
|
|
26
|
+
*/
|
|
27
|
+
export class TreeSitterGoParser {
|
|
28
|
+
parser = null;
|
|
29
|
+
initError = null;
|
|
30
|
+
/**
|
|
31
|
+
* Check if the parser is available.
|
|
32
|
+
*/
|
|
33
|
+
isAvailable() {
|
|
34
|
+
return isGoTreeSitterAvailable();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get the initialization error if parser is not available.
|
|
38
|
+
*/
|
|
39
|
+
getError() {
|
|
40
|
+
return this.initError ?? getGoLoadingError();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Initialize the parser.
|
|
44
|
+
* Call this before parsing or check isAvailable() first.
|
|
45
|
+
*/
|
|
46
|
+
initialize() {
|
|
47
|
+
if (this.parser) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
if (!isGoTreeSitterAvailable()) {
|
|
51
|
+
this.initError = getGoLoadingError() ?? 'tree-sitter-go not available';
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
this.parser = createGoParser();
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
this.initError = error instanceof Error ? error.message : 'Failed to create Go parser';
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parse Go source code and extract semantic information.
|
|
65
|
+
*
|
|
66
|
+
* @param source - Go source code
|
|
67
|
+
* @param filePath - Optional file path for error reporting
|
|
68
|
+
* @returns GoParseResult with full semantic information
|
|
69
|
+
*/
|
|
70
|
+
parse(source, _filePath) {
|
|
71
|
+
// Ensure parser is initialized
|
|
72
|
+
if (!this.parser && !this.initialize()) {
|
|
73
|
+
return this.createErrorResult(this.initError ?? 'Parser not initialized');
|
|
74
|
+
}
|
|
75
|
+
if (!this.parser) {
|
|
76
|
+
return this.createErrorResult('Parser not available');
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
// Parse the source
|
|
80
|
+
const tree = this.parser.parse(source);
|
|
81
|
+
const rootNode = tree.rootNode;
|
|
82
|
+
// Extract semantic information
|
|
83
|
+
const packageInfo = this.extractPackage(rootNode);
|
|
84
|
+
const imports = this.extractImports(rootNode);
|
|
85
|
+
const packageName = packageInfo?.name ?? 'main';
|
|
86
|
+
// Extract declarations
|
|
87
|
+
const functions = this.extractFunctions(rootNode, packageName);
|
|
88
|
+
const methods = this.extractMethods(rootNode, packageName);
|
|
89
|
+
const structs = this.extractStructs(rootNode);
|
|
90
|
+
const interfaces = this.extractInterfaces(rootNode);
|
|
91
|
+
const typeAliases = this.extractTypeAliases(rootNode);
|
|
92
|
+
// Convert to AST for base result
|
|
93
|
+
const ast = this.convertToAST(rootNode, source);
|
|
94
|
+
return {
|
|
95
|
+
success: true,
|
|
96
|
+
language: 'go',
|
|
97
|
+
ast,
|
|
98
|
+
errors: [],
|
|
99
|
+
package: packageInfo,
|
|
100
|
+
imports,
|
|
101
|
+
functions,
|
|
102
|
+
methods,
|
|
103
|
+
structs,
|
|
104
|
+
interfaces,
|
|
105
|
+
typeAliases,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
return this.createErrorResult(error instanceof Error ? error.message : 'Parse error');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// ============================================
|
|
113
|
+
// Extraction Methods
|
|
114
|
+
// ============================================
|
|
115
|
+
/**
|
|
116
|
+
* Extract package declaration from the AST.
|
|
117
|
+
*/
|
|
118
|
+
extractPackage(root) {
|
|
119
|
+
const packageNode = this.findChildByType(root, 'package_clause');
|
|
120
|
+
if (!packageNode) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
const nameNode = packageNode.childForFieldName('name') ??
|
|
124
|
+
this.findChildByType(packageNode, 'package_identifier');
|
|
125
|
+
if (!nameNode) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
name: nameNode.text,
|
|
130
|
+
startPosition: this.toPosition(packageNode.startPosition),
|
|
131
|
+
endPosition: this.toPosition(packageNode.endPosition),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Extract import statements from the AST.
|
|
136
|
+
*/
|
|
137
|
+
extractImports(root) {
|
|
138
|
+
const imports = [];
|
|
139
|
+
this.findNodesOfType(root, 'import_declaration', (node) => {
|
|
140
|
+
// Handle import spec list (grouped imports)
|
|
141
|
+
this.findNodesOfType(node, 'import_spec', (specNode) => {
|
|
142
|
+
const importInfo = this.parseImportSpec(specNode);
|
|
143
|
+
if (importInfo) {
|
|
144
|
+
imports.push(importInfo);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
return imports;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Parse a single import spec.
|
|
152
|
+
*/
|
|
153
|
+
parseImportSpec(node) {
|
|
154
|
+
const pathNode = node.childForFieldName('path') ??
|
|
155
|
+
this.findChildByType(node, 'interpreted_string_literal');
|
|
156
|
+
if (!pathNode) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
// Remove quotes from path
|
|
160
|
+
const path = pathNode.text.replace(/^"|"$/g, '');
|
|
161
|
+
// Check for alias
|
|
162
|
+
const nameNode = node.childForFieldName('name') ??
|
|
163
|
+
this.findChildByType(node, 'package_identifier') ??
|
|
164
|
+
this.findChildByType(node, 'blank_identifier') ??
|
|
165
|
+
this.findChildByType(node, 'dot');
|
|
166
|
+
let alias = null;
|
|
167
|
+
let isBlankImport = false;
|
|
168
|
+
let isDotImport = false;
|
|
169
|
+
if (nameNode) {
|
|
170
|
+
if (nameNode.type === 'blank_identifier' || nameNode.text === '_') {
|
|
171
|
+
isBlankImport = true;
|
|
172
|
+
alias = '_';
|
|
173
|
+
}
|
|
174
|
+
else if (nameNode.type === 'dot' || nameNode.text === '.') {
|
|
175
|
+
isDotImport = true;
|
|
176
|
+
alias = '.';
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
alias = nameNode.text;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
path,
|
|
184
|
+
alias,
|
|
185
|
+
isBlankImport,
|
|
186
|
+
isDotImport,
|
|
187
|
+
startPosition: this.toPosition(node.startPosition),
|
|
188
|
+
endPosition: this.toPosition(node.endPosition),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Extract function declarations (non-method functions).
|
|
193
|
+
*/
|
|
194
|
+
extractFunctions(root, packageName) {
|
|
195
|
+
const functions = [];
|
|
196
|
+
this.findNodesOfType(root, 'function_declaration', (node) => {
|
|
197
|
+
const funcInfo = this.parseFunctionDeclaration(node, packageName);
|
|
198
|
+
if (funcInfo) {
|
|
199
|
+
functions.push(funcInfo);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
return functions;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Parse a function declaration.
|
|
206
|
+
*/
|
|
207
|
+
parseFunctionDeclaration(node, packageName) {
|
|
208
|
+
const nameNode = node.childForFieldName('name');
|
|
209
|
+
if (!nameNode) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
const name = nameNode.text;
|
|
213
|
+
const isExported = /^[A-Z]/.test(name);
|
|
214
|
+
const parametersNode = node.childForFieldName('parameters');
|
|
215
|
+
const resultNode = node.childForFieldName('result');
|
|
216
|
+
const bodyNode = node.childForFieldName('body');
|
|
217
|
+
const parameters = parametersNode ? this.extractParameters(parametersNode) : [];
|
|
218
|
+
const returns = resultNode ? this.extractReturns(resultNode) : [];
|
|
219
|
+
const isVariadic = parameters.some(p => p.isVariadic);
|
|
220
|
+
return {
|
|
221
|
+
name,
|
|
222
|
+
qualifiedName: `${packageName}.${name}`,
|
|
223
|
+
parameters,
|
|
224
|
+
returns,
|
|
225
|
+
isExported,
|
|
226
|
+
isVariadic,
|
|
227
|
+
startPosition: this.toPosition(node.startPosition),
|
|
228
|
+
endPosition: this.toPosition(node.endPosition),
|
|
229
|
+
bodyStartPosition: bodyNode ? this.toPosition(bodyNode.startPosition) : null,
|
|
230
|
+
bodyEndPosition: bodyNode ? this.toPosition(bodyNode.endPosition) : null,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Extract method declarations (functions with receivers).
|
|
235
|
+
*/
|
|
236
|
+
extractMethods(root, packageName) {
|
|
237
|
+
const methods = [];
|
|
238
|
+
this.findNodesOfType(root, 'method_declaration', (node) => {
|
|
239
|
+
const methodInfo = this.parseMethodDeclaration(node, packageName);
|
|
240
|
+
if (methodInfo) {
|
|
241
|
+
methods.push(methodInfo);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
return methods;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Parse a method declaration.
|
|
248
|
+
*/
|
|
249
|
+
parseMethodDeclaration(node, packageName) {
|
|
250
|
+
const nameNode = node.childForFieldName('name');
|
|
251
|
+
const receiverNode = node.childForFieldName('receiver');
|
|
252
|
+
if (!nameNode || !receiverNode) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
const name = nameNode.text;
|
|
256
|
+
const isExported = /^[A-Z]/.test(name);
|
|
257
|
+
const receiver = this.parseReceiver(receiverNode);
|
|
258
|
+
if (!receiver) {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
const parametersNode = node.childForFieldName('parameters');
|
|
262
|
+
const resultNode = node.childForFieldName('result');
|
|
263
|
+
const bodyNode = node.childForFieldName('body');
|
|
264
|
+
const parameters = parametersNode ? this.extractParameters(parametersNode) : [];
|
|
265
|
+
const returns = resultNode ? this.extractReturns(resultNode) : [];
|
|
266
|
+
const isVariadic = parameters.some(p => p.isVariadic);
|
|
267
|
+
return {
|
|
268
|
+
name,
|
|
269
|
+
qualifiedName: `${packageName}.${receiver.type}.${name}`,
|
|
270
|
+
receiver,
|
|
271
|
+
parameters,
|
|
272
|
+
returns,
|
|
273
|
+
isExported,
|
|
274
|
+
isVariadic,
|
|
275
|
+
startPosition: this.toPosition(node.startPosition),
|
|
276
|
+
endPosition: this.toPosition(node.endPosition),
|
|
277
|
+
bodyStartPosition: bodyNode ? this.toPosition(bodyNode.startPosition) : null,
|
|
278
|
+
bodyEndPosition: bodyNode ? this.toPosition(bodyNode.endPosition) : null,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Parse a receiver declaration.
|
|
283
|
+
*/
|
|
284
|
+
parseReceiver(node) {
|
|
285
|
+
// Receiver is a parameter_list with one parameter
|
|
286
|
+
for (const child of node.children) {
|
|
287
|
+
if (child.type === 'parameter_declaration') {
|
|
288
|
+
const nameNode = this.findChildByType(child, 'identifier');
|
|
289
|
+
const typeNode = child.childForFieldName('type');
|
|
290
|
+
if (!typeNode)
|
|
291
|
+
continue;
|
|
292
|
+
let typeName;
|
|
293
|
+
let isPointer = false;
|
|
294
|
+
if (typeNode.type === 'pointer_type') {
|
|
295
|
+
isPointer = true;
|
|
296
|
+
// Use namedChildren instead of namedChild
|
|
297
|
+
const innerType = typeNode.namedChildren[0];
|
|
298
|
+
typeName = innerType?.text ?? 'unknown';
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
typeName = typeNode.text;
|
|
302
|
+
}
|
|
303
|
+
return {
|
|
304
|
+
name: nameNode?.text ?? '_',
|
|
305
|
+
type: typeName,
|
|
306
|
+
isPointer,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Extract parameters from a parameter list.
|
|
314
|
+
*/
|
|
315
|
+
extractParameters(node) {
|
|
316
|
+
const params = [];
|
|
317
|
+
for (const child of node.children) {
|
|
318
|
+
if (child.type === 'parameter_declaration') {
|
|
319
|
+
const names = [];
|
|
320
|
+
let type;
|
|
321
|
+
let isVariadic = false;
|
|
322
|
+
for (const paramChild of child.children) {
|
|
323
|
+
if (paramChild.type === 'identifier') {
|
|
324
|
+
names.push(paramChild.text);
|
|
325
|
+
}
|
|
326
|
+
else if (paramChild.type === 'variadic_parameter_declaration') {
|
|
327
|
+
isVariadic = true;
|
|
328
|
+
const variadicType = paramChild.childForFieldName('type');
|
|
329
|
+
type = variadicType?.text;
|
|
330
|
+
}
|
|
331
|
+
else if (this.isTypeNode(paramChild)) {
|
|
332
|
+
type = paramChild.text;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
// If no names, it's an unnamed parameter
|
|
336
|
+
if (names.length === 0) {
|
|
337
|
+
params.push({
|
|
338
|
+
name: '_',
|
|
339
|
+
type: type ?? 'unknown',
|
|
340
|
+
isVariadic,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
for (const name of names) {
|
|
345
|
+
params.push({
|
|
346
|
+
name,
|
|
347
|
+
type: type ?? 'unknown',
|
|
348
|
+
isVariadic,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
else if (child.type === 'variadic_parameter_declaration') {
|
|
354
|
+
const nameNode = this.findChildByType(child, 'identifier');
|
|
355
|
+
const typeNode = child.childForFieldName('type');
|
|
356
|
+
params.push({
|
|
357
|
+
name: nameNode?.text ?? '_',
|
|
358
|
+
type: typeNode?.text ?? 'unknown',
|
|
359
|
+
isVariadic: true,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return params;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Extract return types from a result node.
|
|
367
|
+
*/
|
|
368
|
+
extractReturns(node) {
|
|
369
|
+
const returns = [];
|
|
370
|
+
if (node.type === 'parameter_list') {
|
|
371
|
+
// Multiple/named returns: (int, error) or (result int, err error)
|
|
372
|
+
for (const child of node.children) {
|
|
373
|
+
if (child.type === 'parameter_declaration') {
|
|
374
|
+
const names = [];
|
|
375
|
+
let type;
|
|
376
|
+
for (const paramChild of child.children) {
|
|
377
|
+
if (paramChild.type === 'identifier') {
|
|
378
|
+
names.push(paramChild.text);
|
|
379
|
+
}
|
|
380
|
+
else if (this.isTypeNode(paramChild)) {
|
|
381
|
+
type = paramChild.text;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (names.length === 0) {
|
|
385
|
+
returns.push({ name: null, type: type ?? 'unknown' });
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
for (const name of names) {
|
|
389
|
+
returns.push({ name, type: type ?? 'unknown' });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
// Single return type
|
|
397
|
+
returns.push({ name: null, type: node.text });
|
|
398
|
+
}
|
|
399
|
+
return returns;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Extract struct declarations.
|
|
403
|
+
*/
|
|
404
|
+
extractStructs(root) {
|
|
405
|
+
const structs = [];
|
|
406
|
+
this.findNodesOfType(root, 'type_declaration', (node) => {
|
|
407
|
+
for (const child of node.children) {
|
|
408
|
+
if (child.type === 'type_spec') {
|
|
409
|
+
const nameNode = child.childForFieldName('name');
|
|
410
|
+
const typeNode = child.childForFieldName('type');
|
|
411
|
+
if (nameNode && typeNode?.type === 'struct_type') {
|
|
412
|
+
const structInfo = this.parseStruct(nameNode.text, typeNode);
|
|
413
|
+
if (structInfo) {
|
|
414
|
+
structs.push(structInfo);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
return structs;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Parse a struct type.
|
|
424
|
+
*/
|
|
425
|
+
parseStruct(name, node) {
|
|
426
|
+
const isExported = /^[A-Z]/.test(name);
|
|
427
|
+
const fields = [];
|
|
428
|
+
const embeddedTypes = [];
|
|
429
|
+
const fieldListNode = node.childForFieldName('fields') ??
|
|
430
|
+
this.findChildByType(node, 'field_declaration_list');
|
|
431
|
+
if (fieldListNode) {
|
|
432
|
+
for (const child of fieldListNode.children) {
|
|
433
|
+
if (child.type === 'field_declaration') {
|
|
434
|
+
const fieldInfo = this.parseField(child);
|
|
435
|
+
if (fieldInfo) {
|
|
436
|
+
if (fieldInfo.isEmbedded) {
|
|
437
|
+
embeddedTypes.push(fieldInfo.type);
|
|
438
|
+
}
|
|
439
|
+
fields.push(fieldInfo);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return {
|
|
445
|
+
name,
|
|
446
|
+
isExported,
|
|
447
|
+
fields,
|
|
448
|
+
embeddedTypes,
|
|
449
|
+
startPosition: this.toPosition(node.startPosition),
|
|
450
|
+
endPosition: this.toPosition(node.endPosition),
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Parse a struct field.
|
|
455
|
+
*/
|
|
456
|
+
parseField(node) {
|
|
457
|
+
const names = [];
|
|
458
|
+
let type;
|
|
459
|
+
let tag = null;
|
|
460
|
+
for (const child of node.children) {
|
|
461
|
+
if (child.type === 'field_identifier') {
|
|
462
|
+
names.push(child.text);
|
|
463
|
+
}
|
|
464
|
+
else if (this.isTypeNode(child)) {
|
|
465
|
+
type = child.text.replace(/^\*/, ''); // Remove pointer for embedded type check
|
|
466
|
+
}
|
|
467
|
+
else if (child.type === 'raw_string_literal' || child.type === 'interpreted_string_literal') {
|
|
468
|
+
tag = child.text;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
if (!type) {
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
// Embedded type (no name, just type)
|
|
475
|
+
const isEmbedded = names.length === 0;
|
|
476
|
+
const fieldName = isEmbedded ? type : names[0];
|
|
477
|
+
const isExported = /^[A-Z]/.test(fieldName);
|
|
478
|
+
return {
|
|
479
|
+
name: fieldName,
|
|
480
|
+
type,
|
|
481
|
+
tag,
|
|
482
|
+
isExported,
|
|
483
|
+
isEmbedded,
|
|
484
|
+
startPosition: this.toPosition(node.startPosition),
|
|
485
|
+
endPosition: this.toPosition(node.endPosition),
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Extract interface declarations.
|
|
490
|
+
*/
|
|
491
|
+
extractInterfaces(root) {
|
|
492
|
+
const interfaces = [];
|
|
493
|
+
this.findNodesOfType(root, 'type_declaration', (node) => {
|
|
494
|
+
for (const child of node.children) {
|
|
495
|
+
if (child.type === 'type_spec') {
|
|
496
|
+
const nameNode = child.childForFieldName('name');
|
|
497
|
+
const typeNode = child.childForFieldName('type');
|
|
498
|
+
if (nameNode && typeNode?.type === 'interface_type') {
|
|
499
|
+
const interfaceInfo = this.parseInterface(nameNode.text, typeNode);
|
|
500
|
+
if (interfaceInfo) {
|
|
501
|
+
interfaces.push(interfaceInfo);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
return interfaces;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Parse an interface type.
|
|
511
|
+
*/
|
|
512
|
+
parseInterface(name, node) {
|
|
513
|
+
const isExported = /^[A-Z]/.test(name);
|
|
514
|
+
const methods = [];
|
|
515
|
+
const embeddedInterfaces = [];
|
|
516
|
+
for (const child of node.children) {
|
|
517
|
+
if (child.type === 'method_spec') {
|
|
518
|
+
const methodInfo = this.parseInterfaceMethod(child);
|
|
519
|
+
if (methodInfo) {
|
|
520
|
+
methods.push(methodInfo);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
else if (child.type === 'type_identifier' || child.type === 'qualified_type') {
|
|
524
|
+
// Embedded interface
|
|
525
|
+
embeddedInterfaces.push(child.text);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
return {
|
|
529
|
+
name,
|
|
530
|
+
isExported,
|
|
531
|
+
methods,
|
|
532
|
+
embeddedInterfaces,
|
|
533
|
+
startPosition: this.toPosition(node.startPosition),
|
|
534
|
+
endPosition: this.toPosition(node.endPosition),
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Parse an interface method signature.
|
|
539
|
+
*/
|
|
540
|
+
parseInterfaceMethod(node) {
|
|
541
|
+
const nameNode = node.childForFieldName('name');
|
|
542
|
+
if (!nameNode) {
|
|
543
|
+
return null;
|
|
544
|
+
}
|
|
545
|
+
const parametersNode = node.childForFieldName('parameters');
|
|
546
|
+
const resultNode = node.childForFieldName('result');
|
|
547
|
+
return {
|
|
548
|
+
name: nameNode.text,
|
|
549
|
+
parameters: parametersNode ? this.extractParameters(parametersNode) : [],
|
|
550
|
+
returns: resultNode ? this.extractReturns(resultNode) : [],
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Extract type alias declarations.
|
|
555
|
+
*/
|
|
556
|
+
extractTypeAliases(root) {
|
|
557
|
+
const aliases = [];
|
|
558
|
+
this.findNodesOfType(root, 'type_declaration', (node) => {
|
|
559
|
+
for (const child of node.children) {
|
|
560
|
+
if (child.type === 'type_spec') {
|
|
561
|
+
const nameNode = child.childForFieldName('name');
|
|
562
|
+
const typeNode = child.childForFieldName('type');
|
|
563
|
+
if (nameNode && typeNode &&
|
|
564
|
+
typeNode.type !== 'struct_type' &&
|
|
565
|
+
typeNode.type !== 'interface_type') {
|
|
566
|
+
aliases.push({
|
|
567
|
+
name: nameNode.text,
|
|
568
|
+
underlyingType: typeNode.text,
|
|
569
|
+
isExported: /^[A-Z]/.test(nameNode.text),
|
|
570
|
+
startPosition: this.toPosition(child.startPosition),
|
|
571
|
+
endPosition: this.toPosition(child.endPosition),
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
return aliases;
|
|
578
|
+
}
|
|
579
|
+
// ============================================
|
|
580
|
+
// Utility Methods
|
|
581
|
+
// ============================================
|
|
582
|
+
/**
|
|
583
|
+
* Check if a node is a type node.
|
|
584
|
+
*/
|
|
585
|
+
isTypeNode(node) {
|
|
586
|
+
const typeNodes = [
|
|
587
|
+
'type_identifier',
|
|
588
|
+
'pointer_type',
|
|
589
|
+
'slice_type',
|
|
590
|
+
'array_type',
|
|
591
|
+
'map_type',
|
|
592
|
+
'channel_type',
|
|
593
|
+
'function_type',
|
|
594
|
+
'qualified_type',
|
|
595
|
+
'struct_type',
|
|
596
|
+
'interface_type',
|
|
597
|
+
];
|
|
598
|
+
return typeNodes.includes(node.type);
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Convert tree-sitter AST to drift AST format.
|
|
602
|
+
*/
|
|
603
|
+
convertToAST(node, source) {
|
|
604
|
+
const rootNode = this.convertNode(node);
|
|
605
|
+
return {
|
|
606
|
+
rootNode,
|
|
607
|
+
text: source,
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Convert a single tree-sitter node to drift ASTNode.
|
|
612
|
+
*/
|
|
613
|
+
convertNode(node) {
|
|
614
|
+
const children = [];
|
|
615
|
+
for (const child of node.children) {
|
|
616
|
+
children.push(this.convertNode(child));
|
|
617
|
+
}
|
|
618
|
+
return {
|
|
619
|
+
type: this.mapNodeType(node.type),
|
|
620
|
+
text: node.text,
|
|
621
|
+
children,
|
|
622
|
+
startPosition: this.toPosition(node.startPosition),
|
|
623
|
+
endPosition: this.toPosition(node.endPosition),
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Map tree-sitter node types to drift node types.
|
|
628
|
+
*/
|
|
629
|
+
mapNodeType(type) {
|
|
630
|
+
const typeMap = {
|
|
631
|
+
source_file: 'Program',
|
|
632
|
+
package_clause: 'PackageDeclaration',
|
|
633
|
+
import_declaration: 'ImportDeclaration',
|
|
634
|
+
function_declaration: 'FunctionDeclaration',
|
|
635
|
+
method_declaration: 'MethodDeclaration',
|
|
636
|
+
type_declaration: 'TypeDeclaration',
|
|
637
|
+
struct_type: 'StructType',
|
|
638
|
+
interface_type: 'InterfaceType',
|
|
639
|
+
identifier: 'Identifier',
|
|
640
|
+
type_identifier: 'TypeIdentifier',
|
|
641
|
+
block: 'Block',
|
|
642
|
+
return_statement: 'ReturnStatement',
|
|
643
|
+
if_statement: 'IfStatement',
|
|
644
|
+
for_statement: 'ForStatement',
|
|
645
|
+
go_statement: 'GoStatement',
|
|
646
|
+
defer_statement: 'DeferStatement',
|
|
647
|
+
call_expression: 'CallExpression',
|
|
648
|
+
selector_expression: 'SelectorExpression',
|
|
649
|
+
};
|
|
650
|
+
return typeMap[type] ?? type;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Convert tree-sitter position to drift Position.
|
|
654
|
+
*/
|
|
655
|
+
toPosition(point) {
|
|
656
|
+
return {
|
|
657
|
+
row: point.row,
|
|
658
|
+
column: point.column,
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Find a child node by type.
|
|
663
|
+
*/
|
|
664
|
+
findChildByType(node, type) {
|
|
665
|
+
for (const child of node.children) {
|
|
666
|
+
if (child.type === type) {
|
|
667
|
+
return child;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
return null;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Find all nodes of a specific type in the tree.
|
|
674
|
+
*/
|
|
675
|
+
findNodesOfType(node, type, callback) {
|
|
676
|
+
if (node.type === type) {
|
|
677
|
+
callback(node);
|
|
678
|
+
}
|
|
679
|
+
for (const child of node.children) {
|
|
680
|
+
this.findNodesOfType(child, type, callback);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Create an error result.
|
|
685
|
+
*/
|
|
686
|
+
createErrorResult(message) {
|
|
687
|
+
return {
|
|
688
|
+
success: false,
|
|
689
|
+
language: 'go',
|
|
690
|
+
ast: null,
|
|
691
|
+
errors: [
|
|
692
|
+
{
|
|
693
|
+
message,
|
|
694
|
+
position: { row: 0, column: 0 },
|
|
695
|
+
},
|
|
696
|
+
],
|
|
697
|
+
package: null,
|
|
698
|
+
imports: [],
|
|
699
|
+
functions: [],
|
|
700
|
+
methods: [],
|
|
701
|
+
structs: [],
|
|
702
|
+
interfaces: [],
|
|
703
|
+
typeAliases: [],
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
//# sourceMappingURL=tree-sitter-go-parser.js.map
|