Skip to content

Commit f458ea1

Browse files
committed
Make helper method less specific
1 parent 8a92910 commit f458ea1

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

crates/ide-db/src/syntax_helpers/format_string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use syntax::{
44
TextRange, TextSize,
55
};
66

7-
use super::node_ext::get_outer_macro_name;
7+
use super::node_ext::get_outer_macro;
88

99
pub fn is_format_string(string: &ast::String) -> bool {
1010
// Check if `string` is a format string argument of a macro invocation.
@@ -16,7 +16,7 @@ pub fn is_format_string(string: &ast::String) -> bool {
1616
// This setup lets us correctly highlight the components of `concat!("{}", "bla")` format
1717
// strings. It still fails for `concat!("{", "}")`, but that is rare.
1818
(|| {
19-
let name = get_outer_macro_name(string)?;
19+
let name = get_outer_macro(string)?.path()?.segment()?.name_ref()?;
2020

2121
if !matches!(
2222
name.text().as_str(),

crates/ide-db/src/syntax_helpers/node_ext.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use itertools::Itertools;
33
use parser::T;
44
use syntax::{
5-
ast::{self, HasLoopBody, NameRef, PathSegmentKind, VisibilityKind},
5+
ast::{self, HasLoopBody, MacroCall, PathSegmentKind, VisibilityKind},
66
AstNode, AstToken, Preorder, RustLanguage, WalkEvent,
77
};
88

@@ -458,9 +458,7 @@ pub fn parse_tt_as_comma_sep_paths(input: ast::TokenTree) -> Option<Vec<ast::Pat
458458
Some(paths)
459459
}
460460

461-
pub fn get_outer_macro_name(string: &ast::String) -> Option<NameRef> {
461+
pub fn get_outer_macro(string: &ast::String) -> Option<MacroCall> {
462462
let macro_call = string.syntax().parent_ancestors().find_map(ast::MacroCall::cast)?;
463-
let name = macro_call.path()?.segment()?.name_ref()?;
464-
465-
Some(name)
463+
Some(macro_call)
466464
}

0 commit comments

Comments
 (0)