lean4-htt/tests/lean/interactive/rename.lean
Mario Carneiro b97b0ad2aa
feat: rename request handler (#2462)
This implements a request handler for the `textDocument/rename` LSP
request, enabling renames via F2. It handles both local renames (e.g.
`let x := 1; x` to `let y := 1; y`) as well as global renames
(definitions).

Unfortunately it does not work for "orphan" files outside a project, as
it uses ilean data for the current file and this does not seem to be
saved for orphan files. As a result, the test file does not work,
although one can manually test the implementation against a project such
as mathlib. (This issue already exists for the "references" request,
e.g. ctrl click on the first `x` in `let x := 1; x` takes you to the
second one only if you are not in an orphan file.)

* Fixes leanprover-community/mathlib4#7124
2023-11-21 13:10:52 +01:00

39 lines
700 B
Text

-- Note: these tests do not work in the current test suite, you have
-- to run them inside a project
variable (a : Nat)
def foo :=
let a := 1; a
--^ textDocument/prepareRename
--^ textDocument/rename: {"newName": "blue"}
structure Foo where
--^ textDocument/rename: {"newName": "Bar"}
a : Nat
deriving Repr
#eval Foo.mk 1
namespace B
structure Foo where
a : Nat
b : Nat
def bar (x y : Nat) : Foo :=
⟨x, y⟩
--^ textDocument/rename: {"newName": "z"}
end B
namespace Bar
structure Foo where
--^ textDocument/rename: {"newName": "X"}
a : Nat
def foobar (f : Foo) : Foo := f
end Bar
def foobar (f : Bar.Foo) : Bar.Foo := f