diff options
| author | btwotwo <10519967+btwotwo@users.noreply.github.com> | 2022-10-11 19:28:42 +0200 |
|---|---|---|
| committer | btwotwo <10519967+btwotwo@users.noreply.github.com> | 2022-10-11 19:28:42 +0200 |
| commit | a807cc3afbd5bd081f4f5ff0bad1b5c403d7a690 (patch) | |
| tree | 48e93c3ff088fdb4be59ce4e7fb82f7907525cd8 | |
| parent | 3c39668ca464919ed4180049945b3e2b9bf6191a (diff) | |
| download | rust-a807cc3afbd5bd081f4f5ff0bad1b5c403d7a690.tar.gz rust-a807cc3afbd5bd081f4f5ff0bad1b5c403d7a690.zip | |
Rename `get_outer_macro` to `macro_call_for_string_token`
| -rw-r--r-- | crates/ide-completion/src/completions/env_vars.rs | 7 | ||||
| -rw-r--r-- | crates/ide-db/src/syntax_helpers/format_string.rs | 5 | ||||
| -rw-r--r-- | crates/ide-db/src/syntax_helpers/node_ext.rs | 2 |
3 files changed, 6 insertions, 8 deletions
diff --git a/crates/ide-completion/src/completions/env_vars.rs b/crates/ide-completion/src/completions/env_vars.rs index a3a97130394..14dc17321f9 100644 --- a/crates/ide-completion/src/completions/env_vars.rs +++ b/crates/ide-completion/src/completions/env_vars.rs @@ -1,11 +1,10 @@ //! Completes environment variables defined by Cargo (https://doc.rust-lang.org/cargo/reference/environment-variables.html) use hir::Semantics; -use ide_db::{syntax_helpers::node_ext::get_outer_macro, RootDatabase}; +use ide_db::{syntax_helpers::node_ext::macro_call_for_string_token, RootDatabase}; use syntax::ast::{self, IsString}; -use crate::{context::CompletionContext, CompletionItem, CompletionItemKind}; +use crate::{context::CompletionContext, CompletionItem, CompletionItemKind, completions::Completions}; -use super::Completions; const CARGO_DEFINED_VARS: &[(&str, &str)] = &[ ("CARGO","Path to the cargo binary performing the build"), ("CARGO_MANIFEST_DIR","The directory containing the manifest of your package"), @@ -50,7 +49,7 @@ fn guard_env_macro( string: &ast::String, semantics: &Semantics<'_, RootDatabase>, ) -> Option<()> { - let call = get_outer_macro(string)?; + let call = macro_call_for_string_token(string)?; let name = call.path()?.segment()?.name_ref()?; let makro = semantics.resolve_macro_call(&call)?; let db = semantics.db; diff --git a/crates/ide-db/src/syntax_helpers/format_string.rs b/crates/ide-db/src/syntax_helpers/format_string.rs index b3e227ddd27..caa579e322b 100644 --- a/crates/ide-db/src/syntax_helpers/format_string.rs +++ b/crates/ide-db/src/syntax_helpers/format_string.rs @@ -3,8 +3,7 @@ use syntax::{ ast::{self, IsString}, TextRange, TextSize, }; - -use super::node_ext::get_outer_macro; +use crate::syntax_helpers::node_ext::macro_call_for_string_token; pub fn is_format_string(string: &ast::String) -> bool { // 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 { // This setup lets us correctly highlight the components of `concat!("{}", "bla")` format // strings. It still fails for `concat!("{", "}")`, but that is rare. (|| { - let name = get_outer_macro(string)?.path()?.segment()?.name_ref()?; + let name = macro_call_for_string_token(string)?.path()?.segment()?.name_ref()?; if !matches!( name.text().as_str(), diff --git a/crates/ide-db/src/syntax_helpers/node_ext.rs b/crates/ide-db/src/syntax_helpers/node_ext.rs index 9cfcdfb77b9..39710b8f13e 100644 --- a/crates/ide-db/src/syntax_helpers/node_ext.rs +++ b/crates/ide-db/src/syntax_helpers/node_ext.rs @@ -458,7 +458,7 @@ pub fn parse_tt_as_comma_sep_paths(input: ast::TokenTree) -> Option<Vec<ast::Pat Some(paths) } -pub fn get_outer_macro(string: &ast::String) -> Option<MacroCall> { +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) } |
