agent-ide 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -355
- package/dist/application/events/event-bus.d.ts.map +1 -1
- package/dist/application/events/event-bus.js.map +1 -1
- package/dist/application/index.d.ts +3 -1
- package/dist/application/index.d.ts.map +1 -1
- package/dist/application/index.js +10 -5
- package/dist/application/index.js.map +1 -1
- package/dist/application/services/cache-coordinator.service.d.ts.map +1 -1
- package/dist/application/services/cache-coordinator.service.js.map +1 -1
- package/dist/application/services/error-handler.service.d.ts.map +1 -1
- package/dist/application/services/error-handler.service.js.map +1 -1
- package/dist/application/services/module-coordinator.service.d.ts +5 -14
- package/dist/application/services/module-coordinator.service.d.ts.map +1 -1
- package/dist/application/services/module-coordinator.service.js +15 -108
- package/dist/application/services/module-coordinator.service.js.map +1 -1
- package/dist/application/services/session-manager.service.d.ts.map +1 -1
- package/dist/application/services/session-manager.service.js.map +1 -1
- package/dist/application/services/workflow-engine.service.d.ts +1 -1
- package/dist/application/services/workflow-engine.service.d.ts.map +1 -1
- package/dist/application/services/workflow-engine.service.js.map +1 -1
- package/dist/application/state/state-manager.d.ts +3 -3
- package/dist/application/state/state-manager.d.ts.map +1 -1
- package/dist/application/state/state-manager.js +3 -3
- package/dist/application/state/state-manager.js.map +1 -1
- package/dist/application/types.d.ts.map +1 -1
- package/dist/application/workflows/analysis-workflow.d.ts +1 -1
- package/dist/application/workflows/analysis-workflow.d.ts.map +1 -1
- package/dist/application/workflows/analysis-workflow.js +1 -1
- package/dist/application/workflows/analysis-workflow.js.map +1 -1
- package/dist/application/workflows/base-workflow.d.ts.map +1 -1
- package/dist/application/workflows/base-workflow.js.map +1 -1
- package/dist/application/workflows/index.d.ts +2 -2
- package/dist/application/workflows/index.d.ts.map +1 -1
- package/dist/application/workflows/index.js +2 -2
- package/dist/application/workflows/index.js.map +1 -1
- package/dist/application/workflows/refactor-workflow.d.ts +1 -1
- package/dist/application/workflows/refactor-workflow.d.ts.map +1 -1
- package/dist/application/workflows/refactor-workflow.js +1 -1
- package/dist/application/workflows/refactor-workflow.js.map +1 -1
- package/dist/core/change-signature/change-signature-service.d.ts +94 -0
- package/dist/core/change-signature/change-signature-service.d.ts.map +1 -0
- package/dist/core/change-signature/change-signature-service.js +544 -0
- package/dist/core/change-signature/change-signature-service.js.map +1 -0
- package/dist/core/change-signature/index.d.ts +10 -0
- package/dist/core/change-signature/index.d.ts.map +1 -0
- package/dist/core/change-signature/index.js +12 -0
- package/dist/core/change-signature/index.js.map +1 -0
- package/dist/core/change-signature/signature-parser.d.ts +76 -0
- package/dist/core/change-signature/signature-parser.d.ts.map +1 -0
- package/dist/core/change-signature/signature-parser.js +387 -0
- package/dist/core/change-signature/signature-parser.js.map +1 -0
- package/dist/core/change-signature/types.d.ts +244 -0
- package/dist/core/change-signature/types.d.ts.map +1 -0
- package/dist/core/change-signature/types.js +73 -0
- package/dist/core/change-signature/types.js.map +1 -0
- package/dist/core/dependency/cycle-detector.d.ts +1 -1
- package/dist/core/dependency/cycle-detector.d.ts.map +1 -1
- package/dist/core/dependency/cycle-detector.js +1 -1
- package/dist/core/dependency/cycle-detector.js.map +1 -1
- package/dist/core/dependency/dependency-analyzer.d.ts +3 -1
- package/dist/core/dependency/dependency-analyzer.d.ts.map +1 -1
- package/dist/core/dependency/dependency-analyzer.js +25 -24
- package/dist/core/dependency/dependency-analyzer.js.map +1 -1
- package/dist/core/dependency/types.d.ts.map +1 -1
- package/dist/core/indexing/file-index.d.ts.map +1 -1
- package/dist/core/indexing/file-index.js +1 -1
- package/dist/core/indexing/file-index.js.map +1 -1
- package/dist/core/indexing/index-engine.d.ts +3 -1
- package/dist/core/indexing/index-engine.d.ts.map +1 -1
- package/dist/core/indexing/index-engine.js +25 -17
- package/dist/core/indexing/index-engine.js.map +1 -1
- package/dist/core/indexing/index.d.ts +1 -9
- package/dist/core/indexing/index.d.ts.map +1 -1
- package/dist/core/indexing/index.js +2 -12
- package/dist/core/indexing/index.js.map +1 -1
- package/dist/core/indexing/symbol-index.d.ts.map +1 -1
- package/dist/core/indexing/types.d.ts +12 -0
- package/dist/core/indexing/types.d.ts.map +1 -1
- package/dist/core/indexing/types.js +12 -0
- package/dist/core/indexing/types.js.map +1 -1
- package/dist/core/move-file/import-resolver.d.ts.map +1 -0
- package/dist/core/{move → move-file}/import-resolver.js +9 -10
- package/dist/core/move-file/import-resolver.js.map +1 -0
- package/dist/core/{move → move-file}/index.d.ts +2 -2
- package/dist/core/move-file/index.d.ts.map +1 -0
- package/dist/core/{move → move-file}/index.js +2 -2
- package/dist/core/move-file/index.js.map +1 -0
- package/dist/core/{move → move-file}/move-service.d.ts +3 -1
- package/dist/core/move-file/move-service.d.ts.map +1 -0
- package/dist/core/{move → move-file}/move-service.js +66 -84
- package/dist/core/move-file/move-service.js.map +1 -0
- package/dist/core/move-file/types.d.ts.map +1 -0
- package/dist/core/move-file/types.js.map +1 -0
- package/dist/core/move-member/index.d.ts +10 -0
- package/dist/core/move-member/index.d.ts.map +1 -0
- package/dist/core/move-member/index.js +12 -0
- package/dist/core/move-member/index.js.map +1 -0
- package/dist/core/move-member/member-extractor.d.ts +96 -0
- package/dist/core/move-member/member-extractor.d.ts.map +1 -0
- package/dist/core/move-member/member-extractor.js +439 -0
- package/dist/core/move-member/member-extractor.js.map +1 -0
- package/dist/core/move-member/move-member-service.d.ts +87 -0
- package/dist/core/move-member/move-member-service.d.ts.map +1 -0
- package/dist/core/move-member/move-member-service.js +412 -0
- package/dist/core/move-member/move-member-service.js.map +1 -0
- package/dist/core/move-member/types.d.ts +182 -0
- package/dist/core/move-member/types.d.ts.map +1 -0
- package/dist/core/move-member/types.js +75 -0
- package/dist/core/move-member/types.js.map +1 -0
- package/dist/core/rename/index.d.ts +3 -3
- package/dist/core/rename/index.d.ts.map +1 -1
- package/dist/core/rename/index.js +5 -3
- package/dist/core/rename/index.js.map +1 -1
- package/dist/core/rename/reference-updater.d.ts +3 -1
- package/dist/core/rename/reference-updater.d.ts.map +1 -1
- package/dist/core/rename/reference-updater.js +9 -6
- package/dist/core/rename/reference-updater.js.map +1 -1
- package/dist/core/rename/rename-engine.d.ts +3 -1
- package/dist/core/rename/rename-engine.d.ts.map +1 -1
- package/dist/core/rename/rename-engine.js +8 -5
- package/dist/core/rename/rename-engine.js.map +1 -1
- package/dist/core/rename/scope-analyzer.d.ts.map +1 -1
- package/dist/core/rename/scope-analyzer.js.map +1 -1
- package/dist/core/rename/types.d.ts.map +1 -1
- package/dist/core/shared/call-hierarchy-analyzer.d.ts +102 -0
- package/dist/core/shared/call-hierarchy-analyzer.d.ts.map +1 -0
- package/dist/core/shared/call-hierarchy-analyzer.js +328 -0
- package/dist/core/shared/call-hierarchy-analyzer.js.map +1 -0
- package/dist/core/shared/index.d.ts +7 -0
- package/dist/core/shared/index.d.ts.map +1 -0
- package/dist/core/shared/index.js +7 -0
- package/dist/core/shared/index.js.map +1 -0
- package/dist/core/shared/symbol-finder.d.ts +154 -0
- package/dist/core/shared/symbol-finder.d.ts.map +1 -0
- package/dist/core/shared/symbol-finder.js +433 -0
- package/dist/core/shared/symbol-finder.js.map +1 -0
- package/dist/core/snapshot/index.d.ts +3 -19
- package/dist/core/snapshot/index.d.ts.map +1 -1
- package/dist/core/snapshot/index.js +2 -23
- package/dist/core/snapshot/index.js.map +1 -1
- package/dist/core/snapshot/snapshot-generator.d.ts +66 -0
- package/dist/core/snapshot/snapshot-generator.d.ts.map +1 -0
- package/dist/core/snapshot/snapshot-generator.js +258 -0
- package/dist/core/snapshot/snapshot-generator.js.map +1 -0
- package/dist/core/snapshot/types.d.ts +41 -190
- package/dist/core/snapshot/types.d.ts.map +1 -1
- package/dist/core/snapshot/types.js +13 -67
- package/dist/core/snapshot/types.js.map +1 -1
- package/dist/infrastructure/cache/cache-manager.d.ts +1 -1
- package/dist/infrastructure/cache/cache-manager.d.ts.map +1 -1
- package/dist/infrastructure/cache/cache-manager.js +1 -1
- package/dist/infrastructure/cache/cache-manager.js.map +1 -1
- package/dist/infrastructure/cache/memory-cache.js +1 -1
- package/dist/infrastructure/cache/memory-cache.js.map +1 -1
- package/dist/infrastructure/cache/strategies.d.ts +1 -1
- package/dist/infrastructure/cache/strategies.d.ts.map +1 -1
- package/dist/infrastructure/cache/strategies.js +1 -1
- package/dist/infrastructure/cache/strategies.js.map +1 -1
- package/dist/infrastructure/formatters/diff-generator.d.ts +11 -0
- package/dist/infrastructure/formatters/diff-generator.d.ts.map +1 -0
- package/dist/infrastructure/formatters/diff-generator.js +227 -0
- package/dist/infrastructure/formatters/diff-generator.js.map +1 -0
- package/dist/infrastructure/formatters/index.d.ts +11 -0
- package/dist/infrastructure/formatters/index.d.ts.map +1 -0
- package/dist/infrastructure/formatters/index.js +13 -0
- package/dist/infrastructure/formatters/index.js.map +1 -0
- package/dist/infrastructure/formatters/preview-converter.d.ts +85 -0
- package/dist/infrastructure/formatters/preview-converter.d.ts.map +1 -0
- package/dist/infrastructure/formatters/preview-converter.js +209 -0
- package/dist/infrastructure/formatters/preview-converter.js.map +1 -0
- package/dist/infrastructure/formatters/preview-formatter.d.ts +61 -0
- package/dist/infrastructure/formatters/preview-formatter.d.ts.map +1 -0
- package/dist/infrastructure/formatters/preview-formatter.js +208 -0
- package/dist/infrastructure/formatters/preview-formatter.js.map +1 -0
- package/dist/infrastructure/formatters/query-formatter.d.ts +83 -0
- package/dist/infrastructure/formatters/query-formatter.d.ts.map +1 -0
- package/dist/infrastructure/formatters/query-formatter.js +349 -0
- package/dist/infrastructure/formatters/query-formatter.js.map +1 -0
- package/dist/infrastructure/formatters/query-types.d.ts +238 -0
- package/dist/infrastructure/formatters/query-types.d.ts.map +1 -0
- package/dist/infrastructure/formatters/query-types.js +29 -0
- package/dist/infrastructure/formatters/query-types.js.map +1 -0
- package/dist/infrastructure/formatters/types.d.ts +163 -0
- package/dist/infrastructure/formatters/types.d.ts.map +1 -0
- package/dist/infrastructure/formatters/types.js +27 -0
- package/dist/infrastructure/formatters/types.js.map +1 -0
- package/dist/infrastructure/parser/base.d.ts +1 -33
- package/dist/infrastructure/parser/base.d.ts.map +1 -1
- package/dist/infrastructure/parser/base.js +1 -65
- package/dist/infrastructure/parser/base.js.map +1 -1
- package/dist/infrastructure/parser/index.d.ts +0 -2
- package/dist/infrastructure/parser/index.d.ts.map +1 -1
- package/dist/infrastructure/parser/index.js +1 -2
- package/dist/infrastructure/parser/index.js.map +1 -1
- package/dist/infrastructure/parser/interface.d.ts +2 -59
- package/dist/infrastructure/parser/interface.d.ts.map +1 -1
- package/dist/infrastructure/parser/interface.js +1 -11
- package/dist/infrastructure/parser/interface.js.map +1 -1
- package/dist/infrastructure/parser/registry.d.ts +1 -1
- package/dist/infrastructure/parser/registry.d.ts.map +1 -1
- package/dist/infrastructure/parser/registry.js +1 -1
- package/dist/infrastructure/parser/registry.js.map +1 -1
- package/dist/infrastructure/parser/types.d.ts.map +1 -1
- package/dist/infrastructure/storage/file-system.d.ts +2 -1
- package/dist/infrastructure/storage/file-system.d.ts.map +1 -1
- package/dist/infrastructure/storage/file-system.interface.d.ts +69 -0
- package/dist/infrastructure/storage/file-system.interface.d.ts.map +1 -0
- package/dist/infrastructure/storage/file-system.interface.js +6 -0
- package/dist/infrastructure/storage/file-system.interface.js.map +1 -0
- package/dist/infrastructure/storage/file-system.js.map +1 -1
- package/dist/infrastructure/storage/index.d.ts +2 -4
- package/dist/infrastructure/storage/index.d.ts.map +1 -1
- package/dist/infrastructure/storage/index.js +1 -8
- package/dist/infrastructure/storage/index.js.map +1 -1
- package/dist/infrastructure/storage/mem-file-system.d.ts +44 -0
- package/dist/infrastructure/storage/mem-file-system.d.ts.map +1 -0
- package/dist/infrastructure/storage/mem-file-system.js +105 -0
- package/dist/infrastructure/storage/mem-file-system.js.map +1 -0
- package/dist/interfaces/cli/cli.d.ts +13 -94
- package/dist/interfaces/cli/cli.d.ts.map +1 -1
- package/dist/interfaces/cli/cli.js +47 -2450
- package/dist/interfaces/cli/cli.js.map +1 -1
- package/dist/interfaces/cli/commands/call-hierarchy.command.d.ts +11 -0
- package/dist/interfaces/cli/commands/call-hierarchy.command.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/call-hierarchy.command.js +161 -0
- package/dist/interfaces/cli/commands/call-hierarchy.command.js.map +1 -0
- package/dist/interfaces/cli/commands/change-signature.command.d.ts +11 -0
- package/dist/interfaces/cli/commands/change-signature.command.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/change-signature.command.js +290 -0
- package/dist/interfaces/cli/commands/change-signature.command.js.map +1 -0
- package/dist/interfaces/cli/commands/cycles.command.d.ts +11 -0
- package/dist/interfaces/cli/commands/cycles.command.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/cycles.command.js +87 -0
- package/dist/interfaces/cli/commands/cycles.command.js.map +1 -0
- package/dist/interfaces/cli/commands/find-references.command.d.ts +11 -0
- package/dist/interfaces/cli/commands/find-references.command.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/find-references.command.js +122 -0
- package/dist/interfaces/cli/commands/find-references.command.js.map +1 -0
- package/dist/interfaces/cli/commands/impact.command.d.ts +11 -0
- package/dist/interfaces/cli/commands/impact.command.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/impact.command.js +98 -0
- package/dist/interfaces/cli/commands/impact.command.js.map +1 -0
- package/dist/interfaces/cli/commands/index.d.ts +14 -0
- package/dist/interfaces/cli/commands/index.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/index.js +15 -0
- package/dist/interfaces/cli/commands/index.js.map +1 -0
- package/dist/interfaces/cli/commands/move-member.command.d.ts +11 -0
- package/dist/interfaces/cli/commands/move-member.command.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/move-member.command.js +185 -0
- package/dist/interfaces/cli/commands/move-member.command.js.map +1 -0
- package/dist/interfaces/cli/commands/move.command.d.ts +11 -0
- package/dist/interfaces/cli/commands/move.command.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/move.command.js +212 -0
- package/dist/interfaces/cli/commands/move.command.js.map +1 -0
- package/dist/interfaces/cli/commands/rename.command.d.ts +11 -0
- package/dist/interfaces/cli/commands/rename.command.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/rename.command.js +258 -0
- package/dist/interfaces/cli/commands/rename.command.js.map +1 -0
- package/dist/interfaces/cli/commands/snapshot.command.d.ts +11 -0
- package/dist/interfaces/cli/commands/snapshot.command.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/snapshot.command.js +68 -0
- package/dist/interfaces/cli/commands/snapshot.command.js.map +1 -0
- package/dist/interfaces/cli/commands/types.d.ts +18 -0
- package/dist/interfaces/cli/commands/types.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/types.js +5 -0
- package/dist/interfaces/cli/commands/types.js.map +1 -0
- package/dist/interfaces/cli/index.d.ts +1 -1
- package/dist/interfaces/cli/index.d.ts.map +1 -1
- package/dist/interfaces/cli/index.js +1 -1
- package/dist/interfaces/cli/index.js.map +1 -1
- package/dist/interfaces/cli/preview-output-handler.d.ts +53 -0
- package/dist/interfaces/cli/preview-output-handler.d.ts.map +1 -0
- package/dist/interfaces/cli/preview-output-handler.js +73 -0
- package/dist/interfaces/cli/preview-output-handler.js.map +1 -0
- package/dist/interfaces/cli/unified-output-handler.d.ts +79 -0
- package/dist/interfaces/cli/unified-output-handler.d.ts.map +1 -0
- package/dist/interfaces/cli/unified-output-handler.js +149 -0
- package/dist/interfaces/cli/unified-output-handler.js.map +1 -0
- package/dist/plugins/javascript/index.d.ts +2 -2
- package/dist/plugins/javascript/index.d.ts.map +1 -1
- package/dist/plugins/javascript/index.js +1 -1
- package/dist/plugins/javascript/index.js.map +1 -1
- package/dist/plugins/javascript/types.d.ts.map +1 -1
- package/dist/plugins/javascript/types.js.map +1 -1
- package/dist/plugins/python/dependency-analyzer.d.ts +86 -0
- package/dist/plugins/python/dependency-analyzer.d.ts.map +1 -0
- package/dist/plugins/python/dependency-analyzer.js +252 -0
- package/dist/plugins/python/dependency-analyzer.js.map +1 -0
- package/dist/plugins/python/index.d.ts +9 -0
- package/dist/plugins/python/index.d.ts.map +1 -0
- package/dist/plugins/python/index.js +14 -0
- package/dist/plugins/python/index.js.map +1 -0
- package/dist/plugins/python/parser.d.ts +117 -0
- package/dist/plugins/python/parser.d.ts.map +1 -0
- package/dist/plugins/python/parser.js +414 -0
- package/dist/plugins/python/parser.js.map +1 -0
- package/dist/plugins/python/symbol-extractor.d.ts +108 -0
- package/dist/plugins/python/symbol-extractor.d.ts.map +1 -0
- package/dist/plugins/python/symbol-extractor.js +389 -0
- package/dist/plugins/python/symbol-extractor.js.map +1 -0
- package/dist/plugins/python/tree-sitter-bridge.d.ts +57 -0
- package/dist/plugins/python/tree-sitter-bridge.d.ts.map +1 -0
- package/dist/plugins/python/tree-sitter-bridge.js +267 -0
- package/dist/plugins/python/tree-sitter-bridge.js.map +1 -0
- package/dist/plugins/python/types.d.ts +179 -0
- package/dist/plugins/python/types.d.ts.map +1 -0
- package/dist/plugins/python/types.js +252 -0
- package/dist/plugins/python/types.js.map +1 -0
- package/dist/plugins/swift/dependency-analyzer.d.ts +1 -1
- package/dist/plugins/swift/dependency-analyzer.d.ts.map +1 -1
- package/dist/plugins/swift/dependency-analyzer.js +1 -1
- package/dist/plugins/swift/dependency-analyzer.js.map +1 -1
- package/dist/plugins/swift/parser.d.ts +4 -0
- package/dist/plugins/swift/parser.d.ts.map +1 -1
- package/dist/plugins/swift/parser.js +24 -6
- package/dist/plugins/swift/parser.js.map +1 -1
- package/dist/plugins/swift/symbol-extractor.d.ts +1 -1
- package/dist/plugins/swift/symbol-extractor.d.ts.map +1 -1
- package/dist/plugins/swift/symbol-extractor.js.map +1 -1
- package/dist/plugins/swift/types.d.ts.map +1 -1
- package/dist/plugins/swift/types.js.map +1 -1
- package/dist/plugins/typescript/parser.d.ts +4 -37
- package/dist/plugins/typescript/parser.d.ts.map +1 -1
- package/dist/plugins/typescript/parser.js +29 -331
- package/dist/plugins/typescript/parser.js.map +1 -1
- package/dist/plugins/typescript/symbol-extractor.d.ts.map +1 -1
- package/dist/plugins/typescript/symbol-extractor.js +12 -0
- package/dist/plugins/typescript/symbol-extractor.js.map +1 -1
- package/dist/plugins/typescript/types.d.ts.map +1 -1
- package/dist/plugins/typescript/types.js +10 -0
- package/dist/plugins/typescript/types.js.map +1 -1
- package/dist/shared/errors/config-error.d.ts +1 -1
- package/dist/shared/errors/config-error.d.ts.map +1 -1
- package/dist/shared/errors/config-error.js +1 -1
- package/dist/shared/errors/config-error.js.map +1 -1
- package/dist/shared/errors/file-error.d.ts +1 -1
- package/dist/shared/errors/file-error.d.ts.map +1 -1
- package/dist/shared/errors/file-error.js +1 -1
- package/dist/shared/errors/file-error.js.map +1 -1
- package/dist/shared/errors/index.d.ts +1 -1
- package/dist/shared/errors/index.d.ts.map +1 -1
- package/dist/shared/errors/index.js +4 -4
- package/dist/shared/errors/index.js.map +1 -1
- package/dist/shared/errors/parser-error.d.ts +1 -1
- package/dist/shared/errors/parser-error.d.ts.map +1 -1
- package/dist/shared/errors/parser-error.js +1 -1
- package/dist/shared/errors/parser-error.js.map +1 -1
- package/dist/shared/errors/validation-error.d.ts +1 -1
- package/dist/shared/errors/validation-error.d.ts.map +1 -1
- package/dist/shared/errors/validation-error.js +1 -1
- package/dist/shared/errors/validation-error.js.map +1 -1
- package/dist/shared/types/ast.d.ts +1 -1
- package/dist/shared/types/ast.d.ts.map +1 -1
- package/dist/shared/types/ast.js +1 -1
- package/dist/shared/types/ast.js.map +1 -1
- package/dist/shared/types/symbol.d.ts +3 -2
- package/dist/shared/types/symbol.d.ts.map +1 -1
- package/dist/shared/types/symbol.js +1 -0
- package/dist/shared/types/symbol.js.map +1 -1
- package/dist/shared/utils/index.d.ts +5 -5
- package/dist/shared/utils/index.d.ts.map +1 -1
- package/dist/shared/utils/index.js +5 -5
- package/dist/shared/utils/index.js.map +1 -1
- package/package.json +9 -8
- package/dist/core/analysis/index.d.ts +0 -6
- package/dist/core/analysis/index.d.ts.map +0 -1
- package/dist/core/analysis/index.js +0 -7
- package/dist/core/analysis/index.js.map +0 -1
- package/dist/core/analysis/quality-metrics.d.ts +0 -158
- package/dist/core/analysis/quality-metrics.d.ts.map +0 -1
- package/dist/core/analysis/quality-metrics.js +0 -442
- package/dist/core/analysis/quality-metrics.js.map +0 -1
- package/dist/core/indexing/file-watcher.d.ts +0 -110
- package/dist/core/indexing/file-watcher.d.ts.map +0 -1
- package/dist/core/indexing/file-watcher.js +0 -280
- package/dist/core/indexing/file-watcher.js.map +0 -1
- package/dist/core/move/import-resolver.d.ts.map +0 -1
- package/dist/core/move/import-resolver.js.map +0 -1
- package/dist/core/move/index.d.ts.map +0 -1
- package/dist/core/move/index.js.map +0 -1
- package/dist/core/move/move-service.d.ts.map +0 -1
- package/dist/core/move/move-service.js.map +0 -1
- package/dist/core/move/types.d.ts.map +0 -1
- package/dist/core/move/types.js.map +0 -1
- package/dist/core/refactor/design-patterns.d.ts +0 -178
- package/dist/core/refactor/design-patterns.d.ts.map +0 -1
- package/dist/core/refactor/design-patterns.js +0 -656
- package/dist/core/refactor/design-patterns.js.map +0 -1
- package/dist/core/refactor/extract-function.d.ts +0 -197
- package/dist/core/refactor/extract-function.d.ts.map +0 -1
- package/dist/core/refactor/extract-function.js +0 -730
- package/dist/core/refactor/extract-function.js.map +0 -1
- package/dist/core/refactor/index.d.ts +0 -8
- package/dist/core/refactor/index.d.ts.map +0 -1
- package/dist/core/refactor/index.js +0 -11
- package/dist/core/refactor/index.js.map +0 -1
- package/dist/core/refactor/inline-function.d.ts +0 -175
- package/dist/core/refactor/inline-function.d.ts.map +0 -1
- package/dist/core/refactor/inline-function.js +0 -425
- package/dist/core/refactor/inline-function.js.map +0 -1
- package/dist/core/refactor/swift-extractor.d.ts +0 -98
- package/dist/core/refactor/swift-extractor.d.ts.map +0 -1
- package/dist/core/refactor/swift-extractor.js +0 -283
- package/dist/core/refactor/swift-extractor.js.map +0 -1
- package/dist/core/search/engines/text-engine.d.ts +0 -52
- package/dist/core/search/engines/text-engine.d.ts.map +0 -1
- package/dist/core/search/engines/text-engine.js +0 -376
- package/dist/core/search/engines/text-engine.js.map +0 -1
- package/dist/core/search/index.d.ts +0 -10
- package/dist/core/search/index.d.ts.map +0 -1
- package/dist/core/search/index.js +0 -11
- package/dist/core/search/index.js.map +0 -1
- package/dist/core/search/service.d.ts +0 -105
- package/dist/core/search/service.d.ts.map +0 -1
- package/dist/core/search/service.js +0 -384
- package/dist/core/search/service.js.map +0 -1
- package/dist/core/search/types.d.ts +0 -357
- package/dist/core/search/types.d.ts.map +0 -1
- package/dist/core/search/types.js +0 -47
- package/dist/core/search/types.js.map +0 -1
- package/dist/core/shit-score/grading.d.ts +0 -39
- package/dist/core/shit-score/grading.d.ts.map +0 -1
- package/dist/core/shit-score/grading.js +0 -253
- package/dist/core/shit-score/grading.js.map +0 -1
- package/dist/core/shit-score/index.d.ts +0 -9
- package/dist/core/shit-score/index.d.ts.map +0 -1
- package/dist/core/shit-score/index.js +0 -8
- package/dist/core/shit-score/index.js.map +0 -1
- package/dist/core/shit-score/score-calculator.d.ts +0 -75
- package/dist/core/shit-score/score-calculator.d.ts.map +0 -1
- package/dist/core/shit-score/score-calculator.js +0 -240
- package/dist/core/shit-score/score-calculator.js.map +0 -1
- package/dist/core/shit-score/shit-score-analyzer.d.ts +0 -84
- package/dist/core/shit-score/shit-score-analyzer.d.ts.map +0 -1
- package/dist/core/shit-score/shit-score-analyzer.js +0 -595
- package/dist/core/shit-score/shit-score-analyzer.js.map +0 -1
- package/dist/core/shit-score/types.d.ts +0 -231
- package/dist/core/shit-score/types.d.ts.map +0 -1
- package/dist/core/shit-score/types.js +0 -73
- package/dist/core/shit-score/types.js.map +0 -1
- package/dist/core/snapshot/code-compressor.d.ts +0 -39
- package/dist/core/snapshot/code-compressor.d.ts.map +0 -1
- package/dist/core/snapshot/code-compressor.js +0 -211
- package/dist/core/snapshot/code-compressor.js.map +0 -1
- package/dist/core/snapshot/config.d.ts +0 -60
- package/dist/core/snapshot/config.d.ts.map +0 -1
- package/dist/core/snapshot/config.js +0 -136
- package/dist/core/snapshot/config.js.map +0 -1
- package/dist/core/snapshot/snapshot-differ.d.ts +0 -54
- package/dist/core/snapshot/snapshot-differ.d.ts.map +0 -1
- package/dist/core/snapshot/snapshot-differ.js +0 -262
- package/dist/core/snapshot/snapshot-differ.js.map +0 -1
- package/dist/core/snapshot/snapshot-engine.d.ts +0 -94
- package/dist/core/snapshot/snapshot-engine.d.ts.map +0 -1
- package/dist/core/snapshot/snapshot-engine.js +0 -492
- package/dist/core/snapshot/snapshot-engine.js.map +0 -1
- package/dist/infrastructure/parser/factory.d.ts +0 -141
- package/dist/infrastructure/parser/factory.d.ts.map +0 -1
- package/dist/infrastructure/parser/factory.js +0 -306
- package/dist/infrastructure/parser/factory.js.map +0 -1
- package/dist/infrastructure/storage/file-watcher.d.ts +0 -84
- package/dist/infrastructure/storage/file-watcher.d.ts.map +0 -1
- package/dist/infrastructure/storage/file-watcher.js +0 -249
- package/dist/infrastructure/storage/file-watcher.js.map +0 -1
- package/dist/infrastructure/storage/path-utils.d.ts +0 -96
- package/dist/infrastructure/storage/path-utils.d.ts.map +0 -1
- package/dist/infrastructure/storage/path-utils.js +0 -272
- package/dist/infrastructure/storage/path-utils.js.map +0 -1
- package/dist/plugins/swift/analyzers/complexity-analyzer.d.ts +0 -41
- package/dist/plugins/swift/analyzers/complexity-analyzer.d.ts.map +0 -1
- package/dist/plugins/swift/analyzers/complexity-analyzer.js +0 -206
- package/dist/plugins/swift/analyzers/complexity-analyzer.js.map +0 -1
- package/dist/plugins/swift/analyzers/duplication-detector.d.ts +0 -89
- package/dist/plugins/swift/analyzers/duplication-detector.d.ts.map +0 -1
- package/dist/plugins/swift/analyzers/duplication-detector.js +0 -271
- package/dist/plugins/swift/analyzers/duplication-detector.js.map +0 -1
- package/dist/plugins/swift/analyzers/error-handling-checker.d.ts +0 -34
- package/dist/plugins/swift/analyzers/error-handling-checker.d.ts.map +0 -1
- package/dist/plugins/swift/analyzers/error-handling-checker.js +0 -135
- package/dist/plugins/swift/analyzers/error-handling-checker.js.map +0 -1
- package/dist/plugins/swift/analyzers/naming-checker.d.ts +0 -47
- package/dist/plugins/swift/analyzers/naming-checker.d.ts.map +0 -1
- package/dist/plugins/swift/analyzers/naming-checker.js +0 -161
- package/dist/plugins/swift/analyzers/naming-checker.js.map +0 -1
- package/dist/plugins/swift/analyzers/pattern-detector.d.ts +0 -78
- package/dist/plugins/swift/analyzers/pattern-detector.d.ts.map +0 -1
- package/dist/plugins/swift/analyzers/pattern-detector.js +0 -247
- package/dist/plugins/swift/analyzers/pattern-detector.js.map +0 -1
- package/dist/plugins/swift/analyzers/security-checker.d.ts +0 -38
- package/dist/plugins/swift/analyzers/security-checker.d.ts.map +0 -1
- package/dist/plugins/swift/analyzers/security-checker.js +0 -135
- package/dist/plugins/swift/analyzers/security-checker.js.map +0 -1
- package/dist/plugins/swift/analyzers/test-coverage-checker.d.ts +0 -26
- package/dist/plugins/swift/analyzers/test-coverage-checker.d.ts.map +0 -1
- package/dist/plugins/swift/analyzers/test-coverage-checker.js +0 -63
- package/dist/plugins/swift/analyzers/test-coverage-checker.js.map +0 -1
- package/dist/plugins/swift/analyzers/type-safety-checker.d.ts +0 -41
- package/dist/plugins/swift/analyzers/type-safety-checker.d.ts.map +0 -1
- package/dist/plugins/swift/analyzers/type-safety-checker.js +0 -121
- package/dist/plugins/swift/analyzers/type-safety-checker.js.map +0 -1
- package/dist/plugins/swift/analyzers/unused-symbol-detector.d.ts +0 -38
- package/dist/plugins/swift/analyzers/unused-symbol-detector.d.ts.map +0 -1
- package/dist/plugins/swift/analyzers/unused-symbol-detector.js +0 -211
- package/dist/plugins/swift/analyzers/unused-symbol-detector.js.map +0 -1
- package/dist/plugins/typescript/analyzers/complexity-analyzer.d.ts +0 -39
- package/dist/plugins/typescript/analyzers/complexity-analyzer.d.ts.map +0 -1
- package/dist/plugins/typescript/analyzers/complexity-analyzer.js +0 -196
- package/dist/plugins/typescript/analyzers/complexity-analyzer.js.map +0 -1
- package/dist/plugins/typescript/analyzers/duplication-detector.d.ts +0 -181
- package/dist/plugins/typescript/analyzers/duplication-detector.d.ts.map +0 -1
- package/dist/plugins/typescript/analyzers/duplication-detector.js +0 -695
- package/dist/plugins/typescript/analyzers/duplication-detector.js.map +0 -1
- package/dist/plugins/typescript/analyzers/error-handling-checker.d.ts +0 -26
- package/dist/plugins/typescript/analyzers/error-handling-checker.d.ts.map +0 -1
- package/dist/plugins/typescript/analyzers/error-handling-checker.js +0 -84
- package/dist/plugins/typescript/analyzers/error-handling-checker.js.map +0 -1
- package/dist/plugins/typescript/analyzers/naming-checker.d.ts +0 -30
- package/dist/plugins/typescript/analyzers/naming-checker.d.ts.map +0 -1
- package/dist/plugins/typescript/analyzers/naming-checker.js +0 -116
- package/dist/plugins/typescript/analyzers/naming-checker.js.map +0 -1
- package/dist/plugins/typescript/analyzers/pattern-detector.d.ts +0 -80
- package/dist/plugins/typescript/analyzers/pattern-detector.d.ts.map +0 -1
- package/dist/plugins/typescript/analyzers/pattern-detector.js +0 -267
- package/dist/plugins/typescript/analyzers/pattern-detector.js.map +0 -1
- package/dist/plugins/typescript/analyzers/security-checker.d.ts +0 -34
- package/dist/plugins/typescript/analyzers/security-checker.d.ts.map +0 -1
- package/dist/plugins/typescript/analyzers/security-checker.js +0 -126
- package/dist/plugins/typescript/analyzers/security-checker.js.map +0 -1
- package/dist/plugins/typescript/analyzers/test-coverage-checker.d.ts +0 -22
- package/dist/plugins/typescript/analyzers/test-coverage-checker.d.ts.map +0 -1
- package/dist/plugins/typescript/analyzers/test-coverage-checker.js +0 -62
- package/dist/plugins/typescript/analyzers/test-coverage-checker.js.map +0 -1
- package/dist/plugins/typescript/analyzers/type-safety-checker.d.ts +0 -32
- package/dist/plugins/typescript/analyzers/type-safety-checker.d.ts.map +0 -1
- package/dist/plugins/typescript/analyzers/type-safety-checker.js +0 -86
- package/dist/plugins/typescript/analyzers/type-safety-checker.js.map +0 -1
- package/dist/plugins/typescript/analyzers/unused-symbol-detector.d.ts +0 -47
- package/dist/plugins/typescript/analyzers/unused-symbol-detector.d.ts.map +0 -1
- package/dist/plugins/typescript/analyzers/unused-symbol-detector.js +0 -152
- package/dist/plugins/typescript/analyzers/unused-symbol-detector.js.map +0 -1
- /package/dist/core/{move → move-file}/import-resolver.d.ts +0 -0
- /package/dist/core/{move → move-file}/types.d.ts +0 -0
- /package/dist/core/{move → move-file}/types.js +0 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call Hierarchy Analyzer
|
|
3
|
+
* 分析函數的呼叫層次關係(incoming/outgoing)
|
|
4
|
+
*/
|
|
5
|
+
import * as ts from 'typescript';
|
|
6
|
+
import { createSymbolFinder } from './symbol-finder.js';
|
|
7
|
+
/**
|
|
8
|
+
* Call Hierarchy Analyzer
|
|
9
|
+
* 分析函數的呼叫者(incoming)和被呼叫者(outgoing)
|
|
10
|
+
*/
|
|
11
|
+
export class CallHierarchyAnalyzer {
|
|
12
|
+
parserRegistry;
|
|
13
|
+
fileSystem;
|
|
14
|
+
symbolFinder;
|
|
15
|
+
constructor(parserRegistry, fileSystem) {
|
|
16
|
+
this.parserRegistry = parserRegistry;
|
|
17
|
+
this.fileSystem = fileSystem;
|
|
18
|
+
this.symbolFinder = createSymbolFinder(parserRegistry, fileSystem);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 分析函數的呼叫層次
|
|
22
|
+
*/
|
|
23
|
+
async analyze(functionName, projectFiles, options) {
|
|
24
|
+
// 1. 找到函數定義
|
|
25
|
+
const definition = await this.findFunctionDefinition(functionName, projectFiles);
|
|
26
|
+
if (!definition) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return this.analyzeWithDefinition(functionName, definition.location.filePath, definition.location.range, projectFiles, options);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 使用已知的定義位置分析函數的呼叫層次
|
|
33
|
+
* 當呼叫端已經透過 IndexEngine 找到定義時使用此方法
|
|
34
|
+
*/
|
|
35
|
+
async analyzeWithDefinition(functionName, definitionFile, definitionRange, projectFiles, options) {
|
|
36
|
+
const incoming = [];
|
|
37
|
+
const outgoing = [];
|
|
38
|
+
// 分析 incoming(誰呼叫了此函數)
|
|
39
|
+
if (options.direction === 'incoming' || options.direction === 'both') {
|
|
40
|
+
const incomingCalls = await this.findIncomingCalls(functionName, projectFiles, definitionFile, options.depth);
|
|
41
|
+
incoming.push(...incomingCalls);
|
|
42
|
+
}
|
|
43
|
+
// 分析 outgoing(此函數呼叫了誰)
|
|
44
|
+
if (options.direction === 'outgoing' || options.direction === 'both') {
|
|
45
|
+
const outgoingCalls = await this.findOutgoingCalls(definitionFile, functionName, definitionRange, options.depth);
|
|
46
|
+
outgoing.push(...outgoingCalls);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
functionName,
|
|
50
|
+
definitionFile,
|
|
51
|
+
definitionLine: definitionRange.start.line,
|
|
52
|
+
incoming,
|
|
53
|
+
outgoing
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 找到函數定義
|
|
58
|
+
*/
|
|
59
|
+
async findFunctionDefinition(functionName, projectFiles) {
|
|
60
|
+
for (const filePath of projectFiles) {
|
|
61
|
+
const definition = await this.symbolFinder.findDefinition(filePath, functionName);
|
|
62
|
+
if (definition && this.isFunctionSymbol(definition.symbol)) {
|
|
63
|
+
return { location: definition.symbol.location };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 檢查是否為函數類型的符號
|
|
70
|
+
*/
|
|
71
|
+
isFunctionSymbol(symbol) {
|
|
72
|
+
// SymbolType.Function 涵蓋函數和方法
|
|
73
|
+
return symbol.type === 'function';
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 找出 incoming 呼叫(誰呼叫了目標函數)
|
|
77
|
+
*/
|
|
78
|
+
async findIncomingCalls(functionName, projectFiles, definitionFile, depth) {
|
|
79
|
+
const incoming = [];
|
|
80
|
+
const visited = new Set();
|
|
81
|
+
const findCallsRecursive = async (targetName, currentDepth) => {
|
|
82
|
+
if (currentDepth > depth || visited.has(targetName)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
visited.add(targetName);
|
|
86
|
+
const callSites = await this.symbolFinder.findCallSites(targetName, projectFiles);
|
|
87
|
+
for (const callSite of callSites) {
|
|
88
|
+
// 排除定義檔案中的自身呼叫(如果是遞迴)
|
|
89
|
+
if (callSite.location.filePath === definitionFile
|
|
90
|
+
&& callSite.functionName === targetName) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
// 找出呼叫點所在的函數
|
|
94
|
+
const callerInfo = await this.findEnclosingFunction(callSite.location.filePath, callSite.location.range.start.line);
|
|
95
|
+
const context = await this.getLineContext(callSite.location.filePath, callSite.location.range.start.line);
|
|
96
|
+
incoming.push({
|
|
97
|
+
caller: callerInfo?.name || '<anonymous>',
|
|
98
|
+
location: callSite.location,
|
|
99
|
+
context,
|
|
100
|
+
callerDefinitionFile: callerInfo?.file
|
|
101
|
+
});
|
|
102
|
+
// 遞迴查找(如果深度允許)
|
|
103
|
+
if (currentDepth < depth && callerInfo?.name && callerInfo.name !== '<anonymous>') {
|
|
104
|
+
await findCallsRecursive(callerInfo.name, currentDepth + 1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
await findCallsRecursive(functionName, 1);
|
|
109
|
+
return incoming;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 找出 outgoing 呼叫(目標函數呼叫了誰)
|
|
113
|
+
* @param depth 預留參數:未來可用於遞迴深度控制或效能優化
|
|
114
|
+
*/
|
|
115
|
+
async findOutgoingCalls(filePath, functionName, functionRange, _depth // Reserved: 未來可實作遞迴分析或深度限制優化
|
|
116
|
+
) {
|
|
117
|
+
const outgoing = [];
|
|
118
|
+
const visited = new Set();
|
|
119
|
+
const content = await this.readFile(filePath);
|
|
120
|
+
if (!content) {
|
|
121
|
+
return outgoing;
|
|
122
|
+
}
|
|
123
|
+
const parser = this.parserRegistry.getParser(this.getExtension(filePath));
|
|
124
|
+
if (!parser) {
|
|
125
|
+
return outgoing;
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
const ast = await parser.parse(content, filePath);
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
|
+
const sourceFile = ast.tsSourceFile;
|
|
131
|
+
if (!sourceFile) {
|
|
132
|
+
return outgoing;
|
|
133
|
+
}
|
|
134
|
+
// 找到目標函數的 AST 節點
|
|
135
|
+
const functionNode = this.findFunctionNode(sourceFile, functionName, functionRange);
|
|
136
|
+
if (!functionNode || !functionNode.body) {
|
|
137
|
+
return outgoing;
|
|
138
|
+
}
|
|
139
|
+
// 遍歷函數 body 找出所有 CallExpression
|
|
140
|
+
const findCallsInNode = (node) => {
|
|
141
|
+
if (ts.isCallExpression(node)) {
|
|
142
|
+
const callInfo = this.extractCallInfo(node, sourceFile);
|
|
143
|
+
if (callInfo) {
|
|
144
|
+
const key = `${callInfo.callee}:${callInfo.line}:${callInfo.column}`;
|
|
145
|
+
if (!visited.has(key)) {
|
|
146
|
+
visited.add(key);
|
|
147
|
+
outgoing.push({
|
|
148
|
+
callee: callInfo.callee,
|
|
149
|
+
location: {
|
|
150
|
+
filePath,
|
|
151
|
+
range: {
|
|
152
|
+
start: { line: callInfo.line, column: callInfo.column, offset: undefined },
|
|
153
|
+
end: { line: callInfo.line, column: callInfo.column + callInfo.callee.length, offset: undefined }
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
context: callInfo.context,
|
|
157
|
+
isMethodCall: callInfo.isMethodCall,
|
|
158
|
+
receiver: callInfo.receiver
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
ts.forEachChild(node, findCallsInNode);
|
|
164
|
+
};
|
|
165
|
+
findCallsInNode(functionNode.body);
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
// Parser 失敗,返回空結果
|
|
169
|
+
}
|
|
170
|
+
return outgoing;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* 在 AST 中找到目標函數節點
|
|
174
|
+
* @param range 預留參數:未來可用於精確定位同名函數
|
|
175
|
+
*/
|
|
176
|
+
findFunctionNode(sourceFile, functionName, _range // Reserved: 未來可用於區分同名但不同位置的函數
|
|
177
|
+
) {
|
|
178
|
+
let result = null;
|
|
179
|
+
const visit = (node) => {
|
|
180
|
+
if (result) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
// FunctionDeclaration
|
|
184
|
+
if (ts.isFunctionDeclaration(node) && node.name?.text === functionName) {
|
|
185
|
+
result = node;
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
// MethodDeclaration
|
|
189
|
+
if (ts.isMethodDeclaration(node) && ts.isIdentifier(node.name) && node.name.text === functionName) {
|
|
190
|
+
result = node;
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
// Arrow function 或 function expression 賦值給變數
|
|
194
|
+
if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name)) {
|
|
195
|
+
if (node.name.text === functionName && node.initializer) {
|
|
196
|
+
if (ts.isArrowFunction(node.initializer)) {
|
|
197
|
+
result = node.initializer;
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (ts.isFunctionExpression(node.initializer)) {
|
|
201
|
+
result = node.initializer;
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
ts.forEachChild(node, visit);
|
|
207
|
+
};
|
|
208
|
+
visit(sourceFile);
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* 提取 CallExpression 的資訊
|
|
213
|
+
*/
|
|
214
|
+
extractCallInfo(node, sourceFile) {
|
|
215
|
+
const expr = node.expression;
|
|
216
|
+
let callee;
|
|
217
|
+
let isMethodCall = false;
|
|
218
|
+
let receiver;
|
|
219
|
+
if (ts.isIdentifier(expr)) {
|
|
220
|
+
callee = expr.text;
|
|
221
|
+
}
|
|
222
|
+
else if (ts.isPropertyAccessExpression(expr)) {
|
|
223
|
+
callee = expr.name.text;
|
|
224
|
+
isMethodCall = true;
|
|
225
|
+
receiver = expr.expression.getText(sourceFile);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
// 不支援的呼叫類型(如 computed property access)
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
232
|
+
const lines = sourceFile.text.split('\n');
|
|
233
|
+
const lineText = lines[line] || '';
|
|
234
|
+
return {
|
|
235
|
+
callee,
|
|
236
|
+
line: line + 1, // 轉為 1-based
|
|
237
|
+
column: character + 1,
|
|
238
|
+
context: lineText.trim(),
|
|
239
|
+
isMethodCall,
|
|
240
|
+
receiver
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* 找出某行所在的外層函數
|
|
245
|
+
*/
|
|
246
|
+
async findEnclosingFunction(filePath, line) {
|
|
247
|
+
const content = await this.readFile(filePath);
|
|
248
|
+
if (!content) {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
const parser = this.parserRegistry.getParser(this.getExtension(filePath));
|
|
252
|
+
if (!parser) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
try {
|
|
256
|
+
const ast = await parser.parse(content, filePath);
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
258
|
+
const sourceFile = ast.tsSourceFile;
|
|
259
|
+
if (!sourceFile) {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
const position = sourceFile.getPositionOfLineAndCharacter(line - 1, 0);
|
|
263
|
+
let enclosingFunction = null;
|
|
264
|
+
const visit = (node) => {
|
|
265
|
+
if (position >= node.getStart(sourceFile) && position < node.getEnd()) {
|
|
266
|
+
// FunctionDeclaration
|
|
267
|
+
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
268
|
+
enclosingFunction = node.name.text;
|
|
269
|
+
}
|
|
270
|
+
// MethodDeclaration
|
|
271
|
+
else if (ts.isMethodDeclaration(node) && ts.isIdentifier(node.name)) {
|
|
272
|
+
enclosingFunction = node.name.text;
|
|
273
|
+
}
|
|
274
|
+
// Arrow function 或 function expression 賦值給變數
|
|
275
|
+
else if (ts.isVariableDeclaration(node)
|
|
276
|
+
&& ts.isIdentifier(node.name)
|
|
277
|
+
&& node.initializer
|
|
278
|
+
&& (ts.isArrowFunction(node.initializer) || ts.isFunctionExpression(node.initializer))) {
|
|
279
|
+
enclosingFunction = node.name.text;
|
|
280
|
+
}
|
|
281
|
+
ts.forEachChild(node, visit);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
visit(sourceFile);
|
|
285
|
+
return enclosingFunction ? { name: enclosingFunction, file: filePath } : null;
|
|
286
|
+
}
|
|
287
|
+
catch {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* 取得某行的程式碼內容
|
|
293
|
+
*/
|
|
294
|
+
async getLineContext(filePath, line) {
|
|
295
|
+
const content = await this.readFile(filePath);
|
|
296
|
+
if (!content) {
|
|
297
|
+
return '';
|
|
298
|
+
}
|
|
299
|
+
const lines = content.split('\n');
|
|
300
|
+
return lines[line - 1]?.trim() || '';
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* 讀取檔案內容
|
|
304
|
+
*/
|
|
305
|
+
async readFile(filePath) {
|
|
306
|
+
try {
|
|
307
|
+
const content = await this.fileSystem.readFile(filePath, 'utf-8');
|
|
308
|
+
return typeof content === 'string' ? content : content.toString('utf-8');
|
|
309
|
+
}
|
|
310
|
+
catch {
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* 取得檔案副檔名
|
|
316
|
+
*/
|
|
317
|
+
getExtension(filePath) {
|
|
318
|
+
const lastDot = filePath.lastIndexOf('.');
|
|
319
|
+
return lastDot >= 0 ? filePath.substring(lastDot) : '';
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* 建立 CallHierarchyAnalyzer 實例
|
|
324
|
+
*/
|
|
325
|
+
export function createCallHierarchyAnalyzer(parserRegistry, fileSystem) {
|
|
326
|
+
return new CallHierarchyAnalyzer(parserRegistry, fileSystem);
|
|
327
|
+
}
|
|
328
|
+
//# sourceMappingURL=call-hierarchy-analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-hierarchy-analyzer.js","sourceRoot":"","sources":["../../../src/core/shared/call-hierarchy-analyzer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAKjC,OAAO,EAAE,kBAAkB,EAAqB,MAAM,oBAAoB,CAAC;AAmC3E;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAIb;IACA;IAJF,YAAY,CAAe;IAE5C,YACmB,cAA8B,EAC9B,UAAuB;QADvB,mBAAc,GAAd,cAAc,CAAgB;QAC9B,eAAU,GAAV,UAAU,CAAa;QAExC,IAAI,CAAC,YAAY,GAAG,kBAAkB,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IACrE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CACX,YAAoB,EACpB,YAA+B,EAC/B,OAA6B;QAE7B,YAAY;QACZ,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QACjF,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,IAAI,CAAC,qBAAqB,CAC/B,YAAY,EACZ,UAAU,CAAC,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
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/shared/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 統一的符號查找器
|
|
3
|
+
* 整合 AST 分析和文字匹配,提供跨檔案符號查找能力
|
|
4
|
+
*/
|
|
5
|
+
import type { Range, Location } from '../../shared/types/core.js';
|
|
6
|
+
import type { Symbol } from '../../shared/types/symbol.js';
|
|
7
|
+
import type { ParserRegistry } from '../../infrastructure/parser/registry.js';
|
|
8
|
+
import type { IFileSystem } from '../../infrastructure/storage/file-system.interface.js';
|
|
9
|
+
/**
|
|
10
|
+
* 符號引用
|
|
11
|
+
*/
|
|
12
|
+
export interface SymbolReference {
|
|
13
|
+
readonly symbolName: string;
|
|
14
|
+
readonly location: Location;
|
|
15
|
+
readonly type: SymbolReferenceType;
|
|
16
|
+
readonly context?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 符號引用類型
|
|
20
|
+
*/
|
|
21
|
+
export declare enum SymbolReferenceType {
|
|
22
|
+
Definition = "definition",
|
|
23
|
+
Usage = "usage",
|
|
24
|
+
Import = "import",
|
|
25
|
+
Export = "export"
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 函式呼叫點
|
|
29
|
+
*/
|
|
30
|
+
export interface CallSite {
|
|
31
|
+
readonly functionName: string;
|
|
32
|
+
readonly location: Location;
|
|
33
|
+
readonly arguments: readonly CallSiteArgument[];
|
|
34
|
+
readonly isMethodCall: boolean;
|
|
35
|
+
readonly receiver?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 呼叫點參數
|
|
39
|
+
*/
|
|
40
|
+
export interface CallSiteArgument {
|
|
41
|
+
readonly index: number;
|
|
42
|
+
readonly name?: string;
|
|
43
|
+
readonly value: string;
|
|
44
|
+
readonly range: Range;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 類別成員
|
|
48
|
+
*/
|
|
49
|
+
export interface ClassMember {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly type: ClassMemberType;
|
|
52
|
+
readonly location: Location;
|
|
53
|
+
readonly modifiers: readonly string[];
|
|
54
|
+
readonly valueType?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 類別成員類型
|
|
58
|
+
*/
|
|
59
|
+
export declare enum ClassMemberType {
|
|
60
|
+
Method = "method",
|
|
61
|
+
Property = "property",
|
|
62
|
+
Getter = "getter",
|
|
63
|
+
Setter = "setter",
|
|
64
|
+
Constructor = "constructor"
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 符號定義
|
|
68
|
+
*/
|
|
69
|
+
export interface SymbolDefinition {
|
|
70
|
+
readonly symbol: Symbol;
|
|
71
|
+
readonly signature?: string;
|
|
72
|
+
readonly documentation?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 符號查找器
|
|
76
|
+
*/
|
|
77
|
+
export declare class SymbolFinder {
|
|
78
|
+
private readonly parserRegistry;
|
|
79
|
+
private readonly fileSystem;
|
|
80
|
+
constructor(parserRegistry: ParserRegistry, fileSystem: IFileSystem);
|
|
81
|
+
/**
|
|
82
|
+
* 查找符號定義
|
|
83
|
+
*/
|
|
84
|
+
findDefinition(filePath: string, symbolName: string): Promise<SymbolDefinition | null>;
|
|
85
|
+
/**
|
|
86
|
+
* 查找所有引用
|
|
87
|
+
*/
|
|
88
|
+
findReferences(symbolName: string, projectFiles: readonly string[]): Promise<SymbolReference[]>;
|
|
89
|
+
/**
|
|
90
|
+
* 查找檔案中的符號引用
|
|
91
|
+
*/
|
|
92
|
+
findReferencesInFile(filePath: string, symbolName: string): Promise<SymbolReference[]>;
|
|
93
|
+
/**
|
|
94
|
+
* 查找函式的所有呼叫點
|
|
95
|
+
*/
|
|
96
|
+
findCallSites(functionName: string, projectFiles: readonly string[]): Promise<CallSite[]>;
|
|
97
|
+
/**
|
|
98
|
+
* 查找檔案中的函式呼叫點
|
|
99
|
+
*/
|
|
100
|
+
findCallSitesInFile(filePath: string, functionName: string): Promise<CallSite[]>;
|
|
101
|
+
/**
|
|
102
|
+
* 查找類別成員
|
|
103
|
+
*/
|
|
104
|
+
findClassMembers(filePath: string, className: string): Promise<ClassMember[]>;
|
|
105
|
+
/**
|
|
106
|
+
* 讀取檔案內容
|
|
107
|
+
*/
|
|
108
|
+
private readFile;
|
|
109
|
+
/**
|
|
110
|
+
* 取得對應的 Parser
|
|
111
|
+
*/
|
|
112
|
+
private getParser;
|
|
113
|
+
/**
|
|
114
|
+
* 取得檔案副檔名
|
|
115
|
+
*/
|
|
116
|
+
private getFileExtension;
|
|
117
|
+
/**
|
|
118
|
+
* 使用文字匹配查找引用(降級方法)
|
|
119
|
+
*/
|
|
120
|
+
private findReferencesByText;
|
|
121
|
+
/**
|
|
122
|
+
* 提取函式簽名
|
|
123
|
+
*/
|
|
124
|
+
private extractSignature;
|
|
125
|
+
/**
|
|
126
|
+
* 提取文件註解
|
|
127
|
+
*/
|
|
128
|
+
private extractDocumentation;
|
|
129
|
+
/**
|
|
130
|
+
* 提取參數字串
|
|
131
|
+
*/
|
|
132
|
+
private extractArgumentsString;
|
|
133
|
+
/**
|
|
134
|
+
* 解析參數
|
|
135
|
+
*/
|
|
136
|
+
private parseArguments;
|
|
137
|
+
/**
|
|
138
|
+
* 分割參數(考慮巢狀括號)
|
|
139
|
+
*/
|
|
140
|
+
private splitArguments;
|
|
141
|
+
/**
|
|
142
|
+
* 符號類型轉換為成員類型
|
|
143
|
+
*/
|
|
144
|
+
private symbolTypeToMemberType;
|
|
145
|
+
/**
|
|
146
|
+
* 跳脫正則表達式特殊字元
|
|
147
|
+
*/
|
|
148
|
+
private escapeRegex;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* 建立 SymbolFinder 實例
|
|
152
|
+
*/
|
|
153
|
+
export declare function createSymbolFinder(parserRegistry: ParserRegistry, fileSystem: IFileSystem): SymbolFinder;
|
|
154
|
+
//# sourceMappingURL=symbol-finder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symbol-finder.d.ts","sourceRoot":"","sources":["../../../src/core/shared/symbol-finder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAC;AAEpF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,oBAAY,mBAAmB;IAC7B,UAAU,eAAe;IACzB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAChD,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAA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