Rename a symbol safely across the whole project
何時使用: You want to rename a symbol but grep-and-replace would miss string references or dynamic calls.
前置條件
- MCP Server plugin installed in the IDE — plugins.jetbrains.com/plugin/26071-mcp-server — or built-in if on 2025.2+
- Project opened and indexed in the IDE — Open the project; wait for indexing to complete (status bar)
步驟
-
Find the symbolFind the definition and all usages of
getCurrentUserin the project. Include test files.✓ 已複製→ IDE-accurate usage list with file:line -
Dry-run the renameShow me what renaming to
getAuthenticatedUserwould change. Flag any string literals or reflection-based calls I'll need to fix manually.✓ 已複製→ Preview diff + manual-fix list -
Apply the refactorApply the rename. Then run the affected tests.✓ 已複製→ Refactor done, tests green
結果: A safe rename with IDE-level accuracy, covered by the IDE's existing refactoring engine.
注意事項
- Reflection-based or string-built references aren't caught — After refactor, grep for the old name as a string — the IDE warns but doesn't auto-fix these
- IDE not fully indexed, results are partial — Wait for the progress bar to clear before running; ask the IDE for index status first