fn descend_node_into_attributes<N: AstNode>(&self, node: N) -> SmallVec<[N; 1]> {
        let mut res = smallvec![];
        let tokens = (|| {
            let first = skip_trivia_token(node.syntax().first_token()?, Direction::Next)?;
            let last = skip_trivia_token(node.syntax().last_token()?, Direction::Prev)?;
            Some((first, last))
        })();
        let (first, last) = match tokens {
            Some(it) => it,
            None => return res,
        };

        if first == last {
            self.descend_into_macros_impl(
                first,
                &mut |InFile { value, .. }| {
                    if let Some(node) = value.ancestors().find_map(N::cast) {
                        res.push(node)
                    }
                },
                false,
            );
        } else {
            // Descend first and last token, then zip them to look for the node they belong to
            let mut scratch: SmallVec<[_; 1]> = smallvec![];
            self.descend_into_macros_impl(
                first,
                &mut |token| {
                    scratch.push(token);
                },
                false,
            );

            let mut scratch = scratch.into_iter();
            self.descend_into_macros_impl(
                last,
                &mut |InFile { value: last, file_id: last_fid }| {
                    if let Some(InFile { value: first, file_id: first_fid }) = scratch.next() {
                        if first_fid == last_fid {
                            if let Some(p) = first.parent() {
                                let range = first.text_range().cover(last.text_range());
                                let node = find_root(&p)
                                    .covering_element(range)
                                    .ancestors()
                                    .take_while(|it| it.text_range() == range)
                                    .find_map(N::cast);
                                if let Some(node) = node {
                                    res.push(node);
                                }
                            }
                        }
                    }
                },
                false,
            );
        }
        res
    }
// This might not be the correct way to do this, but it works for now
This might not be the correct way to do this, but it works for now
This might not be the correct way to do this but it works for now
fn descend_node_into_attributes<N: AstNode>(&self, node: N) -> SmallVec<[N; 1]> {
        let mut res = smallvec![];
        let tokens = (|| {
            let first = skip_trivia_token(node.syntax().first_token()?, Direction::Next)?;
            let last = skip_trivia_token(node.syntax().last_token()?, Direction::Prev)?;
            Some((first, last))
        })();
        let (first, last) = match tokens {
            Some(it) => it,
            None => return res,
        };
        if first == last {
            self.descend_into_macros_impl(
                first,
                &mut |InFile { value, .. }| {
                    if let Some(node) = value.ancestors().find_map(N::cast) {
                        res.push(node)
                    }
                },
                false,
            );
        } else {
            // Descend first and last token, then zip them to look for the node they belong to
            let mut scratch: SmallVec<[_; 1]> = smallvec![];
            self.descend_into_macros_impl(
                first,
                &mut |token| {
                    scratch.push(token);
                },
                false,
            );
            let mut scratch = scratch.into_iter();
            self.descend_into_macros_impl(
                last,
                &mut |InFile { value: last, file_id: last_fid }| {
                    if let Some(InFile { value: first, file_id: first_fid }) = scratch.next() {
                        if first_fid == last_fid {
                            if let Some(p) = first.parent() {
                                let range = first.text_range().cover(last.text_range());
                                let node = find_root(&p)
                                    .covering_element(range)
                                    .ancestors()
                                    .take_while(|it| it.text_range() == range)
                                    .find_map(N::cast);
                                if let Some(node) = node {
                                    res.push(node);
                                }
                            }
                        }
                    }
                },
                false,
            );
        }
        res
    }
fn descend_node_into_attributes < N : AstNode > ( & self , node : N ) -> SmallVec < [ N ; 1 ] > { let mut res = smallvec ! [ ] ; let tokens = ( | | { let first = skip_trivia_token ( node . syntax ( ) . first_token ( ) ? , Direction :: Next ) ? ; let last = skip_trivia_token ( node . syntax ( ) . last_token ( ) ? , Direction :: Prev ) ? ; Some ( ( first , last ) ) } ) ( ) ; let ( first , last ) = match tokens { Some ( it ) => it , None => return res , } ; if first == last { self . descend_into_macros_impl ( first , & mut | InFile { value , .. } | { if let Some ( node ) = value . ancestors ( ) . find_map ( N :: cast ) { res . push ( node ) } } , false , ) ; } else { // Descend first and last token, then zip them to look for the node they belong to let mut scratch : SmallVec < [ _ ; 1 ] > = smallvec ! [ ] ; self . descend_into_macros_impl ( first , & mut | token | { scratch . push ( token ) ; } , false , ) ; let mut scratch = scratch . into_iter ( ) ; self . descend_into_macros_impl ( last , & mut | InFile { value : last , file_id : last_fid } | { if let Some ( InFile { value : first , file_id : first_fid } ) = scratch . next ( ) { if first_fid == last_fid { if let Some ( p ) = first . parent ( ) { let range = first . text_range ( ) . cover ( last . text_range ( ) ) ; let node = find_root ( & p ) . covering_element ( range ) . ancestors ( ) . take_while ( | it | it . text_range ( ) == range ) . find_map ( N :: cast ) ; if let Some ( node ) = node { res . push ( node ) ; } } } } } , false , ) ; } res }
This might not be the correct way to do this, but it works for now
This might not be the correct way to do this but it works for now
&self
node
N
&self
node
N