agent-ide 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +678 -0
- package/bin/agent-ide.js +19 -0
- package/bin/mcp-server.js +20 -0
- package/dist/application/events/event-bus.d.ts +107 -0
- package/dist/application/events/event-bus.d.ts.map +1 -0
- package/dist/application/events/event-bus.js +364 -0
- package/dist/application/events/event-bus.js.map +1 -0
- package/dist/application/events/event-types.d.ts +195 -0
- package/dist/application/events/event-types.d.ts.map +1 -0
- package/dist/application/events/event-types.js +36 -0
- package/dist/application/events/event-types.js.map +1 -0
- package/dist/application/events/index.d.ts +6 -0
- package/dist/application/events/index.d.ts.map +1 -0
- package/dist/application/events/index.js +6 -0
- package/dist/application/events/index.js.map +1 -0
- package/dist/application/index.d.ts +85 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +138 -0
- package/dist/application/index.js.map +1 -0
- package/dist/application/services/cache-coordinator.service.d.ts +69 -0
- package/dist/application/services/cache-coordinator.service.d.ts.map +1 -0
- package/dist/application/services/cache-coordinator.service.js +251 -0
- package/dist/application/services/cache-coordinator.service.js.map +1 -0
- package/dist/application/services/error-handler.service.d.ts +56 -0
- package/dist/application/services/error-handler.service.d.ts.map +1 -0
- package/dist/application/services/error-handler.service.js +273 -0
- package/dist/application/services/error-handler.service.js.map +1 -0
- package/dist/application/services/index.d.ts +8 -0
- package/dist/application/services/index.d.ts.map +1 -0
- package/dist/application/services/index.js +8 -0
- package/dist/application/services/index.js.map +1 -0
- package/dist/application/services/module-coordinator.service.d.ts +70 -0
- package/dist/application/services/module-coordinator.service.d.ts.map +1 -0
- package/dist/application/services/module-coordinator.service.js +418 -0
- package/dist/application/services/module-coordinator.service.js.map +1 -0
- package/dist/application/services/session-manager.service.d.ts +86 -0
- package/dist/application/services/session-manager.service.d.ts.map +1 -0
- package/dist/application/services/session-manager.service.js +318 -0
- package/dist/application/services/session-manager.service.js.map +1 -0
- package/dist/application/services/workflow-engine.service.d.ts +76 -0
- package/dist/application/services/workflow-engine.service.d.ts.map +1 -0
- package/dist/application/services/workflow-engine.service.js +405 -0
- package/dist/application/services/workflow-engine.service.js.map +1 -0
- package/dist/application/state/application-state.d.ts +164 -0
- package/dist/application/state/application-state.d.ts.map +1 -0
- package/dist/application/state/application-state.js +290 -0
- package/dist/application/state/application-state.js.map +1 -0
- package/dist/application/state/index.d.ts +15 -0
- package/dist/application/state/index.d.ts.map +1 -0
- package/dist/application/state/index.js +15 -0
- package/dist/application/state/index.js.map +1 -0
- package/dist/application/state/session-state.d.ts +114 -0
- package/dist/application/state/session-state.d.ts.map +1 -0
- package/dist/application/state/session-state.js +188 -0
- package/dist/application/state/session-state.js.map +1 -0
- package/dist/application/state/state-manager.d.ts +122 -0
- package/dist/application/state/state-manager.d.ts.map +1 -0
- package/dist/application/state/state-manager.js +234 -0
- package/dist/application/state/state-manager.js.map +1 -0
- package/dist/application/types.d.ts +280 -0
- package/dist/application/types.d.ts.map +1 -0
- package/dist/application/types.js +13 -0
- package/dist/application/types.js.map +1 -0
- package/dist/application/workflows/analysis-workflow.d.ts +239 -0
- package/dist/application/workflows/analysis-workflow.d.ts.map +1 -0
- package/dist/application/workflows/analysis-workflow.js +395 -0
- package/dist/application/workflows/analysis-workflow.js.map +1 -0
- package/dist/application/workflows/base-workflow.d.ts +108 -0
- package/dist/application/workflows/base-workflow.d.ts.map +1 -0
- package/dist/application/workflows/base-workflow.js +236 -0
- package/dist/application/workflows/base-workflow.js.map +1 -0
- package/dist/application/workflows/index.d.ts +115 -0
- package/dist/application/workflows/index.d.ts.map +1 -0
- package/dist/application/workflows/index.js +218 -0
- package/dist/application/workflows/index.js.map +1 -0
- package/dist/application/workflows/refactor-workflow.d.ts +107 -0
- package/dist/application/workflows/refactor-workflow.d.ts.map +1 -0
- package/dist/application/workflows/refactor-workflow.js +310 -0
- package/dist/application/workflows/refactor-workflow.js.map +1 -0
- package/dist/core/analysis/complexity-analyzer.d.ts +81 -0
- package/dist/core/analysis/complexity-analyzer.d.ts.map +1 -0
- package/dist/core/analysis/complexity-analyzer.js +254 -0
- package/dist/core/analysis/complexity-analyzer.js.map +1 -0
- package/dist/core/analysis/dead-code-detector.d.ts +123 -0
- package/dist/core/analysis/dead-code-detector.d.ts.map +1 -0
- package/dist/core/analysis/dead-code-detector.js +275 -0
- package/dist/core/analysis/dead-code-detector.js.map +1 -0
- package/dist/core/analysis/duplication-detector.d.ts +150 -0
- package/dist/core/analysis/duplication-detector.d.ts.map +1 -0
- package/dist/core/analysis/duplication-detector.js +433 -0
- package/dist/core/analysis/duplication-detector.js.map +1 -0
- package/dist/core/analysis/index.d.ts +9 -0
- package/dist/core/analysis/index.d.ts.map +1 -0
- package/dist/core/analysis/index.js +13 -0
- package/dist/core/analysis/index.js.map +1 -0
- package/dist/core/analysis/quality-metrics.d.ts +158 -0
- package/dist/core/analysis/quality-metrics.d.ts.map +1 -0
- package/dist/core/analysis/quality-metrics.js +442 -0
- package/dist/core/analysis/quality-metrics.js.map +1 -0
- package/dist/core/dependency/cycle-detector.d.ts +81 -0
- package/dist/core/dependency/cycle-detector.d.ts.map +1 -0
- package/dist/core/dependency/cycle-detector.js +300 -0
- package/dist/core/dependency/cycle-detector.js.map +1 -0
- package/dist/core/dependency/dependency-analyzer.d.ts +152 -0
- package/dist/core/dependency/dependency-analyzer.d.ts.map +1 -0
- package/dist/core/dependency/dependency-analyzer.js +458 -0
- package/dist/core/dependency/dependency-analyzer.js.map +1 -0
- package/dist/core/dependency/dependency-graph.d.ts +156 -0
- package/dist/core/dependency/dependency-graph.d.ts.map +1 -0
- package/dist/core/dependency/dependency-graph.js +371 -0
- package/dist/core/dependency/dependency-graph.js.map +1 -0
- package/dist/core/dependency/index.d.ts +27 -0
- package/dist/core/dependency/index.d.ts.map +1 -0
- package/dist/core/dependency/index.js +36 -0
- package/dist/core/dependency/index.js.map +1 -0
- package/dist/core/dependency/types.d.ts +168 -0
- package/dist/core/dependency/types.d.ts.map +1 -0
- package/dist/core/dependency/types.js +103 -0
- package/dist/core/dependency/types.js.map +1 -0
- package/dist/core/indexing/file-index.d.ts +117 -0
- package/dist/core/indexing/file-index.d.ts.map +1 -0
- package/dist/core/indexing/file-index.js +302 -0
- package/dist/core/indexing/file-index.js.map +1 -0
- package/dist/core/indexing/file-watcher.d.ts +110 -0
- package/dist/core/indexing/file-watcher.d.ts.map +1 -0
- package/dist/core/indexing/file-watcher.js +280 -0
- package/dist/core/indexing/file-watcher.js.map +1 -0
- package/dist/core/indexing/index-engine.d.ts +120 -0
- package/dist/core/indexing/index-engine.d.ts.map +1 -0
- package/dist/core/indexing/index-engine.js +445 -0
- package/dist/core/indexing/index-engine.js.map +1 -0
- package/dist/core/indexing/index.d.ts +25 -0
- package/dist/core/indexing/index.d.ts.map +1 -0
- package/dist/core/indexing/index.js +36 -0
- package/dist/core/indexing/index.js.map +1 -0
- package/dist/core/indexing/symbol-index.d.ts +107 -0
- package/dist/core/indexing/symbol-index.d.ts.map +1 -0
- package/dist/core/indexing/symbol-index.js +352 -0
- package/dist/core/indexing/symbol-index.js.map +1 -0
- package/dist/core/indexing/types.d.ts +222 -0
- package/dist/core/indexing/types.d.ts.map +1 -0
- package/dist/core/indexing/types.js +143 -0
- package/dist/core/indexing/types.js.map +1 -0
- package/dist/core/move/import-resolver.d.ts +54 -0
- package/dist/core/move/import-resolver.d.ts.map +1 -0
- package/dist/core/move/import-resolver.js +268 -0
- package/dist/core/move/import-resolver.js.map +1 -0
- package/dist/core/move/index.d.ts +10 -0
- package/dist/core/move/index.d.ts.map +1 -0
- package/dist/core/move/index.js +12 -0
- package/dist/core/move/index.js.map +1 -0
- package/dist/core/move/move-service.d.ts +67 -0
- package/dist/core/move/move-service.d.ts.map +1 -0
- package/dist/core/move/move-service.js +400 -0
- package/dist/core/move/move-service.js.map +1 -0
- package/dist/core/move/types.d.ts +266 -0
- package/dist/core/move/types.d.ts.map +1 -0
- package/dist/core/move/types.js +101 -0
- package/dist/core/move/types.js.map +1 -0
- package/dist/core/performance/analyzer.d.ts +62 -0
- package/dist/core/performance/analyzer.d.ts.map +1 -0
- package/dist/core/performance/analyzer.js +378 -0
- package/dist/core/performance/analyzer.js.map +1 -0
- package/dist/core/performance/cache-manager.d.ts +161 -0
- package/dist/core/performance/cache-manager.d.ts.map +1 -0
- package/dist/core/performance/cache-manager.js +375 -0
- package/dist/core/performance/cache-manager.js.map +1 -0
- package/dist/core/performance/index.d.ts +14 -0
- package/dist/core/performance/index.d.ts.map +1 -0
- package/dist/core/performance/index.js +17 -0
- package/dist/core/performance/index.js.map +1 -0
- package/dist/core/performance/interfaces.d.ts +188 -0
- package/dist/core/performance/interfaces.d.ts.map +1 -0
- package/dist/core/performance/interfaces.js +17 -0
- package/dist/core/performance/interfaces.js.map +1 -0
- package/dist/core/performance/memory-manager.d.ts +176 -0
- package/dist/core/performance/memory-manager.d.ts.map +1 -0
- package/dist/core/performance/memory-manager.js +364 -0
- package/dist/core/performance/memory-manager.js.map +1 -0
- package/dist/core/performance/monitor.d.ts +92 -0
- package/dist/core/performance/monitor.d.ts.map +1 -0
- package/dist/core/performance/monitor.js +228 -0
- package/dist/core/performance/monitor.js.map +1 -0
- package/dist/core/refactor/design-patterns.d.ts +178 -0
- package/dist/core/refactor/design-patterns.d.ts.map +1 -0
- package/dist/core/refactor/design-patterns.js +656 -0
- package/dist/core/refactor/design-patterns.js.map +1 -0
- package/dist/core/refactor/extract-function.d.ts +175 -0
- package/dist/core/refactor/extract-function.d.ts.map +1 -0
- package/dist/core/refactor/extract-function.js +478 -0
- package/dist/core/refactor/extract-function.js.map +1 -0
- package/dist/core/refactor/index.d.ts +8 -0
- package/dist/core/refactor/index.d.ts.map +1 -0
- package/dist/core/refactor/index.js +11 -0
- package/dist/core/refactor/index.js.map +1 -0
- package/dist/core/refactor/inline-function.d.ts +175 -0
- package/dist/core/refactor/inline-function.d.ts.map +1 -0
- package/dist/core/refactor/inline-function.js +425 -0
- package/dist/core/refactor/inline-function.js.map +1 -0
- package/dist/core/rename/index.d.ts +9 -0
- package/dist/core/rename/index.d.ts.map +1 -0
- package/dist/core/rename/index.js +13 -0
- package/dist/core/rename/index.js.map +1 -0
- package/dist/core/rename/reference-updater.d.ts +77 -0
- package/dist/core/rename/reference-updater.d.ts.map +1 -0
- package/dist/core/rename/reference-updater.js +400 -0
- package/dist/core/rename/reference-updater.js.map +1 -0
- package/dist/core/rename/rename-engine.d.ts +69 -0
- package/dist/core/rename/rename-engine.d.ts.map +1 -0
- package/dist/core/rename/rename-engine.js +350 -0
- package/dist/core/rename/rename-engine.js.map +1 -0
- package/dist/core/rename/scope-analyzer.d.ts +75 -0
- package/dist/core/rename/scope-analyzer.d.ts.map +1 -0
- package/dist/core/rename/scope-analyzer.js +269 -0
- package/dist/core/rename/scope-analyzer.js.map +1 -0
- package/dist/core/rename/types.d.ts +163 -0
- package/dist/core/rename/types.d.ts.map +1 -0
- package/dist/core/rename/types.js +80 -0
- package/dist/core/rename/types.js.map +1 -0
- package/dist/core/search/engines/text-engine.d.ts +52 -0
- package/dist/core/search/engines/text-engine.d.ts.map +1 -0
- package/dist/core/search/engines/text-engine.js +376 -0
- package/dist/core/search/engines/text-engine.js.map +1 -0
- package/dist/core/search/index.d.ts +10 -0
- package/dist/core/search/index.d.ts.map +1 -0
- package/dist/core/search/index.js +11 -0
- package/dist/core/search/index.js.map +1 -0
- package/dist/core/search/service.d.ts +105 -0
- package/dist/core/search/service.d.ts.map +1 -0
- package/dist/core/search/service.js +384 -0
- package/dist/core/search/service.js.map +1 -0
- package/dist/core/search/types.d.ts +357 -0
- package/dist/core/search/types.d.ts.map +1 -0
- package/dist/core/search/types.js +47 -0
- package/dist/core/search/types.js.map +1 -0
- package/dist/infrastructure/cache/cache-manager.d.ts +113 -0
- package/dist/infrastructure/cache/cache-manager.d.ts.map +1 -0
- package/dist/infrastructure/cache/cache-manager.js +279 -0
- package/dist/infrastructure/cache/cache-manager.js.map +1 -0
- package/dist/infrastructure/cache/index.d.ts +138 -0
- package/dist/infrastructure/cache/index.d.ts.map +1 -0
- package/dist/infrastructure/cache/index.js +266 -0
- package/dist/infrastructure/cache/index.js.map +1 -0
- package/dist/infrastructure/cache/memory-cache.d.ts +94 -0
- package/dist/infrastructure/cache/memory-cache.d.ts.map +1 -0
- package/dist/infrastructure/cache/memory-cache.js +327 -0
- package/dist/infrastructure/cache/memory-cache.js.map +1 -0
- package/dist/infrastructure/cache/strategies.d.ts +99 -0
- package/dist/infrastructure/cache/strategies.d.ts.map +1 -0
- package/dist/infrastructure/cache/strategies.js +230 -0
- package/dist/infrastructure/cache/strategies.js.map +1 -0
- package/dist/infrastructure/cache/types.d.ts +220 -0
- package/dist/infrastructure/cache/types.d.ts.map +1 -0
- package/dist/infrastructure/cache/types.js +42 -0
- package/dist/infrastructure/cache/types.js.map +1 -0
- package/dist/infrastructure/parser/base.d.ts +126 -0
- package/dist/infrastructure/parser/base.d.ts.map +1 -0
- package/dist/infrastructure/parser/base.js +269 -0
- package/dist/infrastructure/parser/base.js.map +1 -0
- package/dist/infrastructure/parser/factory.d.ts +141 -0
- package/dist/infrastructure/parser/factory.d.ts.map +1 -0
- package/dist/infrastructure/parser/factory.js +306 -0
- package/dist/infrastructure/parser/factory.js.map +1 -0
- package/dist/infrastructure/parser/index.d.ts +12 -0
- package/dist/infrastructure/parser/index.d.ts.map +1 -0
- package/dist/infrastructure/parser/index.js +12 -0
- package/dist/infrastructure/parser/index.js.map +1 -0
- package/dist/infrastructure/parser/interface.d.ts +108 -0
- package/dist/infrastructure/parser/interface.d.ts.map +1 -0
- package/dist/infrastructure/parser/interface.js +72 -0
- package/dist/infrastructure/parser/interface.js.map +1 -0
- package/dist/infrastructure/parser/registry.d.ts +141 -0
- package/dist/infrastructure/parser/registry.d.ts.map +1 -0
- package/dist/infrastructure/parser/registry.js +289 -0
- package/dist/infrastructure/parser/registry.js.map +1 -0
- package/dist/infrastructure/parser/types.d.ts +172 -0
- package/dist/infrastructure/parser/types.d.ts.map +1 -0
- package/dist/infrastructure/parser/types.js +147 -0
- package/dist/infrastructure/parser/types.js.map +1 -0
- package/dist/infrastructure/storage/file-system.d.ts +74 -0
- package/dist/infrastructure/storage/file-system.d.ts.map +1 -0
- package/dist/infrastructure/storage/file-system.js +334 -0
- package/dist/infrastructure/storage/file-system.js.map +1 -0
- package/dist/infrastructure/storage/file-watcher.d.ts +84 -0
- package/dist/infrastructure/storage/file-watcher.d.ts.map +1 -0
- package/dist/infrastructure/storage/file-watcher.js +249 -0
- package/dist/infrastructure/storage/file-watcher.js.map +1 -0
- package/dist/infrastructure/storage/index.d.ts +11 -0
- package/dist/infrastructure/storage/index.d.ts.map +1 -0
- package/dist/infrastructure/storage/index.js +16 -0
- package/dist/infrastructure/storage/index.js.map +1 -0
- package/dist/infrastructure/storage/path-utils.d.ts +96 -0
- package/dist/infrastructure/storage/path-utils.d.ts.map +1 -0
- package/dist/infrastructure/storage/path-utils.js +272 -0
- package/dist/infrastructure/storage/path-utils.js.map +1 -0
- package/dist/infrastructure/storage/types.d.ts +106 -0
- package/dist/infrastructure/storage/types.d.ts.map +1 -0
- package/dist/infrastructure/storage/types.js +53 -0
- package/dist/infrastructure/storage/types.js.map +1 -0
- package/dist/interfaces/cli/cli.d.ts +70 -0
- package/dist/interfaces/cli/cli.d.ts.map +1 -0
- package/dist/interfaces/cli/cli.js +1054 -0
- package/dist/interfaces/cli/cli.js.map +1 -0
- package/dist/interfaces/cli/index.d.ts +7 -0
- package/dist/interfaces/cli/index.d.ts.map +1 -0
- package/dist/interfaces/cli/index.js +22 -0
- package/dist/interfaces/cli/index.js.map +1 -0
- package/dist/interfaces/mcp/index.d.ts +7 -0
- package/dist/interfaces/mcp/index.d.ts.map +1 -0
- package/dist/interfaces/mcp/index.js +6 -0
- package/dist/interfaces/mcp/index.js.map +1 -0
- package/dist/interfaces/mcp/mcp-server.d.ts +34 -0
- package/dist/interfaces/mcp/mcp-server.d.ts.map +1 -0
- package/dist/interfaces/mcp/mcp-server.js +154 -0
- package/dist/interfaces/mcp/mcp-server.js.map +1 -0
- package/dist/interfaces/mcp/mcp.d.ts +44 -0
- package/dist/interfaces/mcp/mcp.d.ts.map +1 -0
- package/dist/interfaces/mcp/mcp.js +559 -0
- package/dist/interfaces/mcp/mcp.js.map +1 -0
- package/dist/plugins/javascript/index.d.ts +12 -0
- package/dist/plugins/javascript/index.d.ts.map +1 -0
- package/dist/plugins/javascript/index.js +16 -0
- package/dist/plugins/javascript/index.js.map +1 -0
- package/dist/plugins/javascript/parser.d.ts +81 -0
- package/dist/plugins/javascript/parser.d.ts.map +1 -0
- package/dist/plugins/javascript/parser.js +457 -0
- package/dist/plugins/javascript/parser.js.map +1 -0
- package/dist/plugins/javascript/types.d.ts +131 -0
- package/dist/plugins/javascript/types.d.ts.map +1 -0
- package/dist/plugins/javascript/types.js +366 -0
- package/dist/plugins/javascript/types.js.map +1 -0
- package/dist/plugins/swift/index.d.ts +11 -0
- package/dist/plugins/swift/index.d.ts.map +1 -0
- package/dist/plugins/swift/index.js +15 -0
- package/dist/plugins/swift/index.js.map +1 -0
- package/dist/plugins/swift/parser.d.ts +98 -0
- package/dist/plugins/swift/parser.d.ts.map +1 -0
- package/dist/plugins/swift/parser.js +612 -0
- package/dist/plugins/swift/parser.js.map +1 -0
- package/dist/plugins/swift/types.d.ts +196 -0
- package/dist/plugins/swift/types.d.ts.map +1 -0
- package/dist/plugins/swift/types.js +268 -0
- package/dist/plugins/swift/types.js.map +1 -0
- package/dist/plugins/typescript/dependency-analyzer.d.ts +78 -0
- package/dist/plugins/typescript/dependency-analyzer.d.ts.map +1 -0
- package/dist/plugins/typescript/dependency-analyzer.js +305 -0
- package/dist/plugins/typescript/dependency-analyzer.js.map +1 -0
- package/dist/plugins/typescript/index.d.ts +9 -0
- package/dist/plugins/typescript/index.d.ts.map +1 -0
- package/dist/plugins/typescript/index.js +8 -0
- package/dist/plugins/typescript/index.js.map +1 -0
- package/dist/plugins/typescript/parser.d.ts +117 -0
- package/dist/plugins/typescript/parser.d.ts.map +1 -0
- package/dist/plugins/typescript/parser.js +888 -0
- package/dist/plugins/typescript/parser.js.map +1 -0
- package/dist/plugins/typescript/symbol-extractor.d.ts +76 -0
- package/dist/plugins/typescript/symbol-extractor.d.ts.map +1 -0
- package/dist/plugins/typescript/symbol-extractor.js +339 -0
- package/dist/plugins/typescript/symbol-extractor.js.map +1 -0
- package/dist/plugins/typescript/types.d.ts +131 -0
- package/dist/plugins/typescript/types.d.ts.map +1 -0
- package/dist/plugins/typescript/types.js +331 -0
- package/dist/plugins/typescript/types.js.map +1 -0
- package/dist/shared/errors/base-error.d.ts +27 -0
- package/dist/shared/errors/base-error.d.ts.map +1 -0
- package/dist/shared/errors/base-error.js +58 -0
- package/dist/shared/errors/base-error.js.map +1 -0
- package/dist/shared/errors/config-error.d.ts +21 -0
- package/dist/shared/errors/config-error.d.ts.map +1 -0
- package/dist/shared/errors/config-error.js +34 -0
- package/dist/shared/errors/config-error.js.map +1 -0
- package/dist/shared/errors/file-error.d.ts +21 -0
- package/dist/shared/errors/file-error.d.ts.map +1 -0
- package/dist/shared/errors/file-error.js +34 -0
- package/dist/shared/errors/file-error.js.map +1 -0
- package/dist/shared/errors/index.d.ts +59 -0
- package/dist/shared/errors/index.d.ts.map +1 -0
- package/dist/shared/errors/index.js +114 -0
- package/dist/shared/errors/index.js.map +1 -0
- package/dist/shared/errors/parser-error.d.ts +72 -0
- package/dist/shared/errors/parser-error.d.ts.map +1 -0
- package/dist/shared/errors/parser-error.js +104 -0
- package/dist/shared/errors/parser-error.js.map +1 -0
- package/dist/shared/errors/validation-error.d.ts +21 -0
- package/dist/shared/errors/validation-error.d.ts.map +1 -0
- package/dist/shared/errors/validation-error.js +34 -0
- package/dist/shared/errors/validation-error.js.map +1 -0
- package/dist/shared/index.d.ts +11 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +22 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/types/ast.d.ts +78 -0
- package/dist/shared/types/ast.d.ts.map +1 -0
- package/dist/shared/types/ast.js +215 -0
- package/dist/shared/types/ast.js.map +1 -0
- package/dist/shared/types/core.d.ts +65 -0
- package/dist/shared/types/core.d.ts.map +1 -0
- package/dist/shared/types/core.js +114 -0
- package/dist/shared/types/core.js.map +1 -0
- package/dist/shared/types/index.d.ts +11 -0
- package/dist/shared/types/index.d.ts.map +1 -0
- package/dist/shared/types/index.js +12 -0
- package/dist/shared/types/index.js.map +1 -0
- package/dist/shared/types/symbol.d.ts +119 -0
- package/dist/shared/types/symbol.d.ts.map +1 -0
- package/dist/shared/types/symbol.js +197 -0
- package/dist/shared/types/symbol.js.map +1 -0
- package/dist/shared/utils/array.d.ts +68 -0
- package/dist/shared/utils/array.d.ts.map +1 -0
- package/dist/shared/utils/array.js +165 -0
- package/dist/shared/utils/array.js.map +1 -0
- package/dist/shared/utils/async.d.ts +87 -0
- package/dist/shared/utils/async.d.ts.map +1 -0
- package/dist/shared/utils/async.js +185 -0
- package/dist/shared/utils/async.js.map +1 -0
- package/dist/shared/utils/index.d.ts +32 -0
- package/dist/shared/utils/index.d.ts.map +1 -0
- package/dist/shared/utils/index.js +37 -0
- package/dist/shared/utils/index.js.map +1 -0
- package/dist/shared/utils/memory-monitor.d.ts +83 -0
- package/dist/shared/utils/memory-monitor.d.ts.map +1 -0
- package/dist/shared/utils/memory-monitor.js +168 -0
- package/dist/shared/utils/memory-monitor.js.map +1 -0
- package/dist/shared/utils/object.d.ts +71 -0
- package/dist/shared/utils/object.d.ts.map +1 -0
- package/dist/shared/utils/object.js +284 -0
- package/dist/shared/utils/object.js.map +1 -0
- package/dist/shared/utils/path.d.ts +59 -0
- package/dist/shared/utils/path.d.ts.map +1 -0
- package/dist/shared/utils/path.js +201 -0
- package/dist/shared/utils/path.js.map +1 -0
- package/dist/shared/utils/string.d.ts +74 -0
- package/dist/shared/utils/string.d.ts.map +1 -0
- package/dist/shared/utils/string.js +201 -0
- package/dist/shared/utils/string.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 作用域分析器實作
|
|
3
|
+
* 負責分析程式碼的作用域結構和符號可見性
|
|
4
|
+
*/
|
|
5
|
+
import { SymbolType, createSymbol } from '../../shared/types/symbol.js';
|
|
6
|
+
import { createLocation, isPositionInRange } from '../../shared/types/core.js';
|
|
7
|
+
/**
|
|
8
|
+
* 作用域分析器類別
|
|
9
|
+
*/
|
|
10
|
+
export class ScopeAnalyzer {
|
|
11
|
+
currentScopes = [];
|
|
12
|
+
symbolTable = new Map();
|
|
13
|
+
/**
|
|
14
|
+
* 分析 AST 的作用域結構
|
|
15
|
+
*/
|
|
16
|
+
async analyzeScopes(ast) {
|
|
17
|
+
this.currentScopes = [];
|
|
18
|
+
this.symbolTable.clear();
|
|
19
|
+
// 檢查 AST 是否有效
|
|
20
|
+
if (!ast || !ast.root) {
|
|
21
|
+
// 返回空的作用域列表
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
// 建立全域作用域
|
|
25
|
+
const globalScope = {
|
|
26
|
+
type: 'global',
|
|
27
|
+
symbols: [],
|
|
28
|
+
range: ast.root.range || {
|
|
29
|
+
start: { line: 1, column: 0 },
|
|
30
|
+
end: { line: 1, column: 0 }
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
this.currentScopes.push(globalScope);
|
|
34
|
+
// 遞歸分析 AST 節點
|
|
35
|
+
await this.analyzeNode(ast.root, globalScope);
|
|
36
|
+
return this.currentScopes;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 尋找被遮蔽的變數
|
|
40
|
+
*/
|
|
41
|
+
async findShadowedVariables(ast) {
|
|
42
|
+
const scopes = await this.analyzeScopes(ast);
|
|
43
|
+
const shadowedVars = [];
|
|
44
|
+
// 檢查每個作用域的符號
|
|
45
|
+
for (const scope of scopes) {
|
|
46
|
+
for (const symbol of scope.symbols) {
|
|
47
|
+
const shadows = this.findShadowingSymbols(symbol, scopes, scope);
|
|
48
|
+
if (shadows.length > 0) {
|
|
49
|
+
const existing = shadowedVars.find(sv => sv.name === symbol.name);
|
|
50
|
+
if (existing) {
|
|
51
|
+
existing.shadowedBy.push(...shadows);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
shadowedVars.push({
|
|
55
|
+
name: symbol.name,
|
|
56
|
+
originalSymbol: symbol,
|
|
57
|
+
shadowedBy: shadows
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return shadowedVars;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 根據位置取得對應的作用域
|
|
67
|
+
*/
|
|
68
|
+
async getScopeAtPosition(position) {
|
|
69
|
+
// 找到包含該位置的最具體的作用域
|
|
70
|
+
let targetScope = null;
|
|
71
|
+
let bestDepth = -1;
|
|
72
|
+
for (const scope of this.currentScopes) {
|
|
73
|
+
if (isPositionInRange(position, scope.range)) {
|
|
74
|
+
const depth = this.getScopeDepth(scope);
|
|
75
|
+
if (depth > bestDepth) {
|
|
76
|
+
bestDepth = depth;
|
|
77
|
+
targetScope = scope;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return targetScope;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 檢查符號在特定作用域中是否可見
|
|
85
|
+
*/
|
|
86
|
+
async isSymbolVisible(symbolName, scope) {
|
|
87
|
+
// 檢查當前作用域
|
|
88
|
+
if (scope.symbols.some(s => s.name === symbolName)) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
// 檢查父作用域(向上遍歷)
|
|
92
|
+
let currentScope = scope.parent;
|
|
93
|
+
while (currentScope) {
|
|
94
|
+
if (currentScope.symbols.some(s => s.name === symbolName)) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
currentScope = currentScope.parent;
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 遞歸分析 AST 節點
|
|
103
|
+
*/
|
|
104
|
+
async analyzeNode(node, parentScope) {
|
|
105
|
+
let currentScope = parentScope;
|
|
106
|
+
// 函式宣告需要特殊處理:函式名加到父作用域,但參數和內容在新作用域
|
|
107
|
+
if (node.type === 'FunctionDeclaration') {
|
|
108
|
+
// 把函式名加到父作用域
|
|
109
|
+
const symbol = this.createSymbolFromNode(node);
|
|
110
|
+
if (symbol) {
|
|
111
|
+
parentScope.symbols.push(symbol);
|
|
112
|
+
this.addToSymbolTable(symbol);
|
|
113
|
+
}
|
|
114
|
+
// 建立函式作用域
|
|
115
|
+
currentScope = this.createScope(node, parentScope);
|
|
116
|
+
this.currentScopes.push(currentScope);
|
|
117
|
+
}
|
|
118
|
+
else if (this.shouldCreateScope(node)) {
|
|
119
|
+
// 其他類型的作用域
|
|
120
|
+
currentScope = this.createScope(node, parentScope);
|
|
121
|
+
this.currentScopes.push(currentScope);
|
|
122
|
+
}
|
|
123
|
+
else if (this.isSymbolDefinition(node)) {
|
|
124
|
+
// 一般符號定義
|
|
125
|
+
const symbol = this.createSymbolFromNode(node);
|
|
126
|
+
if (symbol) {
|
|
127
|
+
currentScope.symbols.push(symbol);
|
|
128
|
+
this.addToSymbolTable(symbol);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// 遞歸處理子節點
|
|
132
|
+
for (const child of node.children) {
|
|
133
|
+
await this.analyzeNode(child, currentScope);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* 檢查是否應該為節點建立新的作用域
|
|
138
|
+
*/
|
|
139
|
+
shouldCreateScope(node) {
|
|
140
|
+
const scopeTypes = [
|
|
141
|
+
'FunctionDeclaration',
|
|
142
|
+
'FunctionExpression',
|
|
143
|
+
'ArrowFunctionExpression',
|
|
144
|
+
'BlockStatement',
|
|
145
|
+
'ClassDeclaration'
|
|
146
|
+
];
|
|
147
|
+
return scopeTypes.includes(node.type);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* 為節點建立作用域
|
|
151
|
+
*/
|
|
152
|
+
createScope(node, parent) {
|
|
153
|
+
const scopeType = this.getScopeType(node.type);
|
|
154
|
+
const name = node.properties.name;
|
|
155
|
+
return {
|
|
156
|
+
type: scopeType,
|
|
157
|
+
name,
|
|
158
|
+
parent,
|
|
159
|
+
symbols: [],
|
|
160
|
+
range: node.range
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 取得作用域類型
|
|
165
|
+
*/
|
|
166
|
+
getScopeType(nodeType) {
|
|
167
|
+
const typeMap = {
|
|
168
|
+
'FunctionDeclaration': 'function',
|
|
169
|
+
'FunctionExpression': 'function',
|
|
170
|
+
'ArrowFunctionExpression': 'function',
|
|
171
|
+
'ClassDeclaration': 'class',
|
|
172
|
+
'BlockStatement': 'block'
|
|
173
|
+
};
|
|
174
|
+
return typeMap[nodeType] || 'block';
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* 檢查是否為符號定義
|
|
178
|
+
*/
|
|
179
|
+
isSymbolDefinition(node) {
|
|
180
|
+
const definitionTypes = [
|
|
181
|
+
'VariableDeclaration',
|
|
182
|
+
'FunctionDeclaration',
|
|
183
|
+
'ClassDeclaration',
|
|
184
|
+
'Parameter'
|
|
185
|
+
];
|
|
186
|
+
return definitionTypes.includes(node.type);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* 從 AST 節點建立符號
|
|
190
|
+
*/
|
|
191
|
+
createSymbolFromNode(node) {
|
|
192
|
+
const name = node.properties.name;
|
|
193
|
+
if (!name) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
const symbolType = this.getSymbolType(node.type);
|
|
197
|
+
const location = createLocation('/test/file.ts', node.range); // 暫時使用測試檔案路徑
|
|
198
|
+
return createSymbol(name, symbolType, location);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* 取得符號類型
|
|
202
|
+
*/
|
|
203
|
+
getSymbolType(nodeType) {
|
|
204
|
+
const typeMap = {
|
|
205
|
+
'VariableDeclaration': SymbolType.Variable,
|
|
206
|
+
'FunctionDeclaration': SymbolType.Function,
|
|
207
|
+
'ClassDeclaration': SymbolType.Class,
|
|
208
|
+
'Parameter': SymbolType.Variable
|
|
209
|
+
};
|
|
210
|
+
return typeMap[nodeType] || SymbolType.Variable;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* 添加符號到符號表
|
|
214
|
+
*/
|
|
215
|
+
addToSymbolTable(symbol) {
|
|
216
|
+
const existing = this.symbolTable.get(symbol.name) || [];
|
|
217
|
+
existing.push(symbol);
|
|
218
|
+
this.symbolTable.set(symbol.name, existing);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* 找到遮蔽指定符號的其他符號
|
|
222
|
+
*/
|
|
223
|
+
findShadowingSymbols(symbol, allScopes, symbolScope) {
|
|
224
|
+
const shadows = [];
|
|
225
|
+
for (const scope of allScopes) {
|
|
226
|
+
// 跳過符號所在的作用域
|
|
227
|
+
if (scope === symbolScope) {
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
// 檢查是否為子作用域(會遮蔽父作用域的符號)
|
|
231
|
+
if (this.isChildScope(scope, symbolScope)) {
|
|
232
|
+
const shadowingSymbol = scope.symbols.find(s => s.name === symbol.name);
|
|
233
|
+
if (shadowingSymbol) {
|
|
234
|
+
shadows.push({
|
|
235
|
+
symbol: shadowingSymbol,
|
|
236
|
+
scope
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return shadows;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* 檢查是否為子作用域
|
|
245
|
+
*/
|
|
246
|
+
isChildScope(child, parent) {
|
|
247
|
+
let currentParent = child.parent;
|
|
248
|
+
while (currentParent) {
|
|
249
|
+
if (currentParent === parent) {
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
currentParent = currentParent.parent;
|
|
253
|
+
}
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* 取得作用域深度
|
|
258
|
+
*/
|
|
259
|
+
getScopeDepth(scope) {
|
|
260
|
+
let depth = 0;
|
|
261
|
+
let current = scope.parent;
|
|
262
|
+
while (current) {
|
|
263
|
+
depth++;
|
|
264
|
+
current = current.parent;
|
|
265
|
+
}
|
|
266
|
+
return depth;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=scope-analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-analyzer.js","sourceRoot":"","sources":["../../../src/core/rename/scope-analyzer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAU,UAAU,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/E;;GAEG;AACH,MAAM,OAAO,aAAa;IAChB,aAAa,GAA0B,EAAE,CAAC;IAC1C,WAAW,GAAG,IAAI,GAAG,EAAoB,CAAC;IAElD;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,GAAQ;QAC1B,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAEzB,cAAc;QACd,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YACtB,YAAY;YACZ,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,UAAU;QACV,MAAM,WAAW,GAAwB;YACvC,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI;gBACvB,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;gBAC7B,GAAG,EAAE,E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;YACH,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,KAA0B,EAAE,MAA2B;QAC1E,IAAI,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC;QACjC,OAAO,aAAa,EAAE,CAAC;YACrB,IAAI,aAAa,KAAK,MAAM,EAAE,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC;YACD,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC;QACvC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,KAA0B;QAC9C,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,OAAO,OAAO,EAAE,CAAC;YACf,KAAK,EAAE,CAAC;YACR,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;QAC3B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 重新命名引擎相關型別定義
|
|
3
|
+
* 包含 RenameOptions、RenameResult、ValidationResult 等型別
|
|
4
|
+
*/
|
|
5
|
+
import { Location, Position, Range } from '../../shared/types/core.js';
|
|
6
|
+
import { Symbol } from '../../shared/types/symbol.js';
|
|
7
|
+
/**
|
|
8
|
+
* 重新命名選項
|
|
9
|
+
*/
|
|
10
|
+
export interface RenameOptions {
|
|
11
|
+
readonly symbol: Symbol;
|
|
12
|
+
readonly newName: string;
|
|
13
|
+
readonly filePaths: readonly string[];
|
|
14
|
+
readonly position?: Position;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 重新命名操作
|
|
18
|
+
*/
|
|
19
|
+
export interface RenameOperation {
|
|
20
|
+
readonly filePath: string;
|
|
21
|
+
readonly oldText: string;
|
|
22
|
+
readonly newText: string;
|
|
23
|
+
readonly range: Range;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 重新命名結果
|
|
27
|
+
*/
|
|
28
|
+
export interface RenameResult {
|
|
29
|
+
readonly success: boolean;
|
|
30
|
+
readonly operations: readonly RenameOperation[];
|
|
31
|
+
readonly affectedFiles: readonly string[];
|
|
32
|
+
readonly renameId: string;
|
|
33
|
+
readonly errors?: readonly string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 批次重新命名結果
|
|
37
|
+
*/
|
|
38
|
+
export interface BatchRenameResult {
|
|
39
|
+
readonly success: boolean;
|
|
40
|
+
readonly results: readonly RenameResult[];
|
|
41
|
+
readonly totalOperations: number;
|
|
42
|
+
readonly errors?: readonly string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 驗證結果
|
|
46
|
+
*/
|
|
47
|
+
export interface ValidationResult {
|
|
48
|
+
readonly isValid: boolean;
|
|
49
|
+
readonly conflicts: readonly ConflictInfo[];
|
|
50
|
+
readonly warnings?: readonly string[];
|
|
51
|
+
readonly errors?: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 衝突資訊
|
|
55
|
+
*/
|
|
56
|
+
export interface ConflictInfo {
|
|
57
|
+
readonly type: ConflictType;
|
|
58
|
+
readonly message: string;
|
|
59
|
+
readonly location: Location;
|
|
60
|
+
readonly existingSymbol?: Symbol;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 衝突類型
|
|
64
|
+
*/
|
|
65
|
+
export declare enum ConflictType {
|
|
66
|
+
NameCollision = "name_collision",// 名稱衝突
|
|
67
|
+
ScopeConflict = "scope_conflict",// 作用域衝突
|
|
68
|
+
ReservedKeyword = "reserved_keyword",// 保留字衝突
|
|
69
|
+
InvalidIdentifier = "invalid_identifier"
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 重新命名預覽
|
|
73
|
+
*/
|
|
74
|
+
export interface RenamePreview {
|
|
75
|
+
readonly operations: readonly RenameOperation[];
|
|
76
|
+
readonly affectedFiles: readonly string[];
|
|
77
|
+
readonly conflicts: readonly ConflictInfo[];
|
|
78
|
+
readonly summary: RenameSummary;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 重新命名摘要
|
|
82
|
+
*/
|
|
83
|
+
export interface RenameSummary {
|
|
84
|
+
readonly totalReferences: number;
|
|
85
|
+
readonly totalFiles: number;
|
|
86
|
+
readonly conflictCount: number;
|
|
87
|
+
readonly estimatedTime: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 建立 RenameOptions 的工廠函式
|
|
91
|
+
*/
|
|
92
|
+
export declare function createRenameOptions(symbol: Symbol, newName: string, filePaths: string[], position?: Position): RenameOptions;
|
|
93
|
+
/**
|
|
94
|
+
* 建立 RenameOperation 的工廠函式
|
|
95
|
+
*/
|
|
96
|
+
export declare function createRenameOperation(filePath: string, oldText: string, newText: string, range: Range): RenameOperation;
|
|
97
|
+
/**
|
|
98
|
+
* 建立 ConflictInfo 的工廠函式
|
|
99
|
+
*/
|
|
100
|
+
export declare function createConflictInfo(type: ConflictType, message: string, location: Location, existingSymbol?: Symbol): ConflictInfo;
|
|
101
|
+
/**
|
|
102
|
+
* 作用域分析結果
|
|
103
|
+
*/
|
|
104
|
+
export interface ScopeAnalysisResult {
|
|
105
|
+
readonly type: string;
|
|
106
|
+
readonly name?: string;
|
|
107
|
+
readonly parent?: ScopeAnalysisResult;
|
|
108
|
+
readonly symbols: readonly Symbol[];
|
|
109
|
+
readonly range: Range;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 變數遮蔽資訊
|
|
113
|
+
*/
|
|
114
|
+
export interface ShadowedVariable {
|
|
115
|
+
readonly name: string;
|
|
116
|
+
readonly originalSymbol: Symbol;
|
|
117
|
+
readonly shadowedBy: readonly ShadowInfo[];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 遮蔽資訊
|
|
121
|
+
*/
|
|
122
|
+
export interface ShadowInfo {
|
|
123
|
+
readonly symbol: Symbol;
|
|
124
|
+
readonly scope: ScopeAnalysisResult;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* 引用更新結果
|
|
128
|
+
*/
|
|
129
|
+
export interface UpdateResult {
|
|
130
|
+
readonly success: boolean;
|
|
131
|
+
readonly updatedFiles: readonly UpdatedFile[];
|
|
132
|
+
readonly errors?: readonly string[];
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* 更新後的檔案
|
|
136
|
+
*/
|
|
137
|
+
export interface UpdatedFile {
|
|
138
|
+
readonly filePath: string;
|
|
139
|
+
readonly originalContent: string;
|
|
140
|
+
readonly newContent: string;
|
|
141
|
+
readonly changes: readonly TextChange[];
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 文字變更
|
|
145
|
+
*/
|
|
146
|
+
export interface TextChange {
|
|
147
|
+
readonly range: Range;
|
|
148
|
+
readonly oldText: string;
|
|
149
|
+
readonly newText: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 符號引用
|
|
153
|
+
*/
|
|
154
|
+
export interface SymbolReference {
|
|
155
|
+
readonly symbolName: string;
|
|
156
|
+
readonly range: Range;
|
|
157
|
+
readonly type: 'definition' | 'usage' | 'comment';
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* RenameOptions 型別守衛
|
|
161
|
+
*/
|
|
162
|
+
export declare function isRenameOptions(value: unknown): value is RenameOptions;
|
|
163
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/rename/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,MAAM,EAAS,MAAM,8BAA8B,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ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,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,GAAG,SAAS,CAAC;CACnD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CActE"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 重新命名引擎相關型別定義
|
|
3
|
+
* 包含 RenameOptions、RenameResult、ValidationResult 等型別
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 衝突類型
|
|
7
|
+
*/
|
|
8
|
+
export var ConflictType;
|
|
9
|
+
(function (ConflictType) {
|
|
10
|
+
ConflictType["NameCollision"] = "name_collision";
|
|
11
|
+
ConflictType["ScopeConflict"] = "scope_conflict";
|
|
12
|
+
ConflictType["ReservedKeyword"] = "reserved_keyword";
|
|
13
|
+
ConflictType["InvalidIdentifier"] = "invalid_identifier"; // 無效識別符
|
|
14
|
+
})(ConflictType || (ConflictType = {}));
|
|
15
|
+
/**
|
|
16
|
+
* 建立 RenameOptions 的工廠函式
|
|
17
|
+
*/
|
|
18
|
+
export function createRenameOptions(symbol, newName, filePaths, position) {
|
|
19
|
+
if (!newName.trim()) {
|
|
20
|
+
throw new Error('新名稱不能為空');
|
|
21
|
+
}
|
|
22
|
+
if (filePaths.length === 0) {
|
|
23
|
+
throw new Error('必須指定至少一個檔案路徑');
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
symbol,
|
|
27
|
+
newName: newName.trim(),
|
|
28
|
+
filePaths,
|
|
29
|
+
position
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 建立 RenameOperation 的工廠函式
|
|
34
|
+
*/
|
|
35
|
+
export function createRenameOperation(filePath, oldText, newText, range) {
|
|
36
|
+
if (!filePath.trim()) {
|
|
37
|
+
throw new Error('檔案路徑不能為空');
|
|
38
|
+
}
|
|
39
|
+
if (!oldText.trim()) {
|
|
40
|
+
throw new Error('舊文字不能為空');
|
|
41
|
+
}
|
|
42
|
+
if (!newText.trim()) {
|
|
43
|
+
throw new Error('新文字不能為空');
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
filePath,
|
|
47
|
+
oldText,
|
|
48
|
+
newText,
|
|
49
|
+
range
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 建立 ConflictInfo 的工廠函式
|
|
54
|
+
*/
|
|
55
|
+
export function createConflictInfo(type, message, location, existingSymbol) {
|
|
56
|
+
if (!message.trim()) {
|
|
57
|
+
throw new Error('衝突訊息不能為空');
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
type,
|
|
61
|
+
message,
|
|
62
|
+
location,
|
|
63
|
+
existingSymbol
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* RenameOptions 型別守衛
|
|
68
|
+
*/
|
|
69
|
+
export function isRenameOptions(value) {
|
|
70
|
+
if (!value || typeof value !== 'object') {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const obj = value;
|
|
74
|
+
return !!(obj.symbol && typeof obj.symbol === 'object' &&
|
|
75
|
+
typeof obj.newName === 'string' &&
|
|
76
|
+
obj.newName.trim().length > 0 &&
|
|
77
|
+
Array.isArray(obj.filePaths) &&
|
|
78
|
+
obj.filePaths.length > 0);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/rename/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkEH;;GAEG;AACH,MAAM,CAAN,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AE,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,IAAI;QACJ,OAAO;QACP,QAAQ;QACR,cAAc;KACf,CAAC;AACJ,CAAC;AAmED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,GAAG,GAAG,KAAgC,CAAC;IAE7C,OAAO,CAAC,CAAC,CACP,GAAG,CAAC,MAAM,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ;QAC5C,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ;QAC/B,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAC7B,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QAC5B,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CACzB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文字搜尋引擎實作
|
|
3
|
+
* 提供高效的文字搜尋功能,支援正則表達式、模糊匹配等
|
|
4
|
+
*/
|
|
5
|
+
import type { TextQuery, SearchResult } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* 文字搜尋引擎
|
|
8
|
+
*/
|
|
9
|
+
export declare class TextSearchEngine {
|
|
10
|
+
private readonly defaultOptions;
|
|
11
|
+
/**
|
|
12
|
+
* 執行文字搜尋
|
|
13
|
+
*/
|
|
14
|
+
search(query: TextQuery): Promise<SearchResult>;
|
|
15
|
+
/**
|
|
16
|
+
* 在單個檔案中搜尋
|
|
17
|
+
*/
|
|
18
|
+
private searchInFile;
|
|
19
|
+
/**
|
|
20
|
+
* 建立搜尋正則表達式
|
|
21
|
+
*/
|
|
22
|
+
private buildSearchRegex;
|
|
23
|
+
/**
|
|
24
|
+
* 建立匹配上下文
|
|
25
|
+
*/
|
|
26
|
+
private buildContext;
|
|
27
|
+
/**
|
|
28
|
+
* 尋找包圍的函式名稱
|
|
29
|
+
*/
|
|
30
|
+
private findEnclosingFunction;
|
|
31
|
+
/**
|
|
32
|
+
* 尋找包圍的類別名稱
|
|
33
|
+
*/
|
|
34
|
+
private findEnclosingClass;
|
|
35
|
+
/**
|
|
36
|
+
* 計算字符偏移量
|
|
37
|
+
*/
|
|
38
|
+
private calculateOffset;
|
|
39
|
+
/**
|
|
40
|
+
* 計算匹配分數
|
|
41
|
+
*/
|
|
42
|
+
private calculateScore;
|
|
43
|
+
/**
|
|
44
|
+
* 排序匹配結果
|
|
45
|
+
*/
|
|
46
|
+
private sortMatches;
|
|
47
|
+
/**
|
|
48
|
+
* 獲取要搜尋的檔案列表
|
|
49
|
+
*/
|
|
50
|
+
private getSearchFiles;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=text-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-engine.d.ts","sourceRoot":"","sources":["../../../../src/core/search/engines/text-engine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EACV,SAAS,EAET,YAAY,EAIb,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAe7B;IAEF;;OAEG;IACG,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;IAgErD;;OAEG;YACW,YAAY;IAuE1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA4CxB;;OAEG;IACH,OAAO,CAAC,YAAY;IA0BpB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAc7B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAc1B;;OAEG;IACH,OAAO,CAAC,eAAe;IAcvB;;OAEG;IACH,OAAO,CAAC,cAAc;IAyBtB;;OAEG;IACH,OAAO,CAAC,WAAW;IAiBnB;;OAEG;YACW,cAAc;CAmG7B"}
|