]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/rust-analyzer/crates/ide-db/src/syntax_helpers/node_ext.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / tools / rust-analyzer / crates / ide-db / src / syntax_helpers / node_ext.rs
index b890e2b58df8f2688923c1262665e7361a747881..39710b8f13eb5f7024b8fe2a385ead1badda3a21 100644 (file)
@@ -2,8 +2,8 @@
 use itertools::Itertools;
 use parser::T;
 use syntax::{
-    ast::{self, HasLoopBody, PathSegmentKind, VisibilityKind},
-    AstNode, Preorder, RustLanguage, WalkEvent,
+    ast::{self, HasLoopBody, MacroCall, PathSegmentKind, VisibilityKind},
+    AstNode, AstToken, Preorder, RustLanguage, WalkEvent,
 };
 
 pub fn expr_as_name_ref(expr: &ast::Expr) -> Option<ast::NameRef> {
@@ -457,3 +457,8 @@ pub fn parse_tt_as_comma_sep_paths(input: ast::TokenTree) -> Option<Vec<ast::Pat
         .collect();
     Some(paths)
 }
+
+pub fn macro_call_for_string_token(string: &ast::String) -> Option<MacroCall> {
+    let macro_call = string.syntax().parent_ancestors().find_map(ast::MacroCall::cast)?;
+    Some(macro_call)
+}