-
Notifications
You must be signed in to change notification settings - Fork 57
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
Add rename provider #230
Add rename provider #230
Conversation
This looks pretty interesting. Looking. |
@amiralies I tried on |
@@ -383,11 +385,49 @@ function onMessage(msg: m.Message) { | |||
// error: code and message set in case an exception happens during the definition request. | |||
}; | |||
send(definitionResponse); | |||
} else if (msg.method === p.RenameRequest.method) { | |||
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rename | |||
let params = msg.params as p.RenameParams; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bit of code duplication with the rename command.
Maybe it makes sense to move out functionality that could lead to errors in future. E.g. definitely the way the references
command is called, which parameters, etc. So that a future edit does not change only one place out of two, by mistake.
server/src/server.ts
Outdated
} else if (msg.method === p.ReferencesRequest.method) { | ||
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references | ||
let params = msg.params as p.ReferenceParams; | ||
let filePath = fileURLToPath(params.textDocument.uri); | ||
let result: Location | null = utils.runAnalysisAfterSanityCheck( | ||
let result: Location[] | null = utils.runAnalysisAfterSanityCheck( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we had a few of these.
See this alternative way which I'm going to merge now:
#232
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged --- perhaps rebase on master instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if the types on #232 are the correct types.
I've also took look at protocol types in ts and couldn't find correct types.
I think we should rely on manual types based on protocl docs. for example in the docs the response type for references request is Location[] | null
but there's not type in ts spec for that.
I couldn't reproduce this, tested on vscode, nvim with coc and nvim with built in lsp recording.mp4Note that i close files before renaming. |
aadc95f
to
bd06877
Compare
Would you try opening the editor from scratch. Open a single file, then do rename? |
Sure, It works on my desktop. recording.mp4 |
Actually, it works. Sorry for the mix-up. |
This PR adds lsp rename provider based on references ruquest on analysis cli.
https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rename
also fixed a small type error in references provider