Skip to content

Commit a807cc3

Browse files
committed
Rename get_outer_macro to macro_call_for_string_token
1 parent 3c39668 commit a807cc3

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

crates/ide-completion/src/completions/env_vars.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
//! Completes environment variables defined by Cargo (https://doc.rust-lang.org/cargo/reference/environment-variables.html)
22
use hir::Semantics;
3-
use ide_db::{syntax_helpers::node_ext::get_outer_macro, RootDatabase};
3+
use ide_db::{syntax_helpers::node_ext::macro_call_for_string_token, RootDatabase};
44
use syntax::ast::{self, IsString};
55

6-
use crate::{context::CompletionContext, CompletionItem, CompletionItemKind};
6+
use crate::{context::CompletionContext, CompletionItem, CompletionItemKind, completions::Completions};
77

8-
use super::Completions;
98
const CARGO_DEFINED_VARS: &[(&str, &str)] = &[
109
("CARGO","Path to the cargo binary performing the build"),
1110
("CARGO_MANIFEST_DIR","The directory containing the manifest of your package"),
@@ -50,7 +49,7 @@ fn guard_env_macro(
5049
string: &ast::String,
5150
semantics: &Semantics<'_, RootDatabase>,
5251
) -> Option<()> {
53-
let call = get_outer_macro(string)?;
52+
let call = macro_call_for_string_token(string)?;
5453
let name = call.path()?.segment()?.name_ref()?;
5554
let makro = semantics.resolve_macro_call(&call)?;
5655
let db = semantics.db;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ use syntax::{
33
ast::{self, IsString},
44
TextRange, TextSize,
55
};
6-
7-
use super::node_ext::get_outer_macro;
6+
use crate::syntax_helpers::node_ext::macro_call_for_string_token;
87

98
pub fn is_format_string(string: &ast::String) -> bool {
109
// Check if `string` is a format string argument of a macro invocation.
@@ -16,7 +15,7 @@ pub fn is_format_string(string: &ast::String) -> bool {
1615
// This setup lets us correctly highlight the components of `concat!("{}", "bla")` format
1716
// strings. It still fails for `concat!("{", "}")`, but that is rare.
1817
(|| {
19-
let name = get_outer_macro(string)?.path()?.segment()?.name_ref()?;
18+
let name = macro_call_for_string_token(string)?.path()?.segment()?.name_ref()?;
2019

2120
if !matches!(
2221
name.text().as_str(),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +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(string: &ast::String) -> Option<MacroCall> {
461+
pub fn macro_call_for_string_token(string: &ast::String) -> Option<MacroCall> {
462462
let macro_call = string.syntax().parent_ancestors().find_map(ast::MacroCall::cast)?;
463463
Some(macro_call)
464464
}

0 commit comments

Comments
 (0)