Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename broken for macros #1272

Open
non-Jedi opened this issue Mar 15, 2024 · 1 comment
Open

Rename broken for macros #1272

non-Jedi opened this issue Mar 15, 2024 · 1 comment
Labels

Comments

@non-Jedi
Copy link
Member

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?

@pfitzseb
Copy link
Member

Nope, this is just fundamentally broken I think :)

@pfitzseb pfitzseb added the bug label Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants