LanguageServer.jl
LanguageServer.jl copied to clipboard
Rename broken for macros
Consider the following file:
module LSRenameMacros
macro add_2(x)
return :($x + 2)
end
add_2_repeatedly(start, n) =
for _=1:n
start = @add_2 start
end
g(x) = @add_2(x)
end # module LSRenameMacros
I'm using LanguageServer.jl 4.5.1 with eglot. Please excuse the s-expression formatting of the JSON RPC requests/responses. So if I hover over @add_2
and attempt to rename to @test
, I end up with the following file and see the following request/response pair:
module LSRenameMacros
macro @test@test(x)
return :($x + 2)
end
add_2_repeatedly(start, n) =
for _=1:n
start = @test start
end
g(x) = @test(x)
end # module LSRenameMacros
[client-request] (id:189) Fri Mar 15 14:11:47 2024:
(:jsonrpc "2.0" :id 189 :method "textDocument/rename" :params
(:textDocument
(:uri "file:///home/adam/repos/LSRenameMacros/src/LSRenameMacros.jl")
:position
(:line 11 :character 12)
:newName "@test"))
[server-reply] (id:189) Fri Mar 15 14:11:48 2024:
(:id 189 :jsonrpc "2.0" :result
(:documentChanges
[(:textDocument
(:uri "file:///home/adam/repos/LSRenameMacros/src/LSRenameMacros.jl" :version 169)
:edits
[(:range
(:start
(:line 2 :character 6)
:end
(:line 2 :character 11))
:newText "@test")
(:range
(:start
(:line 2 :character 6)
:end
(:line 2 :character 11))
:newText "@test")
(:range
(:start
(:line 8 :character 16)
:end
(:line 8 :character 22))
:newText "@test")
(:range
(:start
(:line 11 :character 7)
:end
(:line 11 :character 13))
:newText "@test")])]))
As you can see, the macro invocations are replaced correctly, but the macro definition has duplicate replacements of add_2
with @test
. So probably two separate issues? @
sign should be stripped and need to only send the edit for the macro definition once.
I thought perhaps that the issue was that the LanguageServer expected you to send the new name as test
instead of @test
, but that didn't work either. Does renaming of macros work in the vs-code extension?