Implement LSP didSave notify and rename request [3.x] #48616
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a companion to #48615, but for 3.x. This implements the
textDocument/rename
request for the language server to find symbols such as function names, variables, properties, signals and otherwise, and rename them wherever they match the original symbol.As a companion, this also adds the
textDocument/didSave
notification. This is because, by the time the text changes are received by the client, none of the variables have been renamed internally, which results in error. But saving the scripts SHOULD re-trigger a parsing of all changed scripts and thus find the new property names. However...Known IssueThe 3.x parser is not as good as 4.0's, and so does not re-parse from the parent class variable names, even if they have changed. It requires the script to get validated, which does not happen even with a change in the filesystem.WorkaroundOpen the parent class' script in Godot editor, which triggers a validation. Then going back to the LSP client clears the errors, after a save.This seems to have been fixed by the most recent change, where we also reload the script resource's state for #50510.