Closed Asdas91 closed 2 years ago
Thanks for submitting this bug! I will look into it, but could you also let me know what LSP you're using?
Looking a bit more at the code and the error, could you add a print(resp)
immediately after the if ... then
in which the error occurs? (Between line 382 and 383) just so I can see what the LSP server responded with
Thank you for answering! I am using jdtls server.
When I used just the print function it only printed a hash or something so I used this nice tool https://github.com/kikito/inspect.lua.
I think the problem might be the third item in documentChanges
which is about renaming the file. That one has a different structure and doesn't have the "textDocument" key.
resp:
{
changes = {
<metatable> = {
__tostring = <function 1>
}
},
documentChanges = { {
edits = { {
newText = 'Apps {\n public String getGreetings() {\n return "Hello World!";\n }\n\n public static void main(String[] args) {\n System.out.println(new Apps',
range = {
end = {
character = 34,
line = 11
},
start = {
character = 13,
line = 5
}
}
} },
textDocument = {
uri = "file:///homeFolder/Sources/gradle-project/app/src/main/java/renamer/tester/App.java"
}
}, {
edits = { {
newText = "Apps classUnderTest = new Apps",
range = {
end = {
character = 36,
line = 10
},
start = {
character = 8,
line = 10
}
}
} },
textDocument = {
uri = "file:///homeFolder/Sources/gradle-project/app/src/test/java/renamer/tester/AppTest.java"
}
}, {
kind = "rename",
newUri = "file:///homeFolder/Sources/gradle-project/app/src/main/java/renamer/tester/Apps.java",
oldUri = "file:///homeFolder/Sources/gradle-project/app/src/main/java/renamer/tester/App.java"
} }
}
Thanks a lot for providing the LSP response, sorry I forgot to mention you should inspect it to view it properly (you can also use the built-in vim.inspect(...)
function). That seems to be the issue. This issue seems like a tough one :thinking: I need to look at the LSP docs and figure out how to properly map it.
I will work on a fix, but since it does not seem like an easy one atm, I cannot estimate an accurate ETA for it, so sorry for this. But I can assure you a fix will come ASAP. I am also sorry that I am not sure what the most efficient workaround would be. I guess, rename the file first, then the items inside it, but I am not sure how productive it would be. Will keep you updated.
I see. That's a useful function. I am quite new to Lua so I didn't know about it.
Thank you for looking into it. I like the plugin it enhances the rename functionality really nicely.
the latest develop should have a working fix for your issue, which properly sets qflist
as well (visible with :copen
)
Describe the bug
When I rename a Java public class using renamer error appears and nothing is renamed. It's supposed to rename the class name, filename and references to the class in another files.
The error:
To reproduce
Steps to reproduce the behavior:
Expected behavior
The class gets renamed, the file gets renamed and references to the class also get renamed
Environment
Screenshots
Additional context
I can supply a dummy java project to reproduce this.