mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 17:58:16 +00:00
Added more movable lists
This commit is contained in:
parent
0a2d221d47
commit
2794cc7b00
1 changed files with 95 additions and 1 deletions
|
@ -43,6 +43,10 @@ fn find_ancestors(item: SyntaxElement, direction: Direction, range: TextRange) -
|
|||
|
||||
let movable = [
|
||||
SyntaxKind::ARG_LIST,
|
||||
SyntaxKind::GENERIC_PARAM_LIST,
|
||||
SyntaxKind::GENERIC_ARG_LIST,
|
||||
SyntaxKind::VARIANT_LIST,
|
||||
SyntaxKind::TYPE_BOUND_LIST,
|
||||
SyntaxKind::MATCH_ARM,
|
||||
SyntaxKind::PARAM,
|
||||
SyntaxKind::LET_STMT,
|
||||
|
@ -79,6 +83,10 @@ fn move_in_direction(
|
|||
match_ast! {
|
||||
match node {
|
||||
ast::ArgList(it) => swap_sibling_in_list(it.args(), range, direction),
|
||||
ast::GenericParamList(it) => swap_sibling_in_list(it.generic_params(), range, direction),
|
||||
ast::GenericArgList(it) => swap_sibling_in_list(it.generic_args(), range, direction),
|
||||
ast::VariantList(it) => swap_sibling_in_list(it.variants(), range, direction),
|
||||
ast::TypeBoundList(it) => swap_sibling_in_list(it.bounds(), range, direction),
|
||||
_ => Some(replace_nodes(node, &match direction {
|
||||
Direction::Up => node.prev_sibling(),
|
||||
Direction::Down => node.next_sibling(),
|
||||
|
@ -302,7 +310,7 @@ struct Yay;
|
|||
|
||||
trait Wow {}
|
||||
|
||||
impl Wow for Yay {}$0$0
|
||||
impl Wow for Yay $0$0{}
|
||||
"#,
|
||||
expect![[r#"
|
||||
struct Yay;
|
||||
|
@ -441,6 +449,92 @@ fn main() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_moves_generic_param_up() {
|
||||
check(
|
||||
r#"
|
||||
struct Test<A, B$0$0>(A, B);
|
||||
|
||||
fn main() {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
struct Test<B, A>(A, B);
|
||||
|
||||
fn main() {}
|
||||
"#]],
|
||||
Direction::Up,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_moves_generic_arg_up() {
|
||||
check(
|
||||
r#"
|
||||
struct Test<A, B>(A, B);
|
||||
|
||||
fn main() {
|
||||
let t = Test::<i32, &str$0$0>(123, "yay");
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
struct Test<A, B>(A, B);
|
||||
|
||||
fn main() {
|
||||
let t = Test::<&str, i32>(123, "yay");
|
||||
}
|
||||
"#]],
|
||||
Direction::Up,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_moves_variant_up() {
|
||||
check(
|
||||
r#"
|
||||
enum Hello {
|
||||
One,
|
||||
Two$0$0
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
enum Hello {
|
||||
Two,
|
||||
One
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
"#]],
|
||||
Direction::Up,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_moves_type_bound_up() {
|
||||
check(
|
||||
r#"
|
||||
trait One {}
|
||||
|
||||
trait Two {}
|
||||
|
||||
fn test<T: One + Two$0$0>(t: T) {}
|
||||
|
||||
fn main() {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
trait One {}
|
||||
|
||||
trait Two {}
|
||||
|
||||
fn test<T: Two + One>(t: T) {}
|
||||
|
||||
fn main() {}
|
||||
"#]],
|
||||
Direction::Up,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_prioritizes_trait_items() {
|
||||
check(
|
||||
|
|
Loading…
Reference in a new issue