mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
make on dot typed actually work
This commit is contained in:
parent
dd122145b5
commit
4aa632761f
3 changed files with 120 additions and 124 deletions
|
@ -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') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue