diff options
author | Aleksey Kladov <[email protected]> | 2020-08-13 10:56:11 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-08-13 10:59:42 +0100 |
commit | c81f6230da98fd3e3fa91c0896d65922a1ed4a24 (patch) | |
tree | e355901a2d197f2b7cceb35a732a111afed58198 /crates/ra_fmt | |
parent | 479235ff0b25dbac977d28475b9203e3207b117b (diff) |
Remove ra_fmt crate
Diffstat (limited to 'crates/ra_fmt')
-rw-r--r-- | crates/ra_fmt/Cargo.toml | 15 | ||||
-rw-r--r-- | crates/ra_fmt/src/lib.rs | 28 |
2 files changed, 0 insertions, 43 deletions
diff --git a/crates/ra_fmt/Cargo.toml b/crates/ra_fmt/Cargo.toml deleted file mode 100644 index d42ca62be..000000000 --- a/crates/ra_fmt/Cargo.toml +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | [package] | ||
2 | edition = "2018" | ||
3 | name = "ra_fmt" | ||
4 | version = "0.1.0" | ||
5 | authors = ["rust-analyzer developers"] | ||
6 | publish = false | ||
7 | license = "MIT OR Apache-2.0" | ||
8 | |||
9 | [lib] | ||
10 | doctest = false | ||
11 | |||
12 | [dependencies] | ||
13 | itertools = "0.9.0" | ||
14 | |||
15 | syntax = { path = "../syntax" } | ||
diff --git a/crates/ra_fmt/src/lib.rs b/crates/ra_fmt/src/lib.rs deleted file mode 100644 index b92477f9e..000000000 --- a/crates/ra_fmt/src/lib.rs +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | //! This crate provides some utilities for indenting rust code. | ||
2 | |||
3 | use std::iter::successors; | ||
4 | |||
5 | use syntax::{ | ||
6 | ast::{self, AstToken}, | ||
7 | SmolStr, SyntaxNode, SyntaxToken, | ||
8 | }; | ||
9 | |||
10 | /// If the node is on the beginning of the line, calculate indent. | ||
11 | pub fn leading_indent(node: &SyntaxNode) -> Option<SmolStr> { | ||
12 | for token in prev_tokens(node.first_token()?) { | ||
13 | if let Some(ws) = ast::Whitespace::cast(token.clone()) { | ||
14 | let ws_text = ws.text(); | ||
15 | if let Some(pos) = ws_text.rfind('\n') { | ||
16 | return Some(ws_text[pos + 1..].into()); | ||
17 | } | ||
18 | } | ||
19 | if token.text().contains('\n') { | ||
20 | break; | ||
21 | } | ||
22 | } | ||
23 | None | ||
24 | } | ||
25 | |||
26 | fn prev_tokens(token: SyntaxToken) -> impl Iterator<Item = SyntaxToken> { | ||
27 | successors(token.prev_token(), |token| token.prev_token()) | ||
28 | } | ||