fn indent_of(&mut self, node: &SyntaxNode) -> IndentLevel {
        // The impl is tricky: we need to account for whitespace in `model`, which
        // might be different from original whitespace in the syntax tree
        let mut indent = IndentLevel::default();
        self.with_preceding_elements(node, &mut |element| match element {
            SpaceBlockOrToken::Token(it) => {
                let (len, has_newline) = len_of_last_line(it.text());
                indent.alignment += len;
                has_newline
            }
            SpaceBlockOrToken::SpaceBlock(it) => {
                let (len, has_newline) = len_of_last_line(it.text());
                if has_newline {
                    indent += it.indent();
                } else {
                    indent.alignment += len;
                }
                has_newline
            }
        });

        return indent;

        fn len_of_last_line(s: &str) -> (u32, bool) {
            if let Some(idx) = s.rfind('\n') {
                return (len_for_indent(&s[idx + 1..]), true);
            }
            (len_for_indent(s), false)
        }
    }
/// Calculates current indent level for node.
Calculates current indent level for node.
Calculates current indent level for node .
fn indent_of(&mut self, node: &SyntaxNode) -> IndentLevel {
        // The impl is tricky: we need to account for whitespace in `model`, which
        // might be different from original whitespace in the syntax tree
        let mut indent = IndentLevel::default();
        self.with_preceding_elements(node, &mut |element| match element {
            SpaceBlockOrToken::Token(it) => {
                let (len, has_newline) = len_of_last_line(it.text());
                indent.alignment += len;
                has_newline
            }
            SpaceBlockOrToken::SpaceBlock(it) => {
                let (len, has_newline) = len_of_last_line(it.text());
                if has_newline {
                    indent += it.indent();
                } else {
                    indent.alignment += len;
                }
                has_newline
            }
        });
        return indent;
        fn len_of_last_line(s: &str) -> (u32, bool) {
            if let Some(idx) = s.rfind('\n') {
                return (len_for_indent(&s[idx + 1..]), true);
            }
            (len_for_indent(s), false)
        }
    }
fn indent_of ( & mut self , node : & SyntaxNode ) -> IndentLevel { // The impl is tricky: we need to account for whitespace in `model`, which // might be different from original whitespace in the syntax tree let mut indent = IndentLevel :: default ( ) ; self . with_preceding_elements ( node , & mut | element | match element { SpaceBlockOrToken :: Token ( it ) => { let ( len , has_newline ) = len_of_last_line ( it . text ( ) ) ; indent . alignment += len ; has_newline } SpaceBlockOrToken :: SpaceBlock ( it ) => { let ( len , has_newline ) = len_of_last_line ( it . text ( ) ) ; if has_newline { indent += it . indent ( ) ; } else { indent . alignment += len ; } has_newline } } ) ; return indent ; fn len_of_last_line ( s : & str ) -> ( u32 , bool ) { if let Some ( idx ) = s . rfind ( '\n' ) { return ( len_for_indent ( & s [ idx + 1 .. ] ) , true ) ; } ( len_for_indent ( s ) , false ) } }
Calculates current indent level for node.
Calculates current indent level for node .
&mut self
node
&SyntaxNode