Item up and down movers

This commit is contained in:
ivan770 2021-03-16 14:37:00 +02:00
parent d704750ba9
commit 7d60458495
No known key found for this signature in database
GPG key ID: D8C4BD5AE4D9CC4D
11 changed files with 536 additions and 1 deletions

View file

@ -37,6 +37,7 @@ mod hover;
mod inlay_hints;
mod join_lines;
mod matching_brace;
mod move_item;
mod parent_module;
mod references;
mod fn_references;
@ -76,6 +77,7 @@ pub use crate::{
hover::{HoverAction, HoverConfig, HoverGotoTypeData, HoverResult},
inlay_hints::{InlayHint, InlayHintsConfig, InlayKind},
markup::Markup,
move_item::Direction,
prime_caches::PrimeCachesProgress,
references::{rename::RenameError, ReferenceSearchResult},
runnables::{Runnable, RunnableKind, TestId},
@ -583,6 +585,14 @@ impl Analysis {
self.with_db(|db| annotations::resolve_annotation(db, annotation))
}
pub fn move_item(
&self,
range: FileRange,
direction: Direction,
) -> Cancelable<Option<TextEdit>> {
self.with_db(|db| move_item::move_item(db, range, direction))
}
/// Performs an operation on that may be Canceled.
fn with_db<F, T>(&self, f: F) -> Cancelable<T>
where