rename_symbol

[refactoring]

Renames a symbol throughout the solution with semantic awareness. Unlike grep-based renaming, this correctly distinguishes between different symbols with the same name.

Parameters

NameTypeRequiredDescription
symbolNamestringYesName of the symbol to rename (simple or fully qualified).
newNamestringYesThe new name for the symbol.
projectNamestringNoOptional project name to limit the search scope.
applyChangesbooleanNoIf true (default), applies changes. If false, returns preview only.

Examples

Rename a class

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "rename_symbol",
    "arguments": {
      "symbolName": "OldClassName",
      "newName": "NewClassName"
    }
  }
}
Response
{
  "success": true,
  "data": {
    "symbolName": "OldClassName",
    "newName": "NewClassName",
    "symbolKind": "Class",
    "filesChanged": 5,
    "locationsChanged": 12,
    "applied": true,
    "unifiedDiff": "..."
  },
  "error": null
}

Preview rename without applying

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "rename_symbol",
    "arguments": {
      "symbolName": "OldName",
      "newName": "NewName",
      "applyChanges": false
    }
  }
}
Response
{
  "success": true,
  "data": {
    "symbolName": "OldClassName",
    "newName": "NewClassName",
    "symbolKind": "Class",
    "filesChanged": 5,
    "locationsChanged": 12,
    "applied": true,
    "unifiedDiff": "..."
  },
  "error": null
}

Response

Returns files changed, locations modified, and unified diff

Go to Playground to test this tool interactively.