agent-ide 0.8.2 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/dist/core/call-hierarchy/call-hierarchy-analyzer.d.ts +1 -8
- package/dist/core/call-hierarchy/call-hierarchy-analyzer.d.ts.map +1 -1
- package/dist/core/call-hierarchy/call-hierarchy-analyzer.js +9 -25
- package/dist/core/call-hierarchy/call-hierarchy-analyzer.js.map +1 -1
- package/dist/core/change-signature/call-site-updater.d.ts +106 -0
- package/dist/core/change-signature/call-site-updater.d.ts.map +1 -0
- package/dist/core/change-signature/call-site-updater.js +338 -0
- package/dist/core/change-signature/call-site-updater.js.map +1 -0
- package/dist/core/change-signature/change-signature-service.d.ts +5 -63
- package/dist/core/change-signature/change-signature-service.d.ts.map +1 -1
- package/dist/core/change-signature/change-signature-service.js +27 -511
- package/dist/core/change-signature/change-signature-service.js.map +1 -1
- package/dist/core/change-signature/index.d.ts +4 -0
- package/dist/core/change-signature/index.d.ts.map +1 -1
- package/dist/core/change-signature/index.js +5 -0
- package/dist/core/change-signature/index.js.map +1 -1
- package/dist/core/change-signature/signature-parser.d.ts +1 -8
- package/dist/core/change-signature/signature-parser.d.ts.map +1 -1
- package/dist/core/change-signature/signature-parser.js +7 -23
- package/dist/core/change-signature/signature-parser.js.map +1 -1
- package/dist/core/change-signature/signature-transformer.d.ts +20 -0
- package/dist/core/change-signature/signature-transformer.d.ts.map +1 -0
- package/dist/core/change-signature/signature-transformer.js +91 -0
- package/dist/core/change-signature/signature-transformer.js.map +1 -0
- package/dist/core/change-signature/signature-validator.d.ts +30 -0
- package/dist/core/change-signature/signature-validator.d.ts.map +1 -0
- package/dist/core/change-signature/signature-validator.js +152 -0
- package/dist/core/change-signature/signature-validator.js.map +1 -0
- package/dist/core/change-signature/utils.d.ts +19 -0
- package/dist/core/change-signature/utils.d.ts.map +1 -0
- package/dist/core/change-signature/utils.js +23 -0
- package/dist/core/change-signature/utils.js.map +1 -0
- package/dist/core/cycles/cycle-detector.d.ts +1 -1
- package/dist/core/cycles/cycle-detector.d.ts.map +1 -1
- package/dist/core/cycles/cycle-detector.js +16 -8
- package/dist/core/cycles/cycle-detector.js.map +1 -1
- package/dist/core/cycles/index.d.ts +1 -1
- package/dist/core/cycles/index.d.ts.map +1 -1
- package/dist/core/cycles/index.js +1 -1
- package/dist/core/cycles/index.js.map +1 -1
- package/dist/core/cycles/types.d.ts +20 -4
- package/dist/core/cycles/types.d.ts.map +1 -1
- package/dist/core/cycles/types.js +22 -4
- package/dist/core/cycles/types.js.map +1 -1
- package/dist/core/deadcode/dead-code-detector.d.ts +2 -13
- package/dist/core/deadcode/dead-code-detector.d.ts.map +1 -1
- package/dist/core/deadcode/dead-code-detector.js +6 -29
- package/dist/core/deadcode/dead-code-detector.js.map +1 -1
- package/dist/core/deadcode/dead-code-remover.js +4 -4
- package/dist/core/deadcode/dead-code-remover.js.map +1 -1
- package/dist/core/deadcode/import-cleaner.js +1 -1
- package/dist/core/deadcode/import-cleaner.js.map +1 -1
- package/dist/core/deadcode/import-parser.d.ts +0 -4
- package/dist/core/deadcode/import-parser.d.ts.map +1 -1
- package/dist/core/deadcode/import-parser.js +4 -10
- package/dist/core/deadcode/import-parser.js.map +1 -1
- package/dist/core/deadcode/range-expander.d.ts +0 -4
- package/dist/core/deadcode/range-expander.d.ts.map +1 -1
- package/dist/core/deadcode/range-expander.js +14 -10
- package/dist/core/deadcode/range-expander.js.map +1 -1
- package/dist/core/find-references/index.d.ts +3 -3
- package/dist/core/find-references/index.d.ts.map +1 -1
- package/dist/core/find-references/index.js +2 -2
- package/dist/core/find-references/index.js.map +1 -1
- package/dist/core/foundations/dependency-graph/dependency-graph.d.ts.map +1 -0
- package/dist/core/foundations/dependency-graph/dependency-graph.js.map +1 -0
- package/dist/core/foundations/dependency-graph/index.d.ts.map +1 -0
- package/dist/core/foundations/dependency-graph/index.js.map +1 -0
- package/dist/core/foundations/dependency-graph/types.d.ts.map +1 -0
- package/dist/core/foundations/dependency-graph/types.js.map +1 -0
- package/dist/core/foundations/file-utils.d.ts +50 -0
- package/dist/core/foundations/file-utils.d.ts.map +1 -0
- package/dist/core/foundations/file-utils.js +75 -0
- package/dist/core/foundations/file-utils.js.map +1 -0
- package/dist/core/foundations/index.d.ts +13 -0
- package/dist/core/foundations/index.d.ts.map +1 -0
- package/dist/core/foundations/index.js +17 -0
- package/dist/core/foundations/index.js.map +1 -0
- package/dist/core/foundations/indexing/file-index.d.ts.map +1 -0
- package/dist/core/foundations/indexing/file-index.js.map +1 -0
- package/dist/core/foundations/indexing/index-engine.d.ts.map +1 -0
- package/dist/core/foundations/indexing/index-engine.js.map +1 -0
- package/dist/core/foundations/indexing/index.d.ts.map +1 -0
- package/dist/core/foundations/indexing/index.js.map +1 -0
- package/dist/core/foundations/indexing/symbol-index.d.ts.map +1 -0
- package/dist/core/foundations/indexing/symbol-index.js.map +1 -0
- package/dist/core/{shared → foundations}/indexing/types.d.ts +1 -1
- package/dist/core/foundations/indexing/types.d.ts.map +1 -0
- package/dist/core/{shared → foundations}/indexing/types.js +11 -1
- package/dist/core/foundations/indexing/types.js.map +1 -0
- package/dist/core/foundations/symbol-finder/call-site-parser.d.ts.map +1 -0
- package/dist/core/foundations/symbol-finder/call-site-parser.js.map +1 -0
- package/dist/core/foundations/symbol-finder/index.d.ts.map +1 -0
- package/dist/core/foundations/symbol-finder/index.js.map +1 -0
- package/dist/core/{shared → foundations}/symbol-finder/symbol-finder.d.ts +24 -10
- package/dist/core/foundations/symbol-finder/symbol-finder.d.ts.map +1 -0
- package/dist/core/{shared → foundations}/symbol-finder/symbol-finder.js +127 -149
- package/dist/core/foundations/symbol-finder/symbol-finder.js.map +1 -0
- package/dist/core/foundations/symbol-finder/text-matcher.d.ts.map +1 -0
- package/dist/core/foundations/symbol-finder/text-matcher.js.map +1 -0
- package/dist/core/foundations/symbol-finder/types.d.ts.map +1 -0
- package/dist/core/foundations/symbol-finder/types.js.map +1 -0
- package/dist/core/impact/dependency-extractor.d.ts +25 -0
- package/dist/core/impact/dependency-extractor.d.ts.map +1 -0
- package/dist/core/impact/dependency-extractor.js +65 -0
- package/dist/core/impact/dependency-extractor.js.map +1 -0
- package/dist/core/impact/file-scanner.d.ts +52 -0
- package/dist/core/impact/file-scanner.d.ts.map +1 -0
- package/dist/core/impact/file-scanner.js +131 -0
- package/dist/core/impact/file-scanner.js.map +1 -0
- package/dist/core/impact/impact-analyzer.d.ts +4 -65
- package/dist/core/impact/impact-analyzer.d.ts.map +1 -1
- package/dist/core/impact/impact-analyzer.js +14 -313
- package/dist/core/impact/impact-analyzer.js.map +1 -1
- package/dist/core/impact/index.d.ts +3 -0
- package/dist/core/impact/index.d.ts.map +1 -1
- package/dist/core/impact/index.js +3 -0
- package/dist/core/impact/index.js.map +1 -1
- package/dist/core/impact/path-resolver.d.ts +35 -0
- package/dist/core/impact/path-resolver.d.ts.map +1 -0
- package/dist/core/impact/path-resolver.js +166 -0
- package/dist/core/impact/path-resolver.js.map +1 -0
- package/dist/core/move/file-scanner.d.ts +48 -0
- package/dist/core/move/file-scanner.d.ts.map +1 -0
- package/dist/core/move/file-scanner.js +137 -0
- package/dist/core/move/file-scanner.js.map +1 -0
- package/dist/core/move/import-resolver.d.ts +5 -0
- package/dist/core/move/import-resolver.d.ts.map +1 -1
- package/dist/core/move/import-resolver.js +24 -6
- package/dist/core/move/import-resolver.js.map +1 -1
- package/dist/core/move/index.d.ts +7 -3
- package/dist/core/move/index.d.ts.map +1 -1
- package/dist/core/move/index.js +7 -2
- package/dist/core/move/index.js.map +1 -1
- package/dist/core/move/move-service.d.ts +11 -60
- package/dist/core/move/move-service.d.ts.map +1 -1
- package/dist/core/move/move-service.js +16 -352
- package/dist/core/move/move-service.js.map +1 -1
- package/dist/core/move/path-calculator.d.ts +49 -0
- package/dist/core/move/path-calculator.d.ts.map +1 -0
- package/dist/core/move/path-calculator.js +158 -0
- package/dist/core/move/path-calculator.js.map +1 -0
- package/dist/core/move/path-parser.d.ts +33 -0
- package/dist/core/move/path-parser.d.ts.map +1 -0
- package/dist/core/move/path-parser.js +53 -0
- package/dist/core/move/path-parser.js.map +1 -0
- package/dist/core/move/path-utils.d.ts +70 -0
- package/dist/core/move/path-utils.d.ts.map +1 -0
- package/dist/core/move/path-utils.js +201 -0
- package/dist/core/move/path-utils.js.map +1 -0
- package/dist/core/move/types.d.ts +81 -18
- package/dist/core/move/types.d.ts.map +1 -1
- package/dist/core/move/types.js +73 -5
- package/dist/core/move/types.js.map +1 -1
- package/dist/core/move-member/change-applier.d.ts +23 -0
- package/dist/core/move-member/change-applier.d.ts.map +1 -0
- package/dist/core/move-member/change-applier.js +51 -0
- package/dist/core/move-member/change-applier.js.map +1 -0
- package/dist/core/move-member/extractors/index.d.ts +7 -0
- package/dist/core/move-member/extractors/index.d.ts.map +1 -0
- package/dist/core/move-member/extractors/index.js +9 -0
- package/dist/core/move-member/extractors/index.js.map +1 -0
- package/dist/core/move-member/extractors/javascript-extractor.d.ts +29 -0
- package/dist/core/move-member/extractors/javascript-extractor.d.ts.map +1 -0
- package/dist/core/move-member/extractors/javascript-extractor.js +33 -0
- package/dist/core/move-member/extractors/javascript-extractor.js.map +1 -0
- package/dist/core/move-member/extractors/typescript-extractor.d.ts +40 -0
- package/dist/core/move-member/extractors/typescript-extractor.d.ts.map +1 -0
- package/dist/core/move-member/extractors/typescript-extractor.js +286 -0
- package/dist/core/move-member/extractors/typescript-extractor.js.map +1 -0
- package/dist/core/move-member/file-change-preparer.d.ts +49 -0
- package/dist/core/move-member/file-change-preparer.d.ts.map +1 -0
- package/dist/core/move-member/file-change-preparer.js +340 -0
- package/dist/core/move-member/file-change-preparer.js.map +1 -0
- package/dist/core/move-member/index.d.ts +4 -1
- package/dist/core/move-member/index.d.ts.map +1 -1
- package/dist/core/move-member/index.js +3 -0
- package/dist/core/move-member/index.js.map +1 -1
- package/dist/core/move-member/member-extractor.d.ts +21 -60
- package/dist/core/move-member/member-extractor.d.ts.map +1 -1
- package/dist/core/move-member/member-extractor.js +59 -335
- package/dist/core/move-member/member-extractor.js.map +1 -1
- package/dist/core/move-member/move-member-service.d.ts +3 -78
- package/dist/core/move-member/move-member-service.d.ts.map +1 -1
- package/dist/core/move-member/move-member-service.js +35 -419
- package/dist/core/move-member/move-member-service.js.map +1 -1
- package/dist/core/move-member/reference-updater.d.ts +73 -0
- package/dist/core/move-member/reference-updater.d.ts.map +1 -0
- package/dist/core/move-member/reference-updater.js +288 -0
- package/dist/core/move-member/reference-updater.js.map +1 -0
- package/dist/core/move-member/types.d.ts +17 -2
- package/dist/core/move-member/types.d.ts.map +1 -1
- package/dist/core/move-member/types.js.map +1 -1
- package/dist/core/move-member/utils/range-finder.d.ts +40 -0
- package/dist/core/move-member/utils/range-finder.d.ts.map +1 -0
- package/dist/core/move-member/utils/range-finder.js +101 -0
- package/dist/core/move-member/utils/range-finder.js.map +1 -0
- package/dist/core/rename/reference-updater.d.ts +5 -0
- package/dist/core/rename/reference-updater.d.ts.map +1 -1
- package/dist/core/rename/reference-updater.js +21 -5
- package/dist/core/rename/reference-updater.js.map +1 -1
- package/dist/core/rename/rename-engine.d.ts +5 -3
- package/dist/core/rename/rename-engine.d.ts.map +1 -1
- package/dist/core/rename/rename-engine.js +29 -8
- package/dist/core/rename/rename-engine.js.map +1 -1
- package/dist/core/rename/types.d.ts.map +1 -1
- package/dist/core/snapshot/snapshot-generator.d.ts +0 -29
- package/dist/core/snapshot/snapshot-generator.d.ts.map +1 -1
- package/dist/core/snapshot/snapshot-generator.js +6 -183
- package/dist/core/snapshot/snapshot-generator.js.map +1 -1
- package/dist/core/snapshot/utils/bracket-balancer.d.ts +27 -0
- package/dist/core/snapshot/utils/bracket-balancer.d.ts.map +1 -0
- package/dist/core/snapshot/utils/bracket-balancer.js +70 -0
- package/dist/core/snapshot/utils/bracket-balancer.js.map +1 -0
- package/dist/core/snapshot/utils/factory-pattern-detector.d.ts +22 -0
- package/dist/core/snapshot/utils/factory-pattern-detector.d.ts.map +1 -0
- package/dist/core/snapshot/utils/factory-pattern-detector.js +70 -0
- package/dist/core/snapshot/utils/factory-pattern-detector.js.map +1 -0
- package/dist/core/snapshot/utils/index.d.ts +7 -0
- package/dist/core/snapshot/utils/index.d.ts.map +1 -0
- package/dist/core/snapshot/utils/index.js +7 -0
- package/dist/core/snapshot/utils/index.js.map +1 -0
- package/dist/core/snapshot/utils/symbol-formatter.d.ts +37 -0
- package/dist/core/snapshot/utils/symbol-formatter.d.ts.map +1 -0
- package/dist/core/snapshot/utils/symbol-formatter.js +89 -0
- package/dist/core/snapshot/utils/symbol-formatter.js.map +1 -0
- package/dist/infrastructure/changeset/change-applicator.d.ts +1 -1
- package/dist/infrastructure/changeset/change-applicator.d.ts.map +1 -1
- package/dist/infrastructure/changeset/change-applicator.js +22 -21
- package/dist/infrastructure/changeset/change-applicator.js.map +1 -1
- package/dist/infrastructure/changeset/changeset-builder.d.ts +2 -2
- package/dist/infrastructure/changeset/changeset-builder.d.ts.map +1 -1
- package/dist/infrastructure/changeset/changeset-builder.js +11 -6
- package/dist/infrastructure/changeset/changeset-builder.js.map +1 -1
- package/dist/infrastructure/changeset/changeset-converter.d.ts +1 -1
- package/dist/infrastructure/changeset/changeset-converter.d.ts.map +1 -1
- package/dist/infrastructure/changeset/changeset-converter.js +9 -8
- package/dist/infrastructure/changeset/changeset-converter.js.map +1 -1
- package/dist/infrastructure/changeset/index.d.ts +1 -0
- package/dist/infrastructure/changeset/index.d.ts.map +1 -1
- package/dist/infrastructure/changeset/index.js +2 -0
- package/dist/infrastructure/changeset/index.js.map +1 -1
- package/dist/infrastructure/changeset/types.d.ts +41 -4
- package/dist/infrastructure/changeset/types.d.ts.map +1 -1
- package/dist/infrastructure/changeset/types.js +41 -1
- package/dist/infrastructure/changeset/types.js.map +1 -1
- package/dist/infrastructure/formatters/query-formatter.d.ts +8 -62
- package/dist/infrastructure/formatters/query-formatter.d.ts.map +1 -1
- package/dist/infrastructure/formatters/query-formatter.js +29 -438
- package/dist/infrastructure/formatters/query-formatter.js.map +1 -1
- package/dist/infrastructure/formatters/strategies/analyze-formatter.d.ts +24 -0
- package/dist/infrastructure/formatters/strategies/analyze-formatter.d.ts.map +1 -0
- package/dist/infrastructure/formatters/strategies/analyze-formatter.js +107 -0
- package/dist/infrastructure/formatters/strategies/analyze-formatter.js.map +1 -0
- package/dist/infrastructure/formatters/strategies/base-formatter.d.ts +67 -0
- package/dist/infrastructure/formatters/strategies/base-formatter.d.ts.map +1 -0
- package/dist/infrastructure/formatters/strategies/base-formatter.js +75 -0
- package/dist/infrastructure/formatters/strategies/base-formatter.js.map +1 -0
- package/dist/infrastructure/formatters/strategies/call-hierarchy-formatter.d.ts +19 -0
- package/dist/infrastructure/formatters/strategies/call-hierarchy-formatter.d.ts.map +1 -0
- package/dist/infrastructure/formatters/strategies/call-hierarchy-formatter.js +77 -0
- package/dist/infrastructure/formatters/strategies/call-hierarchy-formatter.js.map +1 -0
- package/dist/infrastructure/formatters/strategies/deps-formatter.d.ts +15 -0
- package/dist/infrastructure/formatters/strategies/deps-formatter.d.ts.map +1 -0
- package/dist/infrastructure/formatters/strategies/deps-formatter.js +47 -0
- package/dist/infrastructure/formatters/strategies/deps-formatter.js.map +1 -0
- package/dist/infrastructure/formatters/strategies/find-references-formatter.d.ts +23 -0
- package/dist/infrastructure/formatters/strategies/find-references-formatter.d.ts.map +1 -0
- package/dist/infrastructure/formatters/strategies/find-references-formatter.js +71 -0
- package/dist/infrastructure/formatters/strategies/find-references-formatter.js.map +1 -0
- package/dist/infrastructure/formatters/strategies/index.d.ts +11 -0
- package/dist/infrastructure/formatters/strategies/index.d.ts.map +1 -0
- package/dist/infrastructure/formatters/strategies/index.js +11 -0
- package/dist/infrastructure/formatters/strategies/index.js.map +1 -0
- package/dist/infrastructure/formatters/strategies/search-formatter.d.ts +15 -0
- package/dist/infrastructure/formatters/strategies/search-formatter.d.ts.map +1 -0
- package/dist/infrastructure/formatters/strategies/search-formatter.js +32 -0
- package/dist/infrastructure/formatters/strategies/search-formatter.js.map +1 -0
- package/dist/infrastructure/formatters/strategies/snapshot-formatter.d.ts +20 -0
- package/dist/infrastructure/formatters/strategies/snapshot-formatter.d.ts.map +1 -0
- package/dist/infrastructure/formatters/strategies/snapshot-formatter.js +101 -0
- package/dist/infrastructure/formatters/strategies/snapshot-formatter.js.map +1 -0
- package/dist/infrastructure/parser/registry.js.map +1 -1
- package/dist/interfaces/cli/cli.d.ts.map +1 -1
- package/dist/interfaces/cli/cli.js +1 -2
- package/dist/interfaces/cli/cli.js.map +1 -1
- package/dist/interfaces/cli/commands/call-hierarchy.command.js +1 -1
- package/dist/interfaces/cli/commands/call-hierarchy.command.js.map +1 -1
- package/dist/interfaces/cli/commands/change-signature.command.js +3 -2
- package/dist/interfaces/cli/commands/change-signature.command.js.map +1 -1
- package/dist/interfaces/cli/commands/deadcode.command.js +1 -1
- package/dist/interfaces/cli/commands/deadcode.command.js.map +1 -1
- package/dist/interfaces/cli/commands/find-references.command.js +2 -2
- package/dist/interfaces/cli/commands/find-references.command.js.map +1 -1
- package/dist/interfaces/cli/commands/index.d.ts +0 -1
- package/dist/interfaces/cli/commands/index.d.ts.map +1 -1
- package/dist/interfaces/cli/commands/index.js +0 -1
- package/dist/interfaces/cli/commands/index.js.map +1 -1
- package/dist/interfaces/cli/commands/move.command.d.ts +1 -0
- package/dist/interfaces/cli/commands/move.command.d.ts.map +1 -1
- package/dist/interfaces/cli/commands/move.command.js +127 -11
- package/dist/interfaces/cli/commands/move.command.js.map +1 -1
- package/dist/interfaces/cli/commands/rename.command.d.ts.map +1 -1
- package/dist/interfaces/cli/commands/rename.command.js +116 -8
- package/dist/interfaces/cli/commands/rename.command.js.map +1 -1
- package/dist/interfaces/cli/preview-output-handler.d.ts.map +1 -1
- package/dist/interfaces/cli/preview-output-handler.js.map +1 -1
- package/dist/interfaces/cli/unified-output-handler.d.ts.map +1 -1
- package/dist/interfaces/cli/unified-output-handler.js.map +1 -1
- package/dist/plugins/javascript/declaration-analyzer.d.ts.map +1 -1
- package/dist/plugins/javascript/declaration-analyzer.js +9 -0
- package/dist/plugins/javascript/declaration-analyzer.js.map +1 -1
- package/dist/plugins/javascript/parser.d.ts +0 -2
- package/dist/plugins/javascript/parser.d.ts.map +1 -1
- package/dist/plugins/javascript/parser.js +3 -19
- package/dist/plugins/javascript/parser.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/shared/index.d.ts +1 -0
- package/dist/plugins/shared/index.d.ts.map +1 -1
- package/dist/plugins/shared/index.js +2 -0
- package/dist/plugins/shared/index.js.map +1 -1
- package/dist/plugins/shared/utils/async.d.ts.map +1 -1
- package/dist/plugins/shared/utils/async.js.map +1 -1
- package/dist/plugins/shared/utils/object.js +5 -5
- package/dist/plugins/shared/utils/object.js.map +1 -1
- package/dist/plugins/shared/validators.d.ts +15 -0
- package/dist/plugins/shared/validators.d.ts.map +1 -0
- package/dist/plugins/shared/validators.js +29 -0
- package/dist/plugins/shared/validators.js.map +1 -0
- package/dist/plugins/typescript/declaration-analyzer.d.ts.map +1 -1
- package/dist/plugins/typescript/declaration-analyzer.js +4 -0
- package/dist/plugins/typescript/declaration-analyzer.js.map +1 -1
- package/dist/plugins/typescript/dependency-analyzer.d.ts.map +1 -1
- package/dist/plugins/typescript/dependency-analyzer.js.map +1 -1
- package/dist/plugins/typescript/parser.d.ts +0 -2
- package/dist/plugins/typescript/parser.d.ts.map +1 -1
- package/dist/plugins/typescript/parser.js +3 -19
- package/dist/plugins/typescript/parser.js.map +1 -1
- package/dist/plugins/typescript/reference-finder.d.ts.map +1 -1
- package/dist/plugins/typescript/reference-finder.js +11 -2
- package/dist/plugins/typescript/reference-finder.js.map +1 -1
- package/dist/plugins/typescript/symbol-extractor.d.ts.map +1 -1
- package/dist/plugins/typescript/symbol-extractor.js +6 -2
- 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.map +1 -1
- package/package.json +1 -1
- package/dist/core/shared/dependency-graph/dependency-graph.d.ts.map +0 -1
- package/dist/core/shared/dependency-graph/dependency-graph.js.map +0 -1
- package/dist/core/shared/dependency-graph/index.d.ts.map +0 -1
- package/dist/core/shared/dependency-graph/index.js.map +0 -1
- package/dist/core/shared/dependency-graph/types.d.ts.map +0 -1
- package/dist/core/shared/dependency-graph/types.js.map +0 -1
- package/dist/core/shared/index.d.ts +0 -8
- package/dist/core/shared/index.d.ts.map +0 -1
- package/dist/core/shared/index.js +0 -11
- package/dist/core/shared/index.js.map +0 -1
- package/dist/core/shared/indexing/file-index.d.ts.map +0 -1
- package/dist/core/shared/indexing/file-index.js.map +0 -1
- package/dist/core/shared/indexing/index-engine.d.ts.map +0 -1
- package/dist/core/shared/indexing/index-engine.js.map +0 -1
- package/dist/core/shared/indexing/index.d.ts.map +0 -1
- package/dist/core/shared/indexing/index.js.map +0 -1
- package/dist/core/shared/indexing/symbol-index.d.ts.map +0 -1
- package/dist/core/shared/indexing/symbol-index.js.map +0 -1
- package/dist/core/shared/indexing/types.d.ts.map +0 -1
- package/dist/core/shared/indexing/types.js.map +0 -1
- package/dist/core/shared/symbol-finder/call-site-parser.d.ts.map +0 -1
- package/dist/core/shared/symbol-finder/call-site-parser.js.map +0 -1
- package/dist/core/shared/symbol-finder/index.d.ts.map +0 -1
- package/dist/core/shared/symbol-finder/index.js.map +0 -1
- package/dist/core/shared/symbol-finder/symbol-finder.d.ts.map +0 -1
- package/dist/core/shared/symbol-finder/symbol-finder.js.map +0 -1
- package/dist/core/shared/symbol-finder/text-matcher.d.ts.map +0 -1
- package/dist/core/shared/symbol-finder/text-matcher.js.map +0 -1
- package/dist/core/shared/symbol-finder/types.d.ts.map +0 -1
- package/dist/core/shared/symbol-finder/types.js.map +0 -1
- package/dist/interfaces/cli/commands/move-member.command.d.ts +0 -11
- package/dist/interfaces/cli/commands/move-member.command.d.ts.map +0 -1
- package/dist/interfaces/cli/commands/move-member.command.js +0 -140
- package/dist/interfaces/cli/commands/move-member.command.js.map +0 -1
- /package/dist/core/{shared → foundations}/dependency-graph/dependency-graph.d.ts +0 -0
- /package/dist/core/{shared → foundations}/dependency-graph/dependency-graph.js +0 -0
- /package/dist/core/{shared → foundations}/dependency-graph/index.d.ts +0 -0
- /package/dist/core/{shared → foundations}/dependency-graph/index.js +0 -0
- /package/dist/core/{shared → foundations}/dependency-graph/types.d.ts +0 -0
- /package/dist/core/{shared → foundations}/dependency-graph/types.js +0 -0
- /package/dist/core/{shared → foundations}/indexing/file-index.d.ts +0 -0
- /package/dist/core/{shared → foundations}/indexing/file-index.js +0 -0
- /package/dist/core/{shared → foundations}/indexing/index-engine.d.ts +0 -0
- /package/dist/core/{shared → foundations}/indexing/index-engine.js +0 -0
- /package/dist/core/{shared → foundations}/indexing/index.d.ts +0 -0
- /package/dist/core/{shared → foundations}/indexing/index.js +0 -0
- /package/dist/core/{shared → foundations}/indexing/symbol-index.d.ts +0 -0
- /package/dist/core/{shared → foundations}/indexing/symbol-index.js +0 -0
- /package/dist/core/{shared → foundations}/symbol-finder/call-site-parser.d.ts +0 -0
- /package/dist/core/{shared → foundations}/symbol-finder/call-site-parser.js +0 -0
- /package/dist/core/{shared → foundations}/symbol-finder/index.d.ts +0 -0
- /package/dist/core/{shared → foundations}/symbol-finder/index.js +0 -0
- /package/dist/core/{shared → foundations}/symbol-finder/text-matcher.d.ts +0 -0
- /package/dist/core/{shared → foundations}/symbol-finder/text-matcher.js +0 -0
- /package/dist/core/{shared → foundations}/symbol-finder/types.d.ts +0 -0
- /package/dist/core/{shared → foundations}/symbol-finder/types.js +0 -0
|
@@ -3,23 +3,34 @@
|
|
|
3
3
|
* 參數重構核心服務
|
|
4
4
|
*/
|
|
5
5
|
import * as path from 'path';
|
|
6
|
-
import { createChangesetBuilder } from '../../infrastructure/changeset/index.js';
|
|
6
|
+
import { createChangesetBuilder, ChangesetCommand, TextEditOperationType } from '../../infrastructure/changeset/index.js';
|
|
7
7
|
import { SignatureParser } from './signature-parser.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { SignatureValidator } from './signature-validator.js';
|
|
9
|
+
import { SignatureTransformer } from './signature-transformer.js';
|
|
10
|
+
import { CallSiteUpdater } from './call-site-updater.js';
|
|
11
|
+
import { ChangeSignatureErrorCode } from './types.js';
|
|
12
|
+
import { SymbolFinder, FileUtils, createFileUtils } from '../foundations/index.js';
|
|
10
13
|
/**
|
|
11
14
|
* Change Signature Service
|
|
12
15
|
*/
|
|
13
16
|
export class ChangeSignatureService {
|
|
14
17
|
parserRegistry;
|
|
15
18
|
fileSystem;
|
|
19
|
+
fileUtils;
|
|
16
20
|
signatureParser;
|
|
17
21
|
symbolFinder;
|
|
22
|
+
validator;
|
|
23
|
+
transformer;
|
|
24
|
+
callSiteUpdater;
|
|
18
25
|
constructor(parserRegistry, fileSystem) {
|
|
19
26
|
this.parserRegistry = parserRegistry;
|
|
20
27
|
this.fileSystem = fileSystem;
|
|
28
|
+
this.fileUtils = createFileUtils(fileSystem, parserRegistry);
|
|
21
29
|
this.signatureParser = new SignatureParser(parserRegistry, fileSystem);
|
|
22
30
|
this.symbolFinder = new SymbolFinder(parserRegistry, fileSystem);
|
|
31
|
+
this.validator = new SignatureValidator();
|
|
32
|
+
this.transformer = new SignatureTransformer();
|
|
33
|
+
this.callSiteUpdater = new CallSiteUpdater(fileSystem, parserRegistry);
|
|
23
34
|
}
|
|
24
35
|
/**
|
|
25
36
|
* 執行 Change Signature
|
|
@@ -31,19 +42,19 @@ export class ChangeSignatureService {
|
|
|
31
42
|
return this.createErrorResult(ChangeSignatureErrorCode.FunctionNotFound, `找不到函式: ${options.functionName}`);
|
|
32
43
|
}
|
|
33
44
|
// 2. 驗證變更
|
|
34
|
-
const validationErrors = this.validateChanges(originalSignature, options.changes);
|
|
45
|
+
const validationErrors = this.validator.validateChanges(originalSignature, options.changes);
|
|
35
46
|
if (validationErrors.length > 0) {
|
|
36
47
|
return this.createErrorResult(validationErrors[0].code, validationErrors[0].message);
|
|
37
48
|
}
|
|
38
49
|
// 3. 計算新簽名
|
|
39
|
-
const newSignature = this.applyChangesToSignature(originalSignature, options.changes);
|
|
50
|
+
const newSignature = this.transformer.applyChangesToSignature(originalSignature, options.changes);
|
|
40
51
|
// 4. 取得所有呼叫點
|
|
41
52
|
const projectFiles = options.targetFiles ?? await this.getProjectFiles(options.projectRoot);
|
|
42
53
|
const callSites = await this.symbolFinder.findCallSites(options.functionName, projectFiles);
|
|
43
54
|
// 5. 生成定義更新
|
|
44
55
|
const definitionUpdate = await this.generateDefinitionUpdate(options.filePath, originalSignature, newSignature);
|
|
45
56
|
// 6. 生成呼叫點更新
|
|
46
|
-
const callSiteUpdates = await this.generateCallSiteUpdates(callSites, originalSignature, newSignature, options.changes);
|
|
57
|
+
const callSiteUpdates = await this.callSiteUpdater.generateCallSiteUpdates(callSites, originalSignature, newSignature, options.changes);
|
|
47
58
|
// 7. 執行或預覽
|
|
48
59
|
if (!options.preview) {
|
|
49
60
|
await this.applyChanges(definitionUpdate, callSiteUpdates);
|
|
@@ -75,7 +86,7 @@ export class ChangeSignatureService {
|
|
|
75
86
|
* @returns Changeset 物件
|
|
76
87
|
*/
|
|
77
88
|
async generateChangeset(options) {
|
|
78
|
-
const builder = createChangesetBuilder().forCommand(
|
|
89
|
+
const builder = createChangesetBuilder().forCommand(ChangesetCommand.ChangeSignature);
|
|
79
90
|
// 使用現有邏輯(preview 模式)收集變更
|
|
80
91
|
const result = await this.changeSignature({
|
|
81
92
|
...options,
|
|
@@ -100,7 +111,7 @@ export class ChangeSignatureService {
|
|
|
100
111
|
},
|
|
101
112
|
newText: newCode,
|
|
102
113
|
description: `Update definition: ${originalCode.trim()} -> ${newCode.trim()}`
|
|
103
|
-
}],
|
|
114
|
+
}], TextEditOperationType.Modify);
|
|
104
115
|
// 轉換 callSiteUpdates
|
|
105
116
|
// 按檔案分組,合併同一檔案的多個變更
|
|
106
117
|
const updatesByFile = new Map();
|
|
@@ -130,7 +141,7 @@ export class ChangeSignatureService {
|
|
|
130
141
|
description: `Update call: ${update.originalCode.trim()} -> ${update.newCode.trim()}`
|
|
131
142
|
};
|
|
132
143
|
});
|
|
133
|
-
builder.addTextChange(updateFilePath, edits,
|
|
144
|
+
builder.addTextChange(updateFilePath, edits, TextEditOperationType.Modify);
|
|
134
145
|
}
|
|
135
146
|
// 設定描述
|
|
136
147
|
const originalParams = result.originalSignature.parameters.map(p => p.name).join(', ');
|
|
@@ -138,170 +149,11 @@ export class ChangeSignatureService {
|
|
|
138
149
|
builder.withDescription(`Changed signature of ${result.originalSignature.name}: (${originalParams}) -> (${newParams})`);
|
|
139
150
|
return builder.build();
|
|
140
151
|
}
|
|
141
|
-
/**
|
|
142
|
-
* 驗證變更
|
|
143
|
-
*/
|
|
144
|
-
validateChanges(signature, changes) {
|
|
145
|
-
const errors = [];
|
|
146
|
-
const parameterNames = new Set(signature.parameters.map(p => p.name));
|
|
147
|
-
const newParameterNames = new Set(parameterNames);
|
|
148
|
-
for (const change of changes) {
|
|
149
|
-
if (isAddParameterChange(change)) {
|
|
150
|
-
if (newParameterNames.has(change.name)) {
|
|
151
|
-
errors.push({
|
|
152
|
-
code: ChangeSignatureErrorCode.DuplicateParameterName,
|
|
153
|
-
message: `參數名稱重複: ${change.name}`,
|
|
154
|
-
parameterName: change.name
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
newParameterNames.add(change.name);
|
|
159
|
-
}
|
|
160
|
-
// 驗證新增參數必須有預設值
|
|
161
|
-
if (!change.callSiteValue && !change.defaultValue) {
|
|
162
|
-
errors.push({
|
|
163
|
-
code: ChangeSignatureErrorCode.MissingDefaultValue,
|
|
164
|
-
message: `參數 ${change.name} 缺少預設值,請使用 --default-value 或 --call-site-value 指定`,
|
|
165
|
-
parameterName: change.name
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (isRemoveParameterChange(change)) {
|
|
170
|
-
const targetName = this.resolveParameterName(signature, change.parameterNameOrIndex);
|
|
171
|
-
if (!targetName || !parameterNames.has(targetName)) {
|
|
172
|
-
errors.push({
|
|
173
|
-
code: ChangeSignatureErrorCode.ParameterNotFound,
|
|
174
|
-
message: `找不到參數: ${change.parameterNameOrIndex}`,
|
|
175
|
-
parameterName: String(change.parameterNameOrIndex)
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
newParameterNames.delete(targetName);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (isReorderParametersChange(change)) {
|
|
183
|
-
for (const nameOrIndex of change.newOrder) {
|
|
184
|
-
const targetName = this.resolveParameterName(signature, nameOrIndex);
|
|
185
|
-
if (!targetName || !parameterNames.has(targetName)) {
|
|
186
|
-
errors.push({
|
|
187
|
-
code: ChangeSignatureErrorCode.ParameterNotFound,
|
|
188
|
-
message: `找不到參數: ${nameOrIndex}`,
|
|
189
|
-
parameterName: String(nameOrIndex)
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (change.newOrder.length !== signature.parameters.length) {
|
|
194
|
-
errors.push({
|
|
195
|
-
code: ChangeSignatureErrorCode.InvalidParameterOrder,
|
|
196
|
-
message: '重新排序必須包含所有參數'
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
// 驗證可選參數順序:可選參數必須在必選參數之後
|
|
200
|
-
const optionalOrderError = this.validateOptionalParameterOrder(signature, change.newOrder);
|
|
201
|
-
if (optionalOrderError) {
|
|
202
|
-
errors.push(optionalOrderError);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
if (isChangeParameterTypeChange(change) || isRenameParameterChange(change) ||
|
|
206
|
-
isChangeDefaultValueChange(change) || isToggleOptionalChange(change)) {
|
|
207
|
-
const targetName = this.resolveParameterName(signature, change.parameterNameOrIndex);
|
|
208
|
-
if (!targetName || !parameterNames.has(targetName)) {
|
|
209
|
-
errors.push({
|
|
210
|
-
code: ChangeSignatureErrorCode.ParameterNotFound,
|
|
211
|
-
message: `找不到參數: ${change.parameterNameOrIndex}`,
|
|
212
|
-
parameterName: String(change.parameterNameOrIndex)
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
if (isRenameParameterChange(change)) {
|
|
217
|
-
if (newParameterNames.has(change.newName) && change.newName !== this.resolveParameterName(signature, change.parameterNameOrIndex)) {
|
|
218
|
-
errors.push({
|
|
219
|
-
code: ChangeSignatureErrorCode.DuplicateParameterName,
|
|
220
|
-
message: `參數名稱重複: ${change.newName}`,
|
|
221
|
-
parameterName: change.newName
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
return errors;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* 套用變更到簽名
|
|
230
|
-
*/
|
|
231
|
-
applyChangesToSignature(signature, changes) {
|
|
232
|
-
let parameters = [...signature.parameters];
|
|
233
|
-
for (const change of changes) {
|
|
234
|
-
if (isAddParameterChange(change)) {
|
|
235
|
-
const newParam = {
|
|
236
|
-
name: change.name,
|
|
237
|
-
type: change.parameterType,
|
|
238
|
-
defaultValue: change.defaultValue,
|
|
239
|
-
optional: change.optional,
|
|
240
|
-
rest: false,
|
|
241
|
-
range: { start: { line: 0, column: 0, offset: 0 }, end: { line: 0, column: 0, offset: 0 } }
|
|
242
|
-
};
|
|
243
|
-
if (change.position < 0 || change.position >= parameters.length) {
|
|
244
|
-
parameters.push(newParam);
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
parameters.splice(change.position, 0, newParam);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
if (isRemoveParameterChange(change)) {
|
|
251
|
-
const index = this.resolveParameterIndex(parameters, change.parameterNameOrIndex);
|
|
252
|
-
if (index >= 0) {
|
|
253
|
-
parameters.splice(index, 1);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
if (isReorderParametersChange(change)) {
|
|
257
|
-
const newParams = [];
|
|
258
|
-
for (const nameOrIndex of change.newOrder) {
|
|
259
|
-
const index = this.resolveParameterIndex(parameters, nameOrIndex);
|
|
260
|
-
if (index >= 0) {
|
|
261
|
-
newParams.push(parameters[index]);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
parameters = newParams;
|
|
265
|
-
}
|
|
266
|
-
if (isChangeParameterTypeChange(change)) {
|
|
267
|
-
const index = this.resolveParameterIndex(parameters, change.parameterNameOrIndex);
|
|
268
|
-
if (index >= 0) {
|
|
269
|
-
parameters[index] = { ...parameters[index], type: change.newType };
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
if (isRenameParameterChange(change)) {
|
|
273
|
-
const index = this.resolveParameterIndex(parameters, change.parameterNameOrIndex);
|
|
274
|
-
if (index >= 0) {
|
|
275
|
-
parameters[index] = { ...parameters[index], name: change.newName };
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (isChangeDefaultValueChange(change)) {
|
|
279
|
-
const index = this.resolveParameterIndex(parameters, change.parameterNameOrIndex);
|
|
280
|
-
if (index >= 0) {
|
|
281
|
-
parameters[index] = {
|
|
282
|
-
...parameters[index],
|
|
283
|
-
defaultValue: change.newDefaultValue,
|
|
284
|
-
optional: change.newDefaultValue !== undefined || parameters[index].optional
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
if (isToggleOptionalChange(change)) {
|
|
289
|
-
const index = this.resolveParameterIndex(parameters, change.parameterNameOrIndex);
|
|
290
|
-
if (index >= 0) {
|
|
291
|
-
parameters[index] = { ...parameters[index], optional: change.optional };
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
return {
|
|
296
|
-
...signature,
|
|
297
|
-
parameters
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
152
|
/**
|
|
301
153
|
* 生成定義更新
|
|
302
154
|
*/
|
|
303
155
|
async generateDefinitionUpdate(filePath, originalSignature, newSignature) {
|
|
304
|
-
const content = await this.readFile(filePath);
|
|
156
|
+
const content = await this.fileUtils.readFile(filePath);
|
|
305
157
|
if (!content) {
|
|
306
158
|
throw new Error(`無法讀取檔案: ${filePath}`);
|
|
307
159
|
}
|
|
@@ -324,267 +176,6 @@ export class ChangeSignatureService {
|
|
|
324
176
|
location: originalSignature.location
|
|
325
177
|
};
|
|
326
178
|
}
|
|
327
|
-
/**
|
|
328
|
-
* 生成呼叫點更新
|
|
329
|
-
* 效能優化:按檔案分組後批次讀取,避免重複讀取同一檔案
|
|
330
|
-
* 檔案讀取次數從 O(N) 降到 O(M),N = callSites 數量,M = 不重複檔案數
|
|
331
|
-
* 支援多行呼叫點:正確處理跨多行的函式呼叫
|
|
332
|
-
*/
|
|
333
|
-
async generateCallSiteUpdates(callSites, originalSignature, newSignature, changes) {
|
|
334
|
-
const updates = [];
|
|
335
|
-
// 建立參數映射
|
|
336
|
-
const parameterMapping = this.createParameterMapping(originalSignature, newSignature, changes);
|
|
337
|
-
// 按檔案分組 callSites,避免重複讀取同一檔案
|
|
338
|
-
const callSitesByFile = new Map();
|
|
339
|
-
for (const callSite of callSites) {
|
|
340
|
-
const filePath = callSite.location.filePath;
|
|
341
|
-
const existing = callSitesByFile.get(filePath);
|
|
342
|
-
if (existing) {
|
|
343
|
-
existing.push(callSite);
|
|
344
|
-
}
|
|
345
|
-
else {
|
|
346
|
-
callSitesByFile.set(filePath, [callSite]);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
// 批次讀取所有不重複的檔案並處理
|
|
350
|
-
for (const [filePath, fileCallSites] of callSitesByFile) {
|
|
351
|
-
const content = await this.readFile(filePath);
|
|
352
|
-
if (!content) {
|
|
353
|
-
continue;
|
|
354
|
-
}
|
|
355
|
-
const lines = content.split('\n');
|
|
356
|
-
// 處理該檔案的所有 callSites
|
|
357
|
-
for (const callSite of fileCallSites) {
|
|
358
|
-
const startLineIndex = callSite.location.range.start.line - 1;
|
|
359
|
-
const endLineIndex = callSite.location.range.end.line - 1;
|
|
360
|
-
const isMultiline = startLineIndex !== endLineIndex;
|
|
361
|
-
// 建立新的參數列表
|
|
362
|
-
const newArgs = this.mapCallSiteArguments(callSite, parameterMapping, changes, originalSignature);
|
|
363
|
-
// 找到呼叫的括號位置
|
|
364
|
-
const startLine = lines[startLineIndex];
|
|
365
|
-
const funcNameIndex = startLine.indexOf(callSite.functionName);
|
|
366
|
-
if (funcNameIndex < 0) {
|
|
367
|
-
continue;
|
|
368
|
-
}
|
|
369
|
-
const openParenIndex = startLine.indexOf('(', funcNameIndex);
|
|
370
|
-
if (isMultiline) {
|
|
371
|
-
// 多行呼叫點:提取完整的原始程式碼並替換
|
|
372
|
-
const originalCode = this.extractMultilineCode(lines, startLineIndex, endLineIndex);
|
|
373
|
-
// 檢測原始呼叫的格式風格
|
|
374
|
-
const originalStyle = this.detectCallStyle(lines, startLineIndex, endLineIndex);
|
|
375
|
-
// 生成新的參數字串(保留原始風格)
|
|
376
|
-
const newArgsString = this.formatArgsWithStyle(newArgs, originalStyle);
|
|
377
|
-
// 生成新的程式碼
|
|
378
|
-
const newCode = startLine.substring(0, openParenIndex + 1)
|
|
379
|
-
+ newArgsString
|
|
380
|
-
+ ')' + this.getTrailingContent(lines, endLineIndex, callSite.location.range.end.column - 1);
|
|
381
|
-
if (newCode !== originalCode) {
|
|
382
|
-
updates.push({
|
|
383
|
-
filePath: callSite.location.filePath,
|
|
384
|
-
originalCode,
|
|
385
|
-
newCode,
|
|
386
|
-
location: callSite.location
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
// 單行呼叫點:保持原有邏輯
|
|
392
|
-
const closeParenIndex = this.findMatchingParen(startLine, openParenIndex);
|
|
393
|
-
const newArgsString = newArgs.join(', ');
|
|
394
|
-
const newLine = startLine.substring(0, openParenIndex + 1)
|
|
395
|
-
+ newArgsString
|
|
396
|
-
+ startLine.substring(closeParenIndex);
|
|
397
|
-
if (newLine !== startLine) {
|
|
398
|
-
updates.push({
|
|
399
|
-
filePath: callSite.location.filePath,
|
|
400
|
-
originalCode: startLine,
|
|
401
|
-
newCode: newLine,
|
|
402
|
-
location: callSite.location
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
return updates;
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* 提取多行程式碼
|
|
412
|
-
*/
|
|
413
|
-
extractMultilineCode(lines, startLine, endLine) {
|
|
414
|
-
if (startLine === endLine) {
|
|
415
|
-
return lines[startLine];
|
|
416
|
-
}
|
|
417
|
-
const result = [];
|
|
418
|
-
for (let i = startLine; i <= endLine; i++) {
|
|
419
|
-
result.push(lines[i]);
|
|
420
|
-
}
|
|
421
|
-
return result.join('\n');
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* 檢測呼叫風格
|
|
425
|
-
*/
|
|
426
|
-
detectCallStyle(lines, startLine, endLine) {
|
|
427
|
-
const isMultiline = startLine !== endLine;
|
|
428
|
-
if (!isMultiline) {
|
|
429
|
-
return { multiline: false, indent: '', trailingComma: false };
|
|
430
|
-
}
|
|
431
|
-
// 檢測縮排(從第二行取得)
|
|
432
|
-
const secondLine = lines[startLine + 1] || '';
|
|
433
|
-
const indentMatch = secondLine.match(/^(\s*)/);
|
|
434
|
-
const indent = indentMatch ? indentMatch[1] : ' ';
|
|
435
|
-
// 檢測是否有尾隨逗號
|
|
436
|
-
const lastArgLine = lines[endLine - 1] || lines[endLine];
|
|
437
|
-
const trailingComma = lastArgLine.trimEnd().endsWith(',');
|
|
438
|
-
return { multiline: true, indent, trailingComma };
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* 根據風格格式化參數
|
|
442
|
-
*/
|
|
443
|
-
formatArgsWithStyle(args, style) {
|
|
444
|
-
if (!style.multiline || args.length === 0) {
|
|
445
|
-
return args.join(', ');
|
|
446
|
-
}
|
|
447
|
-
// 多行格式
|
|
448
|
-
const formattedArgs = args.map(arg => `${style.indent}${arg}`);
|
|
449
|
-
const separator = style.trailingComma ? ',\n' : ',\n';
|
|
450
|
-
return '\n' + formattedArgs.join(separator) + (style.trailingComma ? ',' : '') + '\n';
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* 取得結束行的尾隨內容(右括號之後的部分)
|
|
454
|
-
*/
|
|
455
|
-
getTrailingContent(lines, endLine, closeParenColumn) {
|
|
456
|
-
const line = lines[endLine];
|
|
457
|
-
// 找到右括號後的內容
|
|
458
|
-
return line.substring(closeParenColumn + 1);
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* 建立參數映射
|
|
462
|
-
*/
|
|
463
|
-
createParameterMapping(originalSignature, newSignature, changes) {
|
|
464
|
-
const mapping = new Map();
|
|
465
|
-
// 初始化:原始索引 -> 新索引
|
|
466
|
-
let currentParams = originalSignature.parameters.map((p, i) => ({ name: p.name, originalIndex: i }));
|
|
467
|
-
// 處理每個變更
|
|
468
|
-
for (const change of changes) {
|
|
469
|
-
if (isRemoveParameterChange(change)) {
|
|
470
|
-
const index = this.resolveParameterIndex(currentParams.map(p => ({ name: p.name })), change.parameterNameOrIndex);
|
|
471
|
-
if (index >= 0) {
|
|
472
|
-
currentParams.splice(index, 1);
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
if (isReorderParametersChange(change)) {
|
|
476
|
-
const newOrder = [];
|
|
477
|
-
for (const nameOrIndex of change.newOrder) {
|
|
478
|
-
const index = this.resolveParameterIndex(currentParams.map(p => ({ name: p.name })), nameOrIndex);
|
|
479
|
-
if (index >= 0) {
|
|
480
|
-
newOrder.push(currentParams[index]);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
currentParams = newOrder;
|
|
484
|
-
}
|
|
485
|
-
if (isAddParameterChange(change)) {
|
|
486
|
-
const newParam = { name: change.name, originalIndex: -1, value: change.callSiteValue || change.defaultValue };
|
|
487
|
-
if (change.position < 0 || change.position >= currentParams.length) {
|
|
488
|
-
currentParams.push(newParam);
|
|
489
|
-
}
|
|
490
|
-
else {
|
|
491
|
-
currentParams.splice(change.position, 0, newParam);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
// 建立最終映射
|
|
496
|
-
for (let newIndex = 0; newIndex < currentParams.length; newIndex++) {
|
|
497
|
-
const param = currentParams[newIndex];
|
|
498
|
-
if (param.originalIndex >= 0) {
|
|
499
|
-
mapping.set(param.originalIndex, { newIndex });
|
|
500
|
-
}
|
|
501
|
-
else if ('value' in param) {
|
|
502
|
-
// 新增的參數,設定預設值
|
|
503
|
-
mapping.set(-1 - newIndex, { newIndex, value: param.value });
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
return mapping;
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* 映射呼叫點參數
|
|
510
|
-
* 處理省略的可選參數:當可選參數被省略時,重排後需要插入 undefined
|
|
511
|
-
*/
|
|
512
|
-
mapCallSiteArguments(callSite, parameterMapping, changes, originalSignature) {
|
|
513
|
-
const result = [];
|
|
514
|
-
// 找出新參數的數量
|
|
515
|
-
let maxNewIndex = -1;
|
|
516
|
-
for (const { newIndex } of parameterMapping.values()) {
|
|
517
|
-
maxNewIndex = Math.max(maxNewIndex, newIndex);
|
|
518
|
-
}
|
|
519
|
-
// 初始化結果陣列
|
|
520
|
-
for (let i = 0; i <= maxNewIndex; i++) {
|
|
521
|
-
result.push('');
|
|
522
|
-
}
|
|
523
|
-
// 映射原始參數
|
|
524
|
-
for (const [originalIndex, { newIndex }] of parameterMapping.entries()) {
|
|
525
|
-
if (originalIndex >= 0) {
|
|
526
|
-
if (originalIndex < callSite.arguments.length) {
|
|
527
|
-
// 呼叫點有提供此參數
|
|
528
|
-
result[newIndex] = callSite.arguments[originalIndex].value;
|
|
529
|
-
}
|
|
530
|
-
else {
|
|
531
|
-
// 呼叫點省略了此可選參數
|
|
532
|
-
// 檢查這個位置是否需要填入 undefined(當後面有其他參數時)
|
|
533
|
-
const param = originalSignature.parameters[originalIndex];
|
|
534
|
-
if (param && (param.optional || param.defaultValue)) {
|
|
535
|
-
// 標記為需要填入 undefined(如果後面有非空參數)
|
|
536
|
-
result[newIndex] = '\0OMITTED\0';
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
// 填入新增參數的值
|
|
542
|
-
const addedPositions = new Set();
|
|
543
|
-
for (const change of changes) {
|
|
544
|
-
if (isAddParameterChange(change)) {
|
|
545
|
-
// 使用 callSiteValue 或 defaultValue(驗證階段已確保至少有一個值)
|
|
546
|
-
const value = change.callSiteValue || change.defaultValue;
|
|
547
|
-
const position = change.position < 0 ? result.length - 1 : Math.min(change.position, result.length - 1);
|
|
548
|
-
if (position >= 0 && position < result.length && !result[position]) {
|
|
549
|
-
result[position] = value;
|
|
550
|
-
addedPositions.add(position);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
// 處理省略的可選參數:
|
|
555
|
-
// 如果省略的參數後面有非空參數,則需要填入 undefined
|
|
556
|
-
// 否則可以完全省略
|
|
557
|
-
const processedResult = [];
|
|
558
|
-
let lastNonEmptyIndex = -1;
|
|
559
|
-
// 找到最後一個非空參數的索引
|
|
560
|
-
for (let i = result.length - 1; i >= 0; i--) {
|
|
561
|
-
if (result[i] !== '' && result[i] !== '\0OMITTED\0') {
|
|
562
|
-
lastNonEmptyIndex = i;
|
|
563
|
-
break;
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
// 建立最終結果
|
|
567
|
-
for (let i = 0; i <= lastNonEmptyIndex; i++) {
|
|
568
|
-
if (result[i] === '\0OMITTED\0') {
|
|
569
|
-
// 省略的可選參數,但後面有其他參數,需要填入 undefined
|
|
570
|
-
processedResult.push('undefined');
|
|
571
|
-
}
|
|
572
|
-
else if (result[i] === '') {
|
|
573
|
-
// 空值,檢查是否是新增的位置
|
|
574
|
-
if (addedPositions.has(i)) {
|
|
575
|
-
processedResult.push('undefined');
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
578
|
-
// 不應該出現的情況,填入 undefined 以避免語法錯誤
|
|
579
|
-
processedResult.push('undefined');
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
583
|
-
processedResult.push(result[i]);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
return processedResult;
|
|
587
|
-
}
|
|
588
179
|
/**
|
|
589
180
|
* 執行變更
|
|
590
181
|
*/
|
|
@@ -613,7 +204,7 @@ export class ChangeSignatureService {
|
|
|
613
204
|
}
|
|
614
205
|
// 套用到每個檔案
|
|
615
206
|
for (const [filePath, updates] of fileUpdates) {
|
|
616
|
-
let content = await this.readFile(filePath);
|
|
207
|
+
let content = await this.fileUtils.readFile(filePath);
|
|
617
208
|
if (!content) {
|
|
618
209
|
continue;
|
|
619
210
|
}
|
|
@@ -629,8 +220,7 @@ export class ChangeSignatureService {
|
|
|
629
220
|
* 生成參數字串
|
|
630
221
|
*/
|
|
631
222
|
generateParameterString(signature, filePath) {
|
|
632
|
-
const
|
|
633
|
-
const isTypeScript = extension === '.ts' || extension === '.tsx';
|
|
223
|
+
const isTypeScript = FileUtils.isTypeScript(filePath);
|
|
634
224
|
return signature.parameters.map(param => {
|
|
635
225
|
let result = '';
|
|
636
226
|
if (param.rest) {
|
|
@@ -667,61 +257,6 @@ export class ChangeSignatureService {
|
|
|
667
257
|
}
|
|
668
258
|
return line.length;
|
|
669
259
|
}
|
|
670
|
-
/**
|
|
671
|
-
* 解析參數名稱
|
|
672
|
-
*/
|
|
673
|
-
resolveParameterName(signature, nameOrIndex) {
|
|
674
|
-
if (typeof nameOrIndex === 'number') {
|
|
675
|
-
return signature.parameters[nameOrIndex]?.name;
|
|
676
|
-
}
|
|
677
|
-
return signature.parameters.find(p => p.name === nameOrIndex)?.name;
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* 解析參數索引
|
|
681
|
-
*/
|
|
682
|
-
resolveParameterIndex(parameters, nameOrIndex) {
|
|
683
|
-
if (typeof nameOrIndex === 'number') {
|
|
684
|
-
return nameOrIndex >= 0 && nameOrIndex < parameters.length ? nameOrIndex : -1;
|
|
685
|
-
}
|
|
686
|
-
return parameters.findIndex(p => p.name === nameOrIndex);
|
|
687
|
-
}
|
|
688
|
-
/**
|
|
689
|
-
* 驗證可選參數順序
|
|
690
|
-
* TypeScript 規則:可選參數必須在所有必選參數之後
|
|
691
|
-
* 例外:有預設值的參數視為可選,rest 參數必須在最後
|
|
692
|
-
*/
|
|
693
|
-
validateOptionalParameterOrder(signature, newOrder) {
|
|
694
|
-
// 根據新順序建立參數列表
|
|
695
|
-
const reorderedParams = [];
|
|
696
|
-
for (const nameOrIndex of newOrder) {
|
|
697
|
-
const index = this.resolveParameterIndex(signature.parameters, nameOrIndex);
|
|
698
|
-
if (index >= 0) {
|
|
699
|
-
reorderedParams.push(signature.parameters[index]);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
// 檢查可選參數是否在必選參數之前
|
|
703
|
-
let foundOptional = false;
|
|
704
|
-
let firstOptionalParam = null;
|
|
705
|
-
for (const param of reorderedParams) {
|
|
706
|
-
const isOptional = param.optional || param.defaultValue !== undefined;
|
|
707
|
-
const isRest = param.rest;
|
|
708
|
-
if (isOptional && !isRest) {
|
|
709
|
-
foundOptional = true;
|
|
710
|
-
if (!firstOptionalParam) {
|
|
711
|
-
firstOptionalParam = param;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
else if (!isOptional && !isRest && foundOptional) {
|
|
715
|
-
// 找到必選參數在可選參數之後
|
|
716
|
-
return {
|
|
717
|
-
code: ChangeSignatureErrorCode.OptionalBeforeRequired,
|
|
718
|
-
message: `可選參數 '${firstOptionalParam.name}' 不能位於必選參數 '${param.name}' 之前`,
|
|
719
|
-
parameterName: param.name
|
|
720
|
-
};
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
return null;
|
|
724
|
-
}
|
|
725
260
|
/**
|
|
726
261
|
* 取得專案檔案
|
|
727
262
|
*/
|
|
@@ -737,8 +272,9 @@ export class ChangeSignatureService {
|
|
|
737
272
|
const entries = await this.fileSystem.readDirectory(dirPath);
|
|
738
273
|
for (const entry of entries) {
|
|
739
274
|
const fullPath = path.join(dirPath, entry.name);
|
|
740
|
-
// 跳過 node_modules
|
|
741
|
-
|
|
275
|
+
// 跳過 node_modules、build 輸出目錄和隱藏目錄
|
|
276
|
+
const skipDirs = ['node_modules', 'dist', 'build', 'coverage', '.git'];
|
|
277
|
+
if (skipDirs.includes(entry.name) || entry.name.startsWith('.')) {
|
|
742
278
|
continue;
|
|
743
279
|
}
|
|
744
280
|
if (entry.isDirectory) {
|
|
@@ -753,27 +289,7 @@ export class ChangeSignatureService {
|
|
|
753
289
|
* 檢查是否為支援的檔案類型
|
|
754
290
|
*/
|
|
755
291
|
isSupportedFile(filename) {
|
|
756
|
-
|
|
757
|
-
return supportedExtensions.some(ext => filename.endsWith(ext));
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
* 讀取檔案內容
|
|
761
|
-
*/
|
|
762
|
-
async readFile(filePath) {
|
|
763
|
-
try {
|
|
764
|
-
const content = await this.fileSystem.readFile(filePath, 'utf-8');
|
|
765
|
-
return typeof content === 'string' ? content : content.toString('utf-8');
|
|
766
|
-
}
|
|
767
|
-
catch {
|
|
768
|
-
return null;
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
/**
|
|
772
|
-
* 取得檔案副檔名
|
|
773
|
-
*/
|
|
774
|
-
getFileExtension(filePath) {
|
|
775
|
-
const lastDot = filePath.lastIndexOf('.');
|
|
776
|
-
return lastDot >= 0 ? filePath.substring(lastDot) : '';
|
|
292
|
+
return FileUtils.isSupportedLanguage(filename);
|
|
777
293
|
}
|
|
778
294
|
/**
|
|
779
295
|
* 建立錯誤結果
|