@@ -323,11 +323,18 @@ impl<T: Clone> InFile<&T> {
323323 }
324324}
325325
326+ impl < T > InFile < Option < T > > {
327+ pub fn transpose ( self ) -> Option < InFile < T > > {
328+ let value = self . value ?;
329+ Some ( InFile :: new ( self . file_id , value) )
330+ }
331+ }
332+
326333impl InFile < SyntaxNode > {
327- pub fn ancestors_with_macros < ' a > (
334+ pub fn ancestors_with_macros (
328335 self ,
329- db : & ' a impl crate :: db:: AstDatabase ,
330- ) -> impl Iterator < Item = InFile < SyntaxNode > > + ' a {
336+ db : & impl crate :: db:: AstDatabase ,
337+ ) -> impl Iterator < Item = InFile < SyntaxNode > > + ' _ {
331338 std:: iter:: successors ( Some ( self ) , move |node| match node. value . parent ( ) {
332339 Some ( parent) => Some ( node. with_value ( parent) ) ,
333340 None => {
@@ -338,6 +345,15 @@ impl InFile<SyntaxNode> {
338345 }
339346}
340347
348+ impl InFile < SyntaxToken > {
349+ pub fn ancestors_with_macros (
350+ self ,
351+ db : & impl crate :: db:: AstDatabase ,
352+ ) -> impl Iterator < Item = InFile < SyntaxNode > > + ' _ {
353+ self . map ( |it| it. parent ( ) ) . ancestors_with_macros ( db)
354+ }
355+ }
356+
341357impl < N : AstNode > InFile < N > {
342358 pub fn descendants < T : AstNode > ( self ) -> impl Iterator < Item = InFile < T > > {
343359 self . value . syntax ( ) . descendants ( ) . filter_map ( T :: cast) . map ( move |n| self . with_value ( n) )
0 commit comments