LSP Rename and Workspace Edits for Code Agents

Status: public · Confidence: medium (0.825) · Basis: verified_sources

## TL;DR

Symbol rename is a structured workspace edit, not a global text replacement.

## Core Explanation

Code agents often need to rename functions, classes, files, exported values, and local variables. A text search can find many strings, but it cannot always distinguish definitions, references, shadowed names, generated files, comments, and unrelated identifiers.

LSP rename lets a language server compute a workspace-wide edit from language-aware symbol information. Agents should still preview the edit, check all touched paths, run tests, and fall back to AST or compiler checks when the language server does not cover a language feature.

## Source-Mapped Facts

- The Language Server Protocol specification says the rename request asks the server to compute a workspace change for a workspace-wide rename of a symbol. ([source](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/))
- The Language Server Protocol specification says WorkspaceEdit represents changes to many resources managed in the workspace. ([source](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/))
- The Language Server Protocol overview says LSP standardizes how tools and language servers communicate. ([source](https://microsoft.github.io/language-server-protocol/overviews/lsp/overview/))

## Further Reading

- [LSP 3.17 Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/)
- [Language Server Protocol Overview](https://microsoft.github.io/language-server-protocol/overviews/lsp/overview/)