@@ -51,10 +51,6 @@ use crate::{
5151
5252const CONTINUE_NO_BREAKS : ControlFlow < Infallible , ( ) > = ControlFlow :: Continue ( ( ) ) ;
5353
54- pub enum DescendPreference {
55- None ,
56- }
57-
5854#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
5955pub enum PathResolution {
6056 /// An item
@@ -183,6 +179,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
183179
184180 /// Find an AstNode by offset inside SyntaxNode, if it is inside *MacroCall*,
185181 /// descend it and find again
182+ // FIXME: Rethink this API
186183 pub fn find_node_at_offset_with_descend < N : AstNode > (
187184 & self ,
188185 node : & SyntaxNode ,
@@ -191,8 +188,9 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
191188 self . imp . descend_node_at_offset ( node, offset) . flatten ( ) . find_map ( N :: cast)
192189 }
193190
194- /// Find an AstNode by offset inside SyntaxNode, if it is inside *MacroCall* ,
191+ /// Find an AstNode by offset inside SyntaxNode, if it is inside an attribte macro call ,
195192 /// descend it and find again
193+ // FIXME: Rethink this API
196194 pub fn find_nodes_at_offset_with_descend < ' slf , N : AstNode + ' slf > (
197195 & ' slf self ,
198196 node : & SyntaxNode ,
@@ -666,38 +664,6 @@ impl<'db> SemanticsImpl<'db> {
666664 res
667665 }
668666
669- /// Descend the token into its macro call if it is part of one, returning the tokens in the
670- /// expansion that it is associated with.
671- pub fn descend_into_macros (
672- & self ,
673- mode : DescendPreference ,
674- token : SyntaxToken ,
675- ) -> SmallVec < [ SyntaxToken ; 1 ] > {
676- enum Dp {
677- None ,
678- }
679- let mode = match mode {
680- DescendPreference :: None => Dp :: None ,
681- } ;
682- let mut res = smallvec ! [ ] ;
683- self . descend_into_macros_impl :: < Infallible > (
684- token. clone ( ) ,
685- & mut |InFile { value, .. } | {
686- let is_a_match = match mode {
687- Dp :: None => true ,
688- } ;
689- if is_a_match {
690- res. push ( value) ;
691- }
692- ControlFlow :: Continue ( ( ) )
693- } ,
694- ) ;
695- if res. is_empty ( ) {
696- res. push ( token) ;
697- }
698- res
699- }
700-
701667 pub fn descend_into_macros_ng (
702668 & self ,
703669 token : SyntaxToken ,
@@ -709,6 +675,18 @@ impl<'db> SemanticsImpl<'db> {
709675 } ) ;
710676 }
711677
678+ pub fn descend_into_macros_ng_v ( & self , token : SyntaxToken ) -> SmallVec < [ SyntaxToken ; 1 ] > {
679+ let mut res = smallvec ! [ ] ;
680+ self . descend_into_macros_impl ( token. clone ( ) , & mut |t| {
681+ res. push ( t. value ) ;
682+ CONTINUE_NO_BREAKS
683+ } ) ;
684+ if res. is_empty ( ) {
685+ res. push ( token) ;
686+ }
687+ res
688+ }
689+
712690 pub fn descend_into_macros_ng_b < T > (
713691 & self ,
714692 token : SyntaxToken ,
@@ -1003,7 +981,7 @@ impl<'db> SemanticsImpl<'db> {
1003981 offset : TextSize ,
1004982 ) -> impl Iterator < Item = impl Iterator < Item = SyntaxNode > + ' _ > + ' _ {
1005983 node. token_at_offset ( offset)
1006- . map ( move |token| self . descend_into_macros ( DescendPreference :: None , token) )
984+ . map ( move |token| self . descend_into_macros_exact ( token) )
1007985 . map ( |descendants| {
1008986 descendants. into_iter ( ) . map ( move |it| self . token_ancestors_with_macros ( it) )
1009987 } )
0 commit comments