rename_symbol

[refactoring]

Semantically renames a symbol across the solution/project.

Try this tool in Playground.

Parameters

NameTypeRequiredDescription
symbolNamestringYesSymbol name to rename (simple or fully qualified).
newNamestringYesNew name for the symbol.
projectNamestringNoOptional project name to limit symbol search.
applyChangesbooleanNoIf true (default), applies changes to disk. If false, returns a preview diff.
timeout_msnumberNoTimeout in milliseconds (5 minutes). Use 0 to disable. Default is 300000.

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 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 Notes

Returns a unified diff of the change set