How did you learn how to add variable renaming functionality? #16
-
I saw commit 1b556ef and some of the implementation for adding variable renaming functionality. Where did you learn how to do that? Are there any guides you recommend? The Language Server Protocol's specification has a section called "Rename Request" with some details on what the request should look like, but no examples of what that looks like in action, in terms of what code in |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I figured it out on my own. And I'm unaware of any guide that covers such functionality. Specification just tells you what you need to create in terms of request/response and related interfaces. The implementation is up to you. It's not that difficult, but might get lengthy depending on your language. You basically need to build a graph of dependencies or who imports who. Then you locate the correct scope within each of you dependent documents. And finally you generate a list of edits. You need some knowledge of algorithms to do all these steps correctly. At least BFS and DFS graph traversal. Note that if your language supports cyclical dependencies it's up to you to resolve them. You also need to test you solution extensively because there are too many edge cases and variations. Having no tests most probably will end up with situation where fixing one thing breaks the other. |
Beta Was this translation helpful? Give feedback.
I figured it out on my own. And I'm unaware of any guide that covers such functionality.
Specification just tells you what you need to create in terms of request/response and related interfaces. The implementation is up to you.
It's not that difficult, but might get lengthy depending on your language. You basically need to build a graph of dependencies or who imports who. Then you locate the correct scope within each of you dependent documents. And finally you generate a list of edits.
You need some knowledge of algorithms to do all these steps correctly. At least BFS and DFS graph traversal. Note that if your language supports cyclical dependencies it's up to you to resolve them. You als…