diff options
-rw-r--r-- | Cargo.lock | 11 | ||||
-rw-r--r-- | crates/ra_assists/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/assist_ctx.rs | 2 | ||||
-rw-r--r-- | crates/ra_assists/src/replace_if_let_with_match.rs | 2 | ||||
-rw-r--r-- | crates/ra_fmt/Cargo.toml | 11 | ||||
-rw-r--r-- | crates/ra_fmt/src/lib.rs (renamed from crates/ra_ide_api_light/src/formatting.rs) | 4 | ||||
-rw-r--r-- | crates/ra_ide_api_light/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_ide_api_light/src/join_lines.rs | 5 | ||||
-rw-r--r-- | crates/ra_ide_api_light/src/lib.rs | 1 | ||||
-rw-r--r-- | crates/ra_ide_api_light/src/typing.rs | 4 |
10 files changed, 33 insertions, 10 deletions
diff --git a/Cargo.lock b/Cargo.lock index 5ce4a8084..9c65b39f7 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -902,8 +902,8 @@ version = "0.1.0" | |||
902 | dependencies = [ | 902 | dependencies = [ |
903 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | 903 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", |
904 | "ra_db 0.1.0", | 904 | "ra_db 0.1.0", |
905 | "ra_fmt 0.1.0", | ||
905 | "ra_hir 0.1.0", | 906 | "ra_hir 0.1.0", |
906 | "ra_ide_api_light 0.1.0", | ||
907 | "ra_syntax 0.1.0", | 907 | "ra_syntax 0.1.0", |
908 | "ra_text_edit 0.1.0", | 908 | "ra_text_edit 0.1.0", |
909 | "test_utils 0.1.0", | 909 | "test_utils 0.1.0", |
@@ -935,6 +935,14 @@ dependencies = [ | |||
935 | ] | 935 | ] |
936 | 936 | ||
937 | [[package]] | 937 | [[package]] |
938 | name = "ra_fmt" | ||
939 | version = "0.1.0" | ||
940 | dependencies = [ | ||
941 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
942 | "ra_syntax 0.1.0", | ||
943 | ] | ||
944 | |||
945 | [[package]] | ||
938 | name = "ra_hir" | 946 | name = "ra_hir" |
939 | version = "0.1.0" | 947 | version = "0.1.0" |
940 | dependencies = [ | 948 | dependencies = [ |
@@ -988,6 +996,7 @@ dependencies = [ | |||
988 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 996 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
989 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | 997 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", |
990 | "proptest 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", | 998 | "proptest 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", |
999 | "ra_fmt 0.1.0", | ||
991 | "ra_syntax 0.1.0", | 1000 | "ra_syntax 0.1.0", |
992 | "ra_text_edit 0.1.0", | 1001 | "ra_text_edit 0.1.0", |
993 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1002 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml index 20bc253e3..71ab2dcd2 100644 --- a/crates/ra_assists/Cargo.toml +++ b/crates/ra_assists/Cargo.toml | |||
@@ -7,9 +7,9 @@ authors = ["Aleksey Kladov <[email protected]>"] | |||
7 | [dependencies] | 7 | [dependencies] |
8 | join_to_string = "0.1.3" | 8 | join_to_string = "0.1.3" |
9 | 9 | ||
10 | ra_ide_api_light = { path = "../ra_ide_api_light" } | ||
11 | ra_syntax = { path = "../ra_syntax" } | 10 | ra_syntax = { path = "../ra_syntax" } |
12 | ra_text_edit = { path = "../ra_text_edit" } | 11 | ra_text_edit = { path = "../ra_text_edit" } |
12 | ra_fmt = { path = "../ra_fmt" } | ||
13 | ra_db = { path = "../ra_db" } | 13 | ra_db = { path = "../ra_db" } |
14 | hir = { path = "../ra_hir", package = "ra_hir" } | 14 | hir = { path = "../ra_hir", package = "ra_hir" } |
15 | 15 | ||
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs index 41c8ac2f6..e240c35d6 100644 --- a/crates/ra_assists/src/assist_ctx.rs +++ b/crates/ra_assists/src/assist_ctx.rs | |||
@@ -5,7 +5,7 @@ use ra_syntax::{ | |||
5 | SourceFile, TextRange, AstNode, TextUnit, SyntaxNode, | 5 | SourceFile, TextRange, AstNode, TextUnit, SyntaxNode, |
6 | algo::{find_leaf_at_offset, find_node_at_offset, find_covering_node, LeafAtOffset}, | 6 | algo::{find_leaf_at_offset, find_node_at_offset, find_covering_node, LeafAtOffset}, |
7 | }; | 7 | }; |
8 | use ra_ide_api_light::formatting::{leading_indent, reindent}; | 8 | use ra_fmt::{leading_indent, reindent}; |
9 | 9 | ||
10 | use crate::{AssistLabel, AssistAction}; | 10 | use crate::{AssistLabel, AssistAction}; |
11 | 11 | ||
diff --git a/crates/ra_assists/src/replace_if_let_with_match.rs b/crates/ra_assists/src/replace_if_let_with_match.rs index a22ec5584..f74ab3c67 100644 --- a/crates/ra_assists/src/replace_if_let_with_match.rs +++ b/crates/ra_assists/src/replace_if_let_with_match.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use ra_syntax::{AstNode, ast}; | 1 | use ra_syntax::{AstNode, ast}; |
2 | use ra_ide_api_light::formatting::extract_trivial_expression; | 2 | use ra_fmt::extract_trivial_expression; |
3 | use hir::db::HirDatabase; | 3 | use hir::db::HirDatabase; |
4 | 4 | ||
5 | use crate::{AssistCtx, Assist}; | 5 | use crate::{AssistCtx, Assist}; |
diff --git a/crates/ra_fmt/Cargo.toml b/crates/ra_fmt/Cargo.toml new file mode 100644 index 000000000..1cf1b520f --- /dev/null +++ b/crates/ra_fmt/Cargo.toml | |||
@@ -0,0 +1,11 @@ | |||
1 | [package] | ||
2 | edition = "2018" | ||
3 | name = "ra_fmt" | ||
4 | version = "0.1.0" | ||
5 | authors = ["Aleksey Kladov <[email protected]>"] | ||
6 | publish = false | ||
7 | |||
8 | [dependencies] | ||
9 | itertools = "0.8.0" | ||
10 | |||
11 | ra_syntax = { path = "../ra_syntax" } | ||
diff --git a/crates/ra_ide_api_light/src/formatting.rs b/crates/ra_fmt/src/lib.rs index 8bc03f974..62e6fb9c1 100644 --- a/crates/ra_ide_api_light/src/formatting.rs +++ b/crates/ra_fmt/src/lib.rs | |||
@@ -1,3 +1,5 @@ | |||
1 | //! This crate provides some utilities for indenting rust code. | ||
2 | //! | ||
1 | use itertools::Itertools; | 3 | use itertools::Itertools; |
2 | use ra_syntax::{ | 4 | use ra_syntax::{ |
3 | AstNode, | 5 | AstNode, |
@@ -50,7 +52,7 @@ pub fn extract_trivial_expression(block: &ast::Block) -> Option<&ast::Expr> { | |||
50 | Some(expr) | 52 | Some(expr) |
51 | } | 53 | } |
52 | 54 | ||
53 | pub(crate) fn compute_ws(left: &SyntaxNode, right: &SyntaxNode) -> &'static str { | 55 | pub fn compute_ws(left: &SyntaxNode, right: &SyntaxNode) -> &'static str { |
54 | match left.kind() { | 56 | match left.kind() { |
55 | L_PAREN | L_BRACK => return "", | 57 | L_PAREN | L_BRACK => return "", |
56 | L_CURLY => { | 58 | L_CURLY => { |
diff --git a/crates/ra_ide_api_light/Cargo.toml b/crates/ra_ide_api_light/Cargo.toml index c1e4314ce..86311e677 100644 --- a/crates/ra_ide_api_light/Cargo.toml +++ b/crates/ra_ide_api_light/Cargo.toml | |||
@@ -13,6 +13,7 @@ rustc-hash = "1.0" | |||
13 | 13 | ||
14 | ra_syntax = { path = "../ra_syntax" } | 14 | ra_syntax = { path = "../ra_syntax" } |
15 | ra_text_edit = { path = "../ra_text_edit" } | 15 | ra_text_edit = { path = "../ra_text_edit" } |
16 | ra_fmt = { path = "../ra_fmt" } | ||
16 | 17 | ||
17 | [dev-dependencies] | 18 | [dev-dependencies] |
18 | test_utils = { path = "../test_utils" } | 19 | test_utils = { path = "../test_utils" } |
diff --git a/crates/ra_ide_api_light/src/join_lines.rs b/crates/ra_ide_api_light/src/join_lines.rs index 03770c52e..970afd327 100644 --- a/crates/ra_ide_api_light/src/join_lines.rs +++ b/crates/ra_ide_api_light/src/join_lines.rs | |||
@@ -5,10 +5,11 @@ use ra_syntax::{ | |||
5 | algo::find_covering_node, | 5 | algo::find_covering_node, |
6 | ast, | 6 | ast, |
7 | }; | 7 | }; |
8 | 8 | use ra_fmt::{ | |
9 | compute_ws, extract_trivial_expression | ||
10 | }; | ||
9 | use crate::{ | 11 | use crate::{ |
10 | LocalEdit, TextEditBuilder, | 12 | LocalEdit, TextEditBuilder, |
11 | formatting::{compute_ws, extract_trivial_expression}, | ||
12 | }; | 13 | }; |
13 | 14 | ||
14 | pub fn join_lines(file: &SourceFile, range: TextRange) -> LocalEdit { | 15 | pub fn join_lines(file: &SourceFile, range: TextRange) -> LocalEdit { |
diff --git a/crates/ra_ide_api_light/src/lib.rs b/crates/ra_ide_api_light/src/lib.rs index f3078f51e..6d1ce8dbf 100644 --- a/crates/ra_ide_api_light/src/lib.rs +++ b/crates/ra_ide_api_light/src/lib.rs | |||
@@ -3,7 +3,6 @@ | |||
3 | //! This usually means functions which take syntax tree as an input and produce | 3 | //! This usually means functions which take syntax tree as an input and produce |
4 | //! an edit or some auxiliary info. | 4 | //! an edit or some auxiliary info. |
5 | 5 | ||
6 | pub mod formatting; | ||
7 | mod extend_selection; | 6 | mod extend_selection; |
8 | mod folding_ranges; | 7 | mod folding_ranges; |
9 | mod line_index; | 8 | mod line_index; |
diff --git a/crates/ra_ide_api_light/src/typing.rs b/crates/ra_ide_api_light/src/typing.rs index a08a5a8c5..9dd9f1c1d 100644 --- a/crates/ra_ide_api_light/src/typing.rs +++ b/crates/ra_ide_api_light/src/typing.rs | |||
@@ -4,8 +4,8 @@ use ra_syntax::{ | |||
4 | algo::{find_node_at_offset, find_leaf_at_offset, LeafAtOffset}, | 4 | algo::{find_node_at_offset, find_leaf_at_offset, LeafAtOffset}, |
5 | ast::{self, AstToken}, | 5 | ast::{self, AstToken}, |
6 | }; | 6 | }; |
7 | 7 | use ra_fmt::leading_indent; | |
8 | use crate::{LocalEdit, TextEditBuilder, formatting::leading_indent}; | 8 | use crate::{LocalEdit, TextEditBuilder}; |
9 | 9 | ||
10 | pub fn on_enter(file: &SourceFile, offset: TextUnit) -> Option<LocalEdit> { | 10 | pub fn on_enter(file: &SourceFile, offset: TextUnit) -> Option<LocalEdit> { |
11 | let comment = | 11 | let comment = |