From c81f6230da98fd3e3fa91c0896d65922a1ed4a24 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 13 Aug 2020 11:56:11 +0200 Subject: Remove ra_fmt crate --- crates/ra_fmt/src/lib.rs | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 crates/ra_fmt/src/lib.rs (limited to 'crates/ra_fmt/src') 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 @@ -//! This crate provides some utilities for indenting rust code. - -use std::iter::successors; - -use syntax::{ - ast::{self, AstToken}, - SmolStr, SyntaxNode, SyntaxToken, -}; - -/// If the node is on the beginning of the line, calculate indent. -pub fn leading_indent(node: &SyntaxNode) -> Option { - for token in prev_tokens(node.first_token()?) { - if let Some(ws) = ast::Whitespace::cast(token.clone()) { - let ws_text = ws.text(); - if let Some(pos) = ws_text.rfind('\n') { - return Some(ws_text[pos + 1..].into()); - } - } - if token.text().contains('\n') { - break; - } - } - None -} - -fn prev_tokens(token: SyntaxToken) -> impl Iterator { - successors(token.prev_token(), |token| token.prev_token()) -} -- cgit v1.2.3