move_member

[refactoring]

Moves a member (method/property/field) from one type to another and updates references.

Try this tool in Playground.

Parameters

NameTypeRequiredDescription
memberNamestringYesMember name to move.
sourceTypeNamestringYesSource type name.
targetTypeNamestringYesTarget type name.
projectNamestringNoOptional project name to limit search.
applyChangesbooleanNoIf true (default), applies changes to disk. If false, returns a preview diff.
maxReferenceUpdatesnumberNoMaximum reference updates when rewriting call sites. Use 0 to disable. Default is 2000.
timeout_msnumberNoTimeout in milliseconds (5 minutes). Use 0 to disable. Default is 300000.

Examples

Move a method to another class

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "move_member",
    "arguments": {
      "memberName": "ProcessData",
      "sourceTypeName": "OldClass",
      "targetTypeName": "NewClass"
    }
  }
}
Response
{
  "success": true,
  "data": {
    "symbolName": "MyMethod",
    "symbolKind": "Method",
    "sourceLocation": "SourceClass",
    "targetLocation": "TargetClass",
    "filesChanged": 2,
    "filesCreated": 0,
    "applied": true,
    "unifiedDiff": "..."
  },
  "error": null
}

Response Notes

Returns a unified diff of the change set