make on dot typed actually work

This commit is contained in:
Aleksey Kladov 2019-01-11 14:57:19 +03:00
parent dd122145b5
commit 4aa632761f
3 changed files with 120 additions and 124 deletions

View file

@ -1,8 +1,16 @@
use ra_syntax::{
ast, AstNode,
AstNode,
SyntaxNode, SyntaxKind::*,
ast::{self, AstToken},
};
/// If the node is on the begining of the line, calculate indent.
pub(crate) fn leading_indent(node: &SyntaxNode) -> Option<&str> {
let prev = node.prev_sibling()?;
let ws_text = ast::Whitespace::cast(prev)?.text();
ws_text.rfind('\n').map(|pos| &ws_text[pos + 1..])
}
pub(crate) fn extract_trivial_expression(block: &ast::Block) -> Option<&ast::Expr> {
let expr = block.expr()?;
if expr.syntax().text().contains('\n') {