diff options
author | Aleksey Kladov <[email protected]> | 2019-01-11 11:57:19 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-11 11:57:19 +0000 |
commit | 4aa632761f1db5f18338c9bd568156c0259b9252 (patch) | |
tree | d977aab44ae138ba2427b0588efafd8fa7e7fd71 /crates/ra_ide_api_light/src/formatting.rs | |
parent | dd122145b57513cf57076ae3235d70215b226039 (diff) |
make on dot typed actually work
Diffstat (limited to 'crates/ra_ide_api_light/src/formatting.rs')
-rw-r--r-- | crates/ra_ide_api_light/src/formatting.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/ra_ide_api_light/src/formatting.rs b/crates/ra_ide_api_light/src/formatting.rs index 1f3769209..4635fbd60 100644 --- a/crates/ra_ide_api_light/src/formatting.rs +++ b/crates/ra_ide_api_light/src/formatting.rs | |||
@@ -1,8 +1,16 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast, AstNode, | 2 | AstNode, |
3 | SyntaxNode, SyntaxKind::*, | 3 | SyntaxNode, SyntaxKind::*, |
4 | ast::{self, AstToken}, | ||
4 | }; | 5 | }; |
5 | 6 | ||
7 | /// If the node is on the begining of the line, calculate indent. | ||
8 | pub(crate) fn leading_indent(node: &SyntaxNode) -> Option<&str> { | ||
9 | let prev = node.prev_sibling()?; | ||
10 | let ws_text = ast::Whitespace::cast(prev)?.text(); | ||
11 | ws_text.rfind('\n').map(|pos| &ws_text[pos + 1..]) | ||
12 | } | ||
13 | |||
6 | pub(crate) fn extract_trivial_expression(block: &ast::Block) -> Option<&ast::Expr> { | 14 | pub(crate) fn extract_trivial_expression(block: &ast::Block) -> Option<&ast::Expr> { |
7 | let expr = block.expr()?; | 15 | let expr = block.expr()?; |
8 | if expr.syntax().text().contains('\n') { | 16 | if expr.syntax().text().contains('\n') { |