agent-ide 0.8.1 → 0.9.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/dist/application/index.d.ts +1 -12
- package/dist/application/index.d.ts.map +1 -1
- package/dist/application/index.js +0 -16
- 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/module-coordinator.service.d.ts +3 -8
- package/dist/application/services/module-coordinator.service.d.ts.map +1 -1
- package/dist/application/services/module-coordinator.service.js +5 -139
- package/dist/application/services/module-coordinator.service.js.map +1 -1
- package/dist/application/types.d.ts +0 -63
- package/dist/application/types.d.ts.map +1 -1
- package/dist/application/types.js +1 -9
- package/dist/application/types.js.map +1 -1
- package/dist/core/call-hierarchy/call-hierarchy-analyzer.d.ts.map +1 -1
- package/dist/core/call-hierarchy/call-hierarchy-analyzer.js +3 -5
- package/dist/core/call-hierarchy/call-hierarchy-analyzer.js.map +1 -1
- package/dist/core/change-signature/call-site-updater.d.ts +108 -0
- package/dist/core/change-signature/call-site-updater.d.ts.map +1 -0
- package/dist/core/change-signature/call-site-updater.js +347 -0
- package/dist/core/change-signature/call-site-updater.js.map +1 -0
- package/dist/core/change-signature/change-signature-service.d.ts +11 -53
- package/dist/core/change-signature/change-signature-service.d.ts.map +1 -1
- package/dist/core/change-signature/change-signature-service.js +91 -475
- 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 +46 -4
- package/dist/core/change-signature/signature-parser.d.ts.map +1 -1
- package/dist/core/change-signature/signature-parser.js +180 -9
- 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.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 +22 -1
- package/dist/core/deadcode/dead-code-detector.d.ts.map +1 -1
- package/dist/core/deadcode/dead-code-detector.js +134 -61
- package/dist/core/deadcode/dead-code-detector.js.map +1 -1
- package/dist/core/deadcode/dead-code-remover.d.ts +11 -93
- package/dist/core/deadcode/dead-code-remover.d.ts.map +1 -1
- package/dist/core/deadcode/dead-code-remover.js +71 -690
- package/dist/core/deadcode/dead-code-remover.js.map +1 -1
- package/dist/core/deadcode/file-operations.d.ts +85 -0
- package/dist/core/deadcode/file-operations.d.ts.map +1 -0
- package/dist/core/deadcode/file-operations.js +263 -0
- package/dist/core/deadcode/file-operations.js.map +1 -0
- package/dist/core/deadcode/import-cleaner.d.ts +63 -0
- package/dist/core/deadcode/import-cleaner.d.ts.map +1 -0
- package/dist/core/deadcode/import-cleaner.js +229 -0
- package/dist/core/deadcode/import-cleaner.js.map +1 -0
- package/dist/core/deadcode/import-parser.d.ts +79 -0
- package/dist/core/deadcode/import-parser.d.ts.map +1 -0
- package/dist/core/deadcode/import-parser.js +229 -0
- package/dist/core/deadcode/import-parser.js.map +1 -0
- package/dist/core/deadcode/range-expander.d.ts +38 -0
- package/dist/core/deadcode/range-expander.d.ts.map +1 -0
- package/dist/core/deadcode/range-expander.js +175 -0
- package/dist/core/deadcode/range-expander.js.map +1 -0
- package/dist/core/deadcode/types.d.ts +2 -0
- package/dist/core/deadcode/types.d.ts.map +1 -1
- package/dist/core/deadcode/types.js.map +1 -1
- package/dist/core/find-references/index.d.ts +2 -2
- package/dist/core/find-references/index.d.ts.map +1 -1
- package/dist/core/find-references/index.js +1 -1
- package/dist/core/find-references/index.js.map +1 -1
- 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 +3 -64
- package/dist/core/impact/impact-analyzer.d.ts.map +1 -1
- package/dist/core/impact/impact-analyzer.js +13 -312
- 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 +10 -0
- package/dist/core/move/import-resolver.d.ts.map +1 -1
- package/dist/core/move/import-resolver.js +31 -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 +41 -52
- package/dist/core/move/move-service.d.ts.map +1 -1
- package/dist/core/move/move-service.js +189 -358
- 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/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 +11 -0
- package/dist/core/move-member/member-extractor.d.ts.map +1 -1
- package/dist/core/move-member/member-extractor.js +116 -24
- package/dist/core/move-member/member-extractor.js.map +1 -1
- package/dist/core/move-member/move-member-service.d.ts +9 -78
- package/dist/core/move-member/move-member-service.d.ts.map +1 -1
- package/dist/core/move-member/move-member-service.js +86 -413
- 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 +286 -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/rename/reference-updater.d.ts +1 -35
- package/dist/core/rename/reference-updater.d.ts.map +1 -1
- package/dist/core/rename/reference-updater.js +8 -251
- package/dist/core/rename/reference-updater.js.map +1 -1
- package/dist/core/rename/rename-engine.d.ts +16 -22
- package/dist/core/rename/rename-engine.d.ts.map +1 -1
- package/dist/core/rename/rename-engine.js +59 -208
- package/dist/core/rename/rename-engine.js.map +1 -1
- package/dist/core/rename/scope-analyzer.d.ts.map +1 -1
- package/dist/core/shared/index.d.ts +1 -1
- package/dist/core/shared/index.d.ts.map +1 -1
- package/dist/core/shared/index.js +1 -1
- package/dist/core/shared/index.js.map +1 -1
- package/dist/core/shared/indexing/index-engine.d.ts +1 -1
- package/dist/core/shared/indexing/index-engine.d.ts.map +1 -1
- package/dist/core/shared/indexing/index-engine.js +1 -1
- package/dist/core/shared/indexing/index-engine.js.map +1 -1
- package/dist/core/shared/symbol-finder/call-site-parser.d.ts +71 -0
- package/dist/core/shared/symbol-finder/call-site-parser.d.ts.map +1 -0
- package/dist/core/shared/symbol-finder/call-site-parser.js +369 -0
- package/dist/core/shared/symbol-finder/call-site-parser.js.map +1 -0
- package/dist/core/shared/symbol-finder/index.d.ts +9 -0
- package/dist/core/shared/symbol-finder/index.d.ts.map +1 -0
- package/dist/core/shared/symbol-finder/index.js +12 -0
- package/dist/core/shared/symbol-finder/index.js.map +1 -0
- package/dist/core/shared/{symbol-finder.d.ts → symbol-finder/symbol-finder.d.ts} +27 -133
- package/dist/core/shared/symbol-finder/symbol-finder.d.ts.map +1 -0
- package/dist/core/shared/symbol-finder/symbol-finder.js +552 -0
- package/dist/core/shared/symbol-finder/symbol-finder.js.map +1 -0
- package/dist/core/shared/symbol-finder/text-matcher.d.ts +45 -0
- package/dist/core/shared/symbol-finder/text-matcher.d.ts.map +1 -0
- package/dist/core/shared/symbol-finder/text-matcher.js +195 -0
- package/dist/core/shared/symbol-finder/text-matcher.js.map +1 -0
- package/dist/core/shared/symbol-finder/types.d.ts +108 -0
- package/dist/core/shared/symbol-finder/types.d.ts.map +1 -0
- package/dist/core/shared/symbol-finder/types.js +71 -0
- package/dist/core/shared/symbol-finder/types.js.map +1 -0
- package/dist/core/snapshot/snapshot-generator.d.ts +16 -4
- package/dist/core/snapshot/snapshot-generator.d.ts.map +1 -1
- package/dist/core/snapshot/snapshot-generator.js +91 -18
- package/dist/core/snapshot/snapshot-generator.js.map +1 -1
- package/dist/infrastructure/cache/cache-manager.d.ts.map +1 -1
- package/dist/infrastructure/cache/cache-manager.js +4 -0
- package/dist/infrastructure/cache/cache-manager.js.map +1 -1
- package/dist/infrastructure/cache/index.d.ts +15 -9
- package/dist/infrastructure/cache/index.d.ts.map +1 -1
- package/dist/infrastructure/cache/index.js +5 -5
- package/dist/infrastructure/cache/index.js.map +1 -1
- package/dist/infrastructure/cache/memory-cache.d.ts.map +1 -1
- package/dist/infrastructure/cache/memory-cache.js.map +1 -1
- package/dist/infrastructure/cache/strategies.d.ts.map +1 -1
- package/dist/infrastructure/cache/strategies.js +2 -1
- package/dist/infrastructure/cache/strategies.js.map +1 -1
- package/dist/infrastructure/cache/types.d.ts +4 -4
- package/dist/infrastructure/cache/types.d.ts.map +1 -1
- package/dist/infrastructure/changeset/change-applicator.d.ts +95 -0
- package/dist/infrastructure/changeset/change-applicator.d.ts.map +1 -0
- package/dist/infrastructure/changeset/change-applicator.js +467 -0
- package/dist/infrastructure/changeset/change-applicator.js.map +1 -0
- package/dist/infrastructure/changeset/changeset-builder.d.ts +107 -0
- package/dist/infrastructure/changeset/changeset-builder.d.ts.map +1 -0
- package/dist/infrastructure/changeset/changeset-builder.js +188 -0
- package/dist/infrastructure/changeset/changeset-builder.js.map +1 -0
- package/dist/infrastructure/changeset/changeset-converter.d.ts +15 -0
- package/dist/infrastructure/changeset/changeset-converter.d.ts.map +1 -0
- package/dist/infrastructure/changeset/changeset-converter.js +370 -0
- package/dist/infrastructure/changeset/changeset-converter.js.map +1 -0
- package/dist/infrastructure/changeset/index.d.ts +10 -0
- package/dist/infrastructure/changeset/index.d.ts.map +1 -0
- package/dist/infrastructure/changeset/index.js +13 -0
- package/dist/infrastructure/changeset/index.js.map +1 -0
- package/dist/infrastructure/changeset/types.d.ts +147 -0
- package/dist/infrastructure/changeset/types.d.ts.map +1 -0
- package/dist/infrastructure/changeset/types.js +46 -0
- package/dist/infrastructure/changeset/types.js.map +1 -0
- package/dist/infrastructure/parser/base.d.ts.map +1 -1
- package/dist/infrastructure/parser/base.js +4 -3
- package/dist/infrastructure/parser/base.js.map +1 -1
- package/dist/infrastructure/parser/interface.d.ts +4 -2
- package/dist/infrastructure/parser/interface.d.ts.map +1 -1
- package/dist/infrastructure/parser/interface.js.map +1 -1
- package/dist/infrastructure/storage/file-system.d.ts.map +1 -1
- package/dist/infrastructure/storage/file-system.js +61 -54
- package/dist/infrastructure/storage/file-system.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/change-signature.command.d.ts.map +1 -1
- package/dist/interfaces/cli/commands/change-signature.command.js +31 -107
- package/dist/interfaces/cli/commands/change-signature.command.js.map +1 -1
- package/dist/interfaces/cli/commands/deadcode.command.js +51 -46
- package/dist/interfaces/cli/commands/deadcode.command.js.map +1 -1
- package/dist/interfaces/cli/commands/find-references.command.d.ts.map +1 -1
- package/dist/interfaces/cli/commands/find-references.command.js +18 -3
- 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 +170 -65
- 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 +133 -59
- package/dist/interfaces/cli/commands/rename.command.js.map +1 -1
- package/dist/interfaces/cli/output-formatter.d.ts +2 -2
- package/dist/interfaces/cli/output-formatter.d.ts.map +1 -1
- package/dist/interfaces/cli/output-formatter.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 +11 -10
- package/dist/plugins/javascript/parser.d.ts.map +1 -1
- package/dist/plugins/javascript/parser.js +57 -53
- package/dist/plugins/javascript/parser.js.map +1 -1
- package/dist/plugins/javascript/pattern-analyzer.d.ts.map +1 -1
- package/dist/plugins/javascript/pattern-analyzer.js +4 -3
- package/dist/plugins/javascript/pattern-analyzer.js.map +1 -1
- package/dist/plugins/javascript/reference-finder.d.ts +21 -0
- package/dist/plugins/javascript/reference-finder.d.ts.map +1 -1
- package/dist/plugins/javascript/reference-finder.js +119 -76
- package/dist/plugins/javascript/reference-finder.js.map +1 -1
- package/dist/plugins/javascript/types.d.ts +4 -7
- package/dist/plugins/javascript/types.d.ts.map +1 -1
- package/dist/plugins/javascript/types.js +9 -9
- package/dist/plugins/javascript/types.js.map +1 -1
- package/dist/plugins/shared/parser-helpers.js.map +1 -1
- package/dist/{shared → plugins/shared}/utils/array.d.ts +6 -1
- package/dist/plugins/shared/utils/array.d.ts.map +1 -0
- package/dist/plugins/shared/utils/array.js.map +1 -0
- package/dist/{shared → plugins/shared}/utils/async.d.ts +1 -1
- package/dist/plugins/shared/utils/async.d.ts.map +1 -0
- package/dist/{shared → plugins/shared}/utils/async.js +2 -0
- package/dist/plugins/shared/utils/async.js.map +1 -0
- package/dist/{shared → plugins/shared}/utils/index.d.ts +0 -20
- package/dist/plugins/shared/utils/index.d.ts.map +1 -0
- package/dist/{shared → plugins/shared}/utils/index.js +0 -20
- package/dist/plugins/shared/utils/index.js.map +1 -0
- package/dist/plugins/shared/utils/memory-monitor.d.ts.map +1 -0
- package/dist/plugins/shared/utils/memory-monitor.js.map +1 -0
- package/dist/{shared → plugins/shared}/utils/object.d.ts +6 -6
- package/dist/plugins/shared/utils/object.d.ts.map +1 -0
- package/dist/{shared → plugins/shared}/utils/object.js +21 -3
- package/dist/plugins/shared/utils/object.js.map +1 -0
- package/dist/plugins/shared/utils/path.d.ts.map +1 -0
- package/dist/plugins/shared/utils/path.js.map +1 -0
- package/dist/{shared → plugins/shared}/utils/string.d.ts +1 -1
- package/dist/plugins/shared/utils/string.d.ts.map +1 -0
- package/dist/{shared → plugins/shared}/utils/string.js +7 -4
- package/dist/plugins/shared/utils/string.js.map +1 -0
- package/dist/plugins/typescript/declaration-analyzer.d.ts +4 -4
- package/dist/plugins/typescript/declaration-analyzer.d.ts.map +1 -1
- package/dist/plugins/typescript/declaration-analyzer.js +13 -6
- package/dist/plugins/typescript/declaration-analyzer.js.map +1 -1
- package/dist/plugins/typescript/language-service.d.ts +1 -1
- package/dist/plugins/typescript/language-service.d.ts.map +1 -1
- package/dist/plugins/typescript/parser.d.ts +3 -2
- package/dist/plugins/typescript/parser.d.ts.map +1 -1
- package/dist/plugins/typescript/parser.js +18 -13
- package/dist/plugins/typescript/parser.js.map +1 -1
- package/dist/plugins/typescript/reference-finder.d.ts +3 -0
- package/dist/plugins/typescript/reference-finder.d.ts.map +1 -1
- package/dist/plugins/typescript/reference-finder.js +16 -4
- package/dist/plugins/typescript/reference-finder.js.map +1 -1
- package/dist/plugins/typescript/symbol-extractor.d.ts +4 -0
- package/dist/plugins/typescript/symbol-extractor.d.ts.map +1 -1
- package/dist/plugins/typescript/symbol-extractor.js +24 -6
- package/dist/plugins/typescript/symbol-extractor.js.map +1 -1
- package/dist/plugins/typescript/types.d.ts +0 -3
- package/dist/plugins/typescript/types.d.ts.map +1 -1
- package/dist/plugins/typescript/types.js +6 -9
- package/dist/plugins/typescript/types.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/parser-error.js +5 -5
- package/dist/shared/errors/parser-error.js.map +1 -1
- package/dist/shared/errors/validation-error.d.ts +2 -2
- package/dist/shared/errors/validation-error.d.ts.map +1 -1
- package/dist/shared/errors/validation-error.js.map +1 -1
- package/dist/shared/types/ast.d.ts +4 -4
- package/dist/shared/types/ast.d.ts.map +1 -1
- package/dist/shared/types/ast.js.map +1 -1
- package/dist/shared/types/core.d.ts +1 -1
- package/dist/shared/types/core.d.ts.map +1 -1
- package/dist/shared/types/index.d.ts +1 -0
- package/dist/shared/types/index.d.ts.map +1 -1
- package/dist/shared/types/index.js +2 -0
- package/dist/shared/types/index.js.map +1 -1
- package/dist/shared/types/line-number.d.ts +22 -0
- package/dist/shared/types/line-number.d.ts.map +1 -0
- package/dist/shared/types/line-number.js +28 -0
- package/dist/shared/types/line-number.js.map +1 -0
- package/package.json +2 -2
- package/dist/application/services/workflow-engine.service.d.ts +0 -76
- package/dist/application/services/workflow-engine.service.d.ts.map +0 -1
- package/dist/application/services/workflow-engine.service.js +0 -405
- package/dist/application/services/workflow-engine.service.js.map +0 -1
- package/dist/application/workflows/analysis-workflow.d.ts +0 -239
- package/dist/application/workflows/analysis-workflow.d.ts.map +0 -1
- package/dist/application/workflows/analysis-workflow.js +0 -395
- package/dist/application/workflows/analysis-workflow.js.map +0 -1
- package/dist/application/workflows/base-workflow.d.ts +0 -108
- package/dist/application/workflows/base-workflow.d.ts.map +0 -1
- package/dist/application/workflows/base-workflow.js +0 -236
- package/dist/application/workflows/base-workflow.js.map +0 -1
- package/dist/application/workflows/index.d.ts +0 -115
- package/dist/application/workflows/index.d.ts.map +0 -1
- package/dist/application/workflows/index.js +0 -218
- package/dist/application/workflows/index.js.map +0 -1
- package/dist/application/workflows/refactor-workflow.d.ts +0 -107
- package/dist/application/workflows/refactor-workflow.d.ts.map +0 -1
- package/dist/application/workflows/refactor-workflow.js +0 -310
- package/dist/application/workflows/refactor-workflow.js.map +0 -1
- package/dist/core/shared/symbol-finder.d.ts.map +0 -1
- package/dist/core/shared/symbol-finder.js +0 -882
- package/dist/core/shared/symbol-finder.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 -211
- package/dist/interfaces/cli/commands/move-member.command.js.map +0 -1
- package/dist/plugins/javascript/code-analyzer.d.ts +0 -68
- package/dist/plugins/javascript/code-analyzer.d.ts.map +0 -1
- package/dist/plugins/javascript/code-analyzer.js +0 -302
- package/dist/plugins/javascript/code-analyzer.js.map +0 -1
- package/dist/plugins/javascript/index.d.ts +0 -12
- package/dist/plugins/javascript/index.d.ts.map +0 -1
- package/dist/plugins/javascript/index.js +0 -16
- package/dist/plugins/javascript/index.js.map +0 -1
- package/dist/plugins/typescript/index.d.ts +0 -14
- package/dist/plugins/typescript/index.d.ts.map +0 -1
- package/dist/plugins/typescript/index.js +0 -13
- package/dist/plugins/typescript/index.js.map +0 -1
- package/dist/shared/utils/array.d.ts.map +0 -1
- package/dist/shared/utils/array.js.map +0 -1
- package/dist/shared/utils/async.d.ts.map +0 -1
- package/dist/shared/utils/async.js.map +0 -1
- package/dist/shared/utils/index.d.ts.map +0 -1
- package/dist/shared/utils/index.js.map +0 -1
- package/dist/shared/utils/memory-monitor.d.ts.map +0 -1
- package/dist/shared/utils/memory-monitor.js.map +0 -1
- package/dist/shared/utils/object.d.ts.map +0 -1
- package/dist/shared/utils/object.js.map +0 -1
- package/dist/shared/utils/path.d.ts.map +0 -1
- package/dist/shared/utils/path.js.map +0 -1
- package/dist/shared/utils/string.d.ts.map +0 -1
- package/dist/shared/utils/string.js.map +0 -1
- /package/dist/{shared → plugins/shared}/utils/array.js +0 -0
- /package/dist/{shared → plugins/shared}/utils/memory-monitor.d.ts +0 -0
- /package/dist/{shared → plugins/shared}/utils/memory-monitor.js +0 -0
- /package/dist/{shared → plugins/shared}/utils/path.d.ts +0 -0
- /package/dist/{shared → plugins/shared}/utils/path.js +0 -0
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
* 參數重構核心服務
|
|
4
4
|
*/
|
|
5
5
|
import * as path from 'path';
|
|
6
|
+
import { createChangesetBuilder, ChangesetCommand, TextEditOperationType } from '../../infrastructure/changeset/index.js';
|
|
6
7
|
import { SignatureParser } from './signature-parser.js';
|
|
7
|
-
import {
|
|
8
|
-
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 } from '../shared/symbol-finder/index.js';
|
|
9
13
|
/**
|
|
10
14
|
* Change Signature Service
|
|
11
15
|
*/
|
|
@@ -14,11 +18,17 @@ export class ChangeSignatureService {
|
|
|
14
18
|
fileSystem;
|
|
15
19
|
signatureParser;
|
|
16
20
|
symbolFinder;
|
|
21
|
+
validator;
|
|
22
|
+
transformer;
|
|
23
|
+
callSiteUpdater;
|
|
17
24
|
constructor(parserRegistry, fileSystem) {
|
|
18
25
|
this.parserRegistry = parserRegistry;
|
|
19
26
|
this.fileSystem = fileSystem;
|
|
20
27
|
this.signatureParser = new SignatureParser(parserRegistry, fileSystem);
|
|
21
28
|
this.symbolFinder = new SymbolFinder(parserRegistry, fileSystem);
|
|
29
|
+
this.validator = new SignatureValidator();
|
|
30
|
+
this.transformer = new SignatureTransformer();
|
|
31
|
+
this.callSiteUpdater = new CallSiteUpdater(fileSystem);
|
|
22
32
|
}
|
|
23
33
|
/**
|
|
24
34
|
* 執行 Change Signature
|
|
@@ -30,19 +40,19 @@ export class ChangeSignatureService {
|
|
|
30
40
|
return this.createErrorResult(ChangeSignatureErrorCode.FunctionNotFound, `找不到函式: ${options.functionName}`);
|
|
31
41
|
}
|
|
32
42
|
// 2. 驗證變更
|
|
33
|
-
const validationErrors = this.validateChanges(originalSignature, options.changes);
|
|
43
|
+
const validationErrors = this.validator.validateChanges(originalSignature, options.changes);
|
|
34
44
|
if (validationErrors.length > 0) {
|
|
35
45
|
return this.createErrorResult(validationErrors[0].code, validationErrors[0].message);
|
|
36
46
|
}
|
|
37
47
|
// 3. 計算新簽名
|
|
38
|
-
const newSignature = this.applyChangesToSignature(originalSignature, options.changes);
|
|
48
|
+
const newSignature = this.transformer.applyChangesToSignature(originalSignature, options.changes);
|
|
39
49
|
// 4. 取得所有呼叫點
|
|
40
50
|
const projectFiles = options.targetFiles ?? await this.getProjectFiles(options.projectRoot);
|
|
41
51
|
const callSites = await this.symbolFinder.findCallSites(options.functionName, projectFiles);
|
|
42
52
|
// 5. 生成定義更新
|
|
43
53
|
const definitionUpdate = await this.generateDefinitionUpdate(options.filePath, originalSignature, newSignature);
|
|
44
54
|
// 6. 生成呼叫點更新
|
|
45
|
-
const callSiteUpdates = await this.generateCallSiteUpdates(callSites, originalSignature, newSignature, options.changes);
|
|
55
|
+
const callSiteUpdates = await this.callSiteUpdater.generateCallSiteUpdates(callSites, originalSignature, newSignature, options.changes);
|
|
46
56
|
// 7. 執行或預覽
|
|
47
57
|
if (!options.preview) {
|
|
48
58
|
await this.applyChanges(definitionUpdate, callSiteUpdates);
|
|
@@ -67,163 +77,75 @@ export class ChangeSignatureService {
|
|
|
67
77
|
};
|
|
68
78
|
}
|
|
69
79
|
/**
|
|
70
|
-
*
|
|
80
|
+
* 生成參數簽名變更的 Changeset
|
|
81
|
+
* 使用 preview 模式收集變更,轉換為統一的 Changeset 格式
|
|
82
|
+
*
|
|
83
|
+
* @param options - 變更選項(強制使用 preview 模式)
|
|
84
|
+
* @returns Changeset 物件
|
|
71
85
|
*/
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
else {
|
|
107
|
-
newParameterNames.delete(targetName);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (isReorderParametersChange(change)) {
|
|
111
|
-
for (const nameOrIndex of change.newOrder) {
|
|
112
|
-
const targetName = this.resolveParameterName(signature, nameOrIndex);
|
|
113
|
-
if (!targetName || !parameterNames.has(targetName)) {
|
|
114
|
-
errors.push({
|
|
115
|
-
code: ChangeSignatureErrorCode.ParameterNotFound,
|
|
116
|
-
message: `找不到參數: ${nameOrIndex}`,
|
|
117
|
-
parameterName: String(nameOrIndex)
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (change.newOrder.length !== signature.parameters.length) {
|
|
122
|
-
errors.push({
|
|
123
|
-
code: ChangeSignatureErrorCode.InvalidParameterOrder,
|
|
124
|
-
message: '重新排序必須包含所有參數'
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
// 驗證可選參數順序:可選參數必須在必選參數之後
|
|
128
|
-
const optionalOrderError = this.validateOptionalParameterOrder(signature, change.newOrder);
|
|
129
|
-
if (optionalOrderError) {
|
|
130
|
-
errors.push(optionalOrderError);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if (isChangeParameterTypeChange(change) || isRenameParameterChange(change) ||
|
|
134
|
-
isChangeDefaultValueChange(change) || isToggleOptionalChange(change)) {
|
|
135
|
-
const targetName = this.resolveParameterName(signature, change.parameterNameOrIndex);
|
|
136
|
-
if (!targetName || !parameterNames.has(targetName)) {
|
|
137
|
-
errors.push({
|
|
138
|
-
code: ChangeSignatureErrorCode.ParameterNotFound,
|
|
139
|
-
message: `找不到參數: ${change.parameterNameOrIndex}`,
|
|
140
|
-
parameterName: String(change.parameterNameOrIndex)
|
|
141
|
-
});
|
|
142
|
-
}
|
|
86
|
+
async generateChangeset(options) {
|
|
87
|
+
const builder = createChangesetBuilder().forCommand(ChangesetCommand.ChangeSignature);
|
|
88
|
+
// 使用現有邏輯(preview 模式)收集變更
|
|
89
|
+
const result = await this.changeSignature({
|
|
90
|
+
...options,
|
|
91
|
+
preview: true
|
|
92
|
+
});
|
|
93
|
+
if (!result.success) {
|
|
94
|
+
return builder
|
|
95
|
+
.addError(result.error ?? 'Change signature failed')
|
|
96
|
+
.withDescription(result.error ?? 'Change signature failed')
|
|
97
|
+
.build();
|
|
98
|
+
}
|
|
99
|
+
// 轉換 definitionUpdate
|
|
100
|
+
const { filePath, originalCode, newCode, location } = result.definitionUpdate;
|
|
101
|
+
// originalCode 和 newCode 都是完整的一行內容
|
|
102
|
+
// 因此 range 應該從行首(column 1)開始,到行尾結束
|
|
103
|
+
const lineNumber = location.range.start.line;
|
|
104
|
+
const originalLineLength = originalCode.length;
|
|
105
|
+
builder.addTextChange(filePath, [{
|
|
106
|
+
range: {
|
|
107
|
+
start: { line: lineNumber, column: 1 },
|
|
108
|
+
end: { line: lineNumber, column: originalLineLength + 1 }
|
|
109
|
+
},
|
|
110
|
+
newText: newCode,
|
|
111
|
+
description: `Update definition: ${originalCode.trim()} -> ${newCode.trim()}`
|
|
112
|
+
}], TextEditOperationType.Modify);
|
|
113
|
+
// 轉換 callSiteUpdates
|
|
114
|
+
// 按檔案分組,合併同一檔案的多個變更
|
|
115
|
+
const updatesByFile = new Map();
|
|
116
|
+
for (const update of result.callSiteUpdates) {
|
|
117
|
+
const existing = updatesByFile.get(update.filePath);
|
|
118
|
+
if (existing) {
|
|
119
|
+
existing.push(update);
|
|
143
120
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
errors.push({
|
|
147
|
-
code: ChangeSignatureErrorCode.DuplicateParameterName,
|
|
148
|
-
message: `參數名稱重複: ${change.newName}`,
|
|
149
|
-
parameterName: change.newName
|
|
150
|
-
});
|
|
151
|
-
}
|
|
121
|
+
else {
|
|
122
|
+
updatesByFile.set(update.filePath, [update]);
|
|
152
123
|
}
|
|
153
124
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
range: { start: { line: 0, column: 0, offset: 0 }, end: { line: 0, column: 0, offset: 0 } }
|
|
125
|
+
for (const [updateFilePath, updates] of updatesByFile) {
|
|
126
|
+
// 跳過與 definitionUpdate 同一檔案(避免重複)
|
|
127
|
+
// 已經在上面處理過了,呼叫點和定義可能在同一行
|
|
128
|
+
const edits = updates.map(update => {
|
|
129
|
+
// originalCode 和 newCode 都是完整的一行內容
|
|
130
|
+
// 因此 range 應該從行首(column 1)開始,到行尾結束
|
|
131
|
+
const lineStart = update.location.range.start.line;
|
|
132
|
+
const callOriginalLength = update.originalCode.length;
|
|
133
|
+
return {
|
|
134
|
+
range: {
|
|
135
|
+
start: { line: lineStart, column: 1 },
|
|
136
|
+
end: { line: lineStart, column: callOriginalLength + 1 }
|
|
137
|
+
},
|
|
138
|
+
newText: update.newCode,
|
|
139
|
+
description: `Update call: ${update.originalCode.trim()} -> ${update.newCode.trim()}`
|
|
170
140
|
};
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
parameters.splice(change.position, 0, newParam);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
if (isRemoveParameterChange(change)) {
|
|
179
|
-
const index = this.resolveParameterIndex(parameters, change.parameterNameOrIndex);
|
|
180
|
-
if (index >= 0) {
|
|
181
|
-
parameters.splice(index, 1);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (isReorderParametersChange(change)) {
|
|
185
|
-
const newParams = [];
|
|
186
|
-
for (const nameOrIndex of change.newOrder) {
|
|
187
|
-
const index = this.resolveParameterIndex(parameters, nameOrIndex);
|
|
188
|
-
if (index >= 0) {
|
|
189
|
-
newParams.push(parameters[index]);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
parameters = newParams;
|
|
193
|
-
}
|
|
194
|
-
if (isChangeParameterTypeChange(change)) {
|
|
195
|
-
const index = this.resolveParameterIndex(parameters, change.parameterNameOrIndex);
|
|
196
|
-
if (index >= 0) {
|
|
197
|
-
parameters[index] = { ...parameters[index], type: change.newType };
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
if (isRenameParameterChange(change)) {
|
|
201
|
-
const index = this.resolveParameterIndex(parameters, change.parameterNameOrIndex);
|
|
202
|
-
if (index >= 0) {
|
|
203
|
-
parameters[index] = { ...parameters[index], name: change.newName };
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (isChangeDefaultValueChange(change)) {
|
|
207
|
-
const index = this.resolveParameterIndex(parameters, change.parameterNameOrIndex);
|
|
208
|
-
if (index >= 0) {
|
|
209
|
-
parameters[index] = {
|
|
210
|
-
...parameters[index],
|
|
211
|
-
defaultValue: change.newDefaultValue,
|
|
212
|
-
optional: change.newDefaultValue !== undefined || parameters[index].optional
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
if (isToggleOptionalChange(change)) {
|
|
217
|
-
const index = this.resolveParameterIndex(parameters, change.parameterNameOrIndex);
|
|
218
|
-
if (index >= 0) {
|
|
219
|
-
parameters[index] = { ...parameters[index], optional: change.optional };
|
|
220
|
-
}
|
|
221
|
-
}
|
|
141
|
+
});
|
|
142
|
+
builder.addTextChange(updateFilePath, edits, TextEditOperationType.Modify);
|
|
222
143
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
};
|
|
144
|
+
// 設定描述
|
|
145
|
+
const originalParams = result.originalSignature.parameters.map(p => p.name).join(', ');
|
|
146
|
+
const newParams = result.newSignature.parameters.map(p => p.name).join(', ');
|
|
147
|
+
builder.withDescription(`Changed signature of ${result.originalSignature.name}: (${originalParams}) -> (${newParams})`);
|
|
148
|
+
return builder.build();
|
|
227
149
|
}
|
|
228
150
|
/**
|
|
229
151
|
* 生成定義更新
|
|
@@ -252,267 +174,6 @@ export class ChangeSignatureService {
|
|
|
252
174
|
location: originalSignature.location
|
|
253
175
|
};
|
|
254
176
|
}
|
|
255
|
-
/**
|
|
256
|
-
* 生成呼叫點更新
|
|
257
|
-
* 效能優化:按檔案分組後批次讀取,避免重複讀取同一檔案
|
|
258
|
-
* 檔案讀取次數從 O(N) 降到 O(M),N = callSites 數量,M = 不重複檔案數
|
|
259
|
-
* 支援多行呼叫點:正確處理跨多行的函式呼叫
|
|
260
|
-
*/
|
|
261
|
-
async generateCallSiteUpdates(callSites, originalSignature, newSignature, changes) {
|
|
262
|
-
const updates = [];
|
|
263
|
-
// 建立參數映射
|
|
264
|
-
const parameterMapping = this.createParameterMapping(originalSignature, newSignature, changes);
|
|
265
|
-
// 按檔案分組 callSites,避免重複讀取同一檔案
|
|
266
|
-
const callSitesByFile = new Map();
|
|
267
|
-
for (const callSite of callSites) {
|
|
268
|
-
const filePath = callSite.location.filePath;
|
|
269
|
-
const existing = callSitesByFile.get(filePath);
|
|
270
|
-
if (existing) {
|
|
271
|
-
existing.push(callSite);
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
callSitesByFile.set(filePath, [callSite]);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
// 批次讀取所有不重複的檔案並處理
|
|
278
|
-
for (const [filePath, fileCallSites] of callSitesByFile) {
|
|
279
|
-
const content = await this.readFile(filePath);
|
|
280
|
-
if (!content) {
|
|
281
|
-
continue;
|
|
282
|
-
}
|
|
283
|
-
const lines = content.split('\n');
|
|
284
|
-
// 處理該檔案的所有 callSites
|
|
285
|
-
for (const callSite of fileCallSites) {
|
|
286
|
-
const startLineIndex = callSite.location.range.start.line - 1;
|
|
287
|
-
const endLineIndex = callSite.location.range.end.line - 1;
|
|
288
|
-
const isMultiline = startLineIndex !== endLineIndex;
|
|
289
|
-
// 建立新的參數列表
|
|
290
|
-
const newArgs = this.mapCallSiteArguments(callSite, parameterMapping, changes, originalSignature);
|
|
291
|
-
// 找到呼叫的括號位置
|
|
292
|
-
const startLine = lines[startLineIndex];
|
|
293
|
-
const funcNameIndex = startLine.indexOf(callSite.functionName);
|
|
294
|
-
if (funcNameIndex < 0) {
|
|
295
|
-
continue;
|
|
296
|
-
}
|
|
297
|
-
const openParenIndex = startLine.indexOf('(', funcNameIndex);
|
|
298
|
-
if (isMultiline) {
|
|
299
|
-
// 多行呼叫點:提取完整的原始程式碼並替換
|
|
300
|
-
const originalCode = this.extractMultilineCode(lines, startLineIndex, endLineIndex);
|
|
301
|
-
// 檢測原始呼叫的格式風格
|
|
302
|
-
const originalStyle = this.detectCallStyle(lines, startLineIndex, endLineIndex);
|
|
303
|
-
// 生成新的參數字串(保留原始風格)
|
|
304
|
-
const newArgsString = this.formatArgsWithStyle(newArgs, originalStyle);
|
|
305
|
-
// 生成新的程式碼
|
|
306
|
-
const newCode = startLine.substring(0, openParenIndex + 1)
|
|
307
|
-
+ newArgsString
|
|
308
|
-
+ ')' + this.getTrailingContent(lines, endLineIndex, callSite.location.range.end.column - 1);
|
|
309
|
-
if (newCode !== originalCode) {
|
|
310
|
-
updates.push({
|
|
311
|
-
filePath: callSite.location.filePath,
|
|
312
|
-
originalCode,
|
|
313
|
-
newCode,
|
|
314
|
-
location: callSite.location
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
// 單行呼叫點:保持原有邏輯
|
|
320
|
-
const closeParenIndex = this.findMatchingParen(startLine, openParenIndex);
|
|
321
|
-
const newArgsString = newArgs.join(', ');
|
|
322
|
-
const newLine = startLine.substring(0, openParenIndex + 1)
|
|
323
|
-
+ newArgsString
|
|
324
|
-
+ startLine.substring(closeParenIndex);
|
|
325
|
-
if (newLine !== startLine) {
|
|
326
|
-
updates.push({
|
|
327
|
-
filePath: callSite.location.filePath,
|
|
328
|
-
originalCode: startLine,
|
|
329
|
-
newCode: newLine,
|
|
330
|
-
location: callSite.location
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
return updates;
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* 提取多行程式碼
|
|
340
|
-
*/
|
|
341
|
-
extractMultilineCode(lines, startLine, endLine) {
|
|
342
|
-
if (startLine === endLine) {
|
|
343
|
-
return lines[startLine];
|
|
344
|
-
}
|
|
345
|
-
const result = [];
|
|
346
|
-
for (let i = startLine; i <= endLine; i++) {
|
|
347
|
-
result.push(lines[i]);
|
|
348
|
-
}
|
|
349
|
-
return result.join('\n');
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* 檢測呼叫風格
|
|
353
|
-
*/
|
|
354
|
-
detectCallStyle(lines, startLine, endLine) {
|
|
355
|
-
const isMultiline = startLine !== endLine;
|
|
356
|
-
if (!isMultiline) {
|
|
357
|
-
return { multiline: false, indent: '', trailingComma: false };
|
|
358
|
-
}
|
|
359
|
-
// 檢測縮排(從第二行取得)
|
|
360
|
-
const secondLine = lines[startLine + 1] || '';
|
|
361
|
-
const indentMatch = secondLine.match(/^(\s*)/);
|
|
362
|
-
const indent = indentMatch ? indentMatch[1] : ' ';
|
|
363
|
-
// 檢測是否有尾隨逗號
|
|
364
|
-
const lastArgLine = lines[endLine - 1] || lines[endLine];
|
|
365
|
-
const trailingComma = lastArgLine.trimEnd().endsWith(',');
|
|
366
|
-
return { multiline: true, indent, trailingComma };
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* 根據風格格式化參數
|
|
370
|
-
*/
|
|
371
|
-
formatArgsWithStyle(args, style) {
|
|
372
|
-
if (!style.multiline || args.length === 0) {
|
|
373
|
-
return args.join(', ');
|
|
374
|
-
}
|
|
375
|
-
// 多行格式
|
|
376
|
-
const formattedArgs = args.map(arg => `${style.indent}${arg}`);
|
|
377
|
-
const separator = style.trailingComma ? ',\n' : ',\n';
|
|
378
|
-
return '\n' + formattedArgs.join(separator) + (style.trailingComma ? ',' : '') + '\n';
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* 取得結束行的尾隨內容(右括號之後的部分)
|
|
382
|
-
*/
|
|
383
|
-
getTrailingContent(lines, endLine, closeParenColumn) {
|
|
384
|
-
const line = lines[endLine];
|
|
385
|
-
// 找到右括號後的內容
|
|
386
|
-
return line.substring(closeParenColumn + 1);
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* 建立參數映射
|
|
390
|
-
*/
|
|
391
|
-
createParameterMapping(originalSignature, newSignature, changes) {
|
|
392
|
-
const mapping = new Map();
|
|
393
|
-
// 初始化:原始索引 -> 新索引
|
|
394
|
-
let currentParams = originalSignature.parameters.map((p, i) => ({ name: p.name, originalIndex: i }));
|
|
395
|
-
// 處理每個變更
|
|
396
|
-
for (const change of changes) {
|
|
397
|
-
if (isRemoveParameterChange(change)) {
|
|
398
|
-
const index = this.resolveParameterIndex(currentParams.map(p => ({ name: p.name })), change.parameterNameOrIndex);
|
|
399
|
-
if (index >= 0) {
|
|
400
|
-
currentParams.splice(index, 1);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
if (isReorderParametersChange(change)) {
|
|
404
|
-
const newOrder = [];
|
|
405
|
-
for (const nameOrIndex of change.newOrder) {
|
|
406
|
-
const index = this.resolveParameterIndex(currentParams.map(p => ({ name: p.name })), nameOrIndex);
|
|
407
|
-
if (index >= 0) {
|
|
408
|
-
newOrder.push(currentParams[index]);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
currentParams = newOrder;
|
|
412
|
-
}
|
|
413
|
-
if (isAddParameterChange(change)) {
|
|
414
|
-
const newParam = { name: change.name, originalIndex: -1, value: change.callSiteValue || change.defaultValue };
|
|
415
|
-
if (change.position < 0 || change.position >= currentParams.length) {
|
|
416
|
-
currentParams.push(newParam);
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
currentParams.splice(change.position, 0, newParam);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
// 建立最終映射
|
|
424
|
-
for (let newIndex = 0; newIndex < currentParams.length; newIndex++) {
|
|
425
|
-
const param = currentParams[newIndex];
|
|
426
|
-
if (param.originalIndex >= 0) {
|
|
427
|
-
mapping.set(param.originalIndex, { newIndex });
|
|
428
|
-
}
|
|
429
|
-
else if ('value' in param) {
|
|
430
|
-
// 新增的參數,設定預設值
|
|
431
|
-
mapping.set(-1 - newIndex, { newIndex, value: param.value });
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
return mapping;
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* 映射呼叫點參數
|
|
438
|
-
* 處理省略的可選參數:當可選參數被省略時,重排後需要插入 undefined
|
|
439
|
-
*/
|
|
440
|
-
mapCallSiteArguments(callSite, parameterMapping, changes, originalSignature) {
|
|
441
|
-
const result = [];
|
|
442
|
-
// 找出新參數的數量
|
|
443
|
-
let maxNewIndex = -1;
|
|
444
|
-
for (const { newIndex } of parameterMapping.values()) {
|
|
445
|
-
maxNewIndex = Math.max(maxNewIndex, newIndex);
|
|
446
|
-
}
|
|
447
|
-
// 初始化結果陣列
|
|
448
|
-
for (let i = 0; i <= maxNewIndex; i++) {
|
|
449
|
-
result.push('');
|
|
450
|
-
}
|
|
451
|
-
// 映射原始參數
|
|
452
|
-
for (const [originalIndex, { newIndex }] of parameterMapping.entries()) {
|
|
453
|
-
if (originalIndex >= 0) {
|
|
454
|
-
if (originalIndex < callSite.arguments.length) {
|
|
455
|
-
// 呼叫點有提供此參數
|
|
456
|
-
result[newIndex] = callSite.arguments[originalIndex].value;
|
|
457
|
-
}
|
|
458
|
-
else {
|
|
459
|
-
// 呼叫點省略了此可選參數
|
|
460
|
-
// 檢查這個位置是否需要填入 undefined(當後面有其他參數時)
|
|
461
|
-
const param = originalSignature.parameters[originalIndex];
|
|
462
|
-
if (param && (param.optional || param.defaultValue)) {
|
|
463
|
-
// 標記為需要填入 undefined(如果後面有非空參數)
|
|
464
|
-
result[newIndex] = '\0OMITTED\0';
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
// 填入新增參數的值
|
|
470
|
-
const addedPositions = new Set();
|
|
471
|
-
for (const change of changes) {
|
|
472
|
-
if (isAddParameterChange(change)) {
|
|
473
|
-
// 使用 callSiteValue 或 defaultValue(驗證階段已確保至少有一個值)
|
|
474
|
-
const value = change.callSiteValue || change.defaultValue;
|
|
475
|
-
const position = change.position < 0 ? result.length - 1 : Math.min(change.position, result.length - 1);
|
|
476
|
-
if (position >= 0 && position < result.length && !result[position]) {
|
|
477
|
-
result[position] = value;
|
|
478
|
-
addedPositions.add(position);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
// 處理省略的可選參數:
|
|
483
|
-
// 如果省略的參數後面有非空參數,則需要填入 undefined
|
|
484
|
-
// 否則可以完全省略
|
|
485
|
-
const processedResult = [];
|
|
486
|
-
let lastNonEmptyIndex = -1;
|
|
487
|
-
// 找到最後一個非空參數的索引
|
|
488
|
-
for (let i = result.length - 1; i >= 0; i--) {
|
|
489
|
-
if (result[i] !== '' && result[i] !== '\0OMITTED\0') {
|
|
490
|
-
lastNonEmptyIndex = i;
|
|
491
|
-
break;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
// 建立最終結果
|
|
495
|
-
for (let i = 0; i <= lastNonEmptyIndex; i++) {
|
|
496
|
-
if (result[i] === '\0OMITTED\0') {
|
|
497
|
-
// 省略的可選參數,但後面有其他參數,需要填入 undefined
|
|
498
|
-
processedResult.push('undefined');
|
|
499
|
-
}
|
|
500
|
-
else if (result[i] === '') {
|
|
501
|
-
// 空值,檢查是否是新增的位置
|
|
502
|
-
if (addedPositions.has(i)) {
|
|
503
|
-
processedResult.push('undefined');
|
|
504
|
-
}
|
|
505
|
-
else {
|
|
506
|
-
// 不應該出現的情況,填入 undefined 以避免語法錯誤
|
|
507
|
-
processedResult.push('undefined');
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
else {
|
|
511
|
-
processedResult.push(result[i]);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
return processedResult;
|
|
515
|
-
}
|
|
516
177
|
/**
|
|
517
178
|
* 執行變更
|
|
518
179
|
*/
|
|
@@ -595,61 +256,6 @@ export class ChangeSignatureService {
|
|
|
595
256
|
}
|
|
596
257
|
return line.length;
|
|
597
258
|
}
|
|
598
|
-
/**
|
|
599
|
-
* 解析參數名稱
|
|
600
|
-
*/
|
|
601
|
-
resolveParameterName(signature, nameOrIndex) {
|
|
602
|
-
if (typeof nameOrIndex === 'number') {
|
|
603
|
-
return signature.parameters[nameOrIndex]?.name;
|
|
604
|
-
}
|
|
605
|
-
return signature.parameters.find(p => p.name === nameOrIndex)?.name;
|
|
606
|
-
}
|
|
607
|
-
/**
|
|
608
|
-
* 解析參數索引
|
|
609
|
-
*/
|
|
610
|
-
resolveParameterIndex(parameters, nameOrIndex) {
|
|
611
|
-
if (typeof nameOrIndex === 'number') {
|
|
612
|
-
return nameOrIndex >= 0 && nameOrIndex < parameters.length ? nameOrIndex : -1;
|
|
613
|
-
}
|
|
614
|
-
return parameters.findIndex(p => p.name === nameOrIndex);
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* 驗證可選參數順序
|
|
618
|
-
* TypeScript 規則:可選參數必須在所有必選參數之後
|
|
619
|
-
* 例外:有預設值的參數視為可選,rest 參數必須在最後
|
|
620
|
-
*/
|
|
621
|
-
validateOptionalParameterOrder(signature, newOrder) {
|
|
622
|
-
// 根據新順序建立參數列表
|
|
623
|
-
const reorderedParams = [];
|
|
624
|
-
for (const nameOrIndex of newOrder) {
|
|
625
|
-
const index = this.resolveParameterIndex(signature.parameters, nameOrIndex);
|
|
626
|
-
if (index >= 0) {
|
|
627
|
-
reorderedParams.push(signature.parameters[index]);
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
// 檢查可選參數是否在必選參數之前
|
|
631
|
-
let foundOptional = false;
|
|
632
|
-
let firstOptionalParam = null;
|
|
633
|
-
for (const param of reorderedParams) {
|
|
634
|
-
const isOptional = param.optional || param.defaultValue !== undefined;
|
|
635
|
-
const isRest = param.rest;
|
|
636
|
-
if (isOptional && !isRest) {
|
|
637
|
-
foundOptional = true;
|
|
638
|
-
if (!firstOptionalParam) {
|
|
639
|
-
firstOptionalParam = param;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
else if (!isOptional && !isRest && foundOptional) {
|
|
643
|
-
// 找到必選參數在可選參數之後
|
|
644
|
-
return {
|
|
645
|
-
code: ChangeSignatureErrorCode.OptionalBeforeRequired,
|
|
646
|
-
message: `可選參數 '${firstOptionalParam.name}' 不能位於必選參數 '${param.name}' 之前`,
|
|
647
|
-
parameterName: param.name
|
|
648
|
-
};
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
return null;
|
|
652
|
-
}
|
|
653
259
|
/**
|
|
654
260
|
* 取得專案檔案
|
|
655
261
|
*/
|
|
@@ -707,12 +313,22 @@ export class ChangeSignatureService {
|
|
|
707
313
|
* 建立錯誤結果
|
|
708
314
|
*/
|
|
709
315
|
createErrorResult(code, message) {
|
|
316
|
+
// 錯誤情況下必須提供佔位簽名資訊
|
|
317
|
+
const emptyRange = { start: { line: 0, column: 0, offset: 0 }, end: { line: 0, column: 0, offset: 0 } };
|
|
318
|
+
const emptyLocation = { filePath: '', range: emptyRange };
|
|
319
|
+
const emptySignature = {
|
|
320
|
+
name: '',
|
|
321
|
+
parameters: [],
|
|
322
|
+
location: emptyLocation,
|
|
323
|
+
isMethod: false,
|
|
324
|
+
modifiers: []
|
|
325
|
+
};
|
|
710
326
|
return {
|
|
711
327
|
success: false,
|
|
712
328
|
error: message,
|
|
713
|
-
originalSignature:
|
|
714
|
-
newSignature:
|
|
715
|
-
definitionUpdate:
|
|
329
|
+
originalSignature: emptySignature,
|
|
330
|
+
newSignature: emptySignature,
|
|
331
|
+
definitionUpdate: { filePath: '', originalCode: '', newCode: '', location: emptyLocation },
|
|
716
332
|
callSiteUpdates: [],
|
|
717
333
|
executed: false,
|
|
718
334
|
stats: {
|