Closed dylon closed 14 hours ago
What should be the output --- should it modify the file in-place, or rather return all locations to rename and VSCode does the actual renaming?
Irrespective of the answer we get above, we'll need to identify all the locations to rename, so naive design goes as
line
and column
information, using --lookup-name
we get the name of symbol
This solves one part of collecting locations. Now if we wish to replace it in-place:
ASR::symbol_t*
visit_Var
to check if symbol name matches with old symbol, if yes replace it with new oneThis way we can replace it.
What should be the output --- should it modify the file in-place, or rather return all locations to rename and VSCode does the actual renaming?
Per this issue, the specification, and the VSCode rename event handler, LSP and VSCode expect the server to respond with a list of ranges (starting and ending coordinates, where each coordinate consists of a line and column) consisting of every occurrence of the symbol to rename, including the text to replace each occurrence with; they do not expect the server to edit the document, probably so the changes can be undone by the client. Each instance should adhere to the TextEdit specification.
For our LSP integration, we will need a command-line option to contextually rename symbols. It would best if we could rename them across a project rather than just the current file, but we must be able to rename them within at least the current file.
Support for this will require indexing a symbol's locations within the current file and possibly within its project. We may then use that same index for LSP's various symbol reference functionalities.
Requirements:
--rename-symbol
or the like.--line
:= line on which the symbol to rename appears (accepts int param; must be within the respective range)--column
:= column on which the symbol to rename appears (accepts int param; must be within the respective range)--new-name
(or something like that) := what to replace the symbol with (accepts string param; must be valid identifier)