diff options
author | RĂ¼diger Herrmann <[email protected]> | 2020-08-24 15:37:45 +0100 |
---|---|---|
committer | RĂ¼diger Herrmann <[email protected]> | 2020-10-10 12:46:10 +0100 |
commit | e90931a2047e6e38f173e2e2f2a24ad648e92e9d (patch) | |
tree | 0ef92bcd580446c4ea44902f0f959d547a698943 /crates/ide/src/lib.rs | |
parent | 05261f5aeb1dcf01c5dfcf3e01826e57b1249ca9 (diff) |
Show reason for failed rename refactoring
Return an error with a meaningful message for requests to
`textDocument/rename` if the operation cannot be performed.
Pass errors raised by rename handling code to the LSP runtime.
As a consequence, the VS Code client shows and logs the request
as if a server-side programming error occured.
Resolves https://github.com/rust-analyzer/rust-analyzer/issues/3981
Diffstat (limited to 'crates/ide/src/lib.rs')
-rw-r--r-- | crates/ide/src/lib.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index 57f3581b6..d54c06b14 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs | |||
@@ -77,7 +77,9 @@ pub use crate::{ | |||
77 | hover::{HoverAction, HoverConfig, HoverGotoTypeData, HoverResult}, | 77 | hover::{HoverAction, HoverConfig, HoverGotoTypeData, HoverResult}, |
78 | inlay_hints::{InlayHint, InlayHintsConfig, InlayKind}, | 78 | inlay_hints::{InlayHint, InlayHintsConfig, InlayKind}, |
79 | markup::Markup, | 79 | markup::Markup, |
80 | references::{Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult}, | 80 | references::{ |
81 | Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult, RenameError, | ||
82 | }, | ||
81 | runnables::{Runnable, RunnableKind, TestId}, | 83 | runnables::{Runnable, RunnableKind, TestId}, |
82 | syntax_highlighting::{ | 84 | syntax_highlighting::{ |
83 | Highlight, HighlightModifier, HighlightModifiers, HighlightTag, HighlightedRange, | 85 | Highlight, HighlightModifier, HighlightModifiers, HighlightTag, HighlightedRange, |
@@ -490,7 +492,7 @@ impl Analysis { | |||
490 | &self, | 492 | &self, |
491 | position: FilePosition, | 493 | position: FilePosition, |
492 | new_name: &str, | 494 | new_name: &str, |
493 | ) -> Cancelable<Option<RangeInfo<SourceChange>>> { | 495 | ) -> Cancelable<Result<RangeInfo<SourceChange>, RenameError>> { |
494 | self.with_db(|db| references::rename(db, position, new_name)) | 496 | self.with_db(|db| references::rename(db, position, new_name)) |
495 | } | 497 | } |
496 | 498 | ||