mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Formatting
This commit is contained in:
parent
c660a5ce34
commit
8a92910f97
3 changed files with 19 additions and 11 deletions
|
@ -27,10 +27,7 @@ const CARGO_DEFINED_VARS: &[(&str, &str)] = &[
|
||||||
("CARGO_TARGET_TMPDIR","Only set when building integration test or benchmark code. This is a path to a directory inside the target directory where integration tests or benchmarks are free to put any data needed by the tests/benches. Cargo initially creates this directory but doesn't manage its content in any way, this is the responsibility of the test code")
|
("CARGO_TARGET_TMPDIR","Only set when building integration test or benchmark code. This is a path to a directory inside the target directory where integration tests or benchmarks are free to put any data needed by the tests/benches. Cargo initially creates this directory but doesn't manage its content in any way, this is the responsibility of the test code")
|
||||||
];
|
];
|
||||||
|
|
||||||
pub(crate) fn complete_cargo_env_vars(
|
pub(crate) fn complete_cargo_env_vars(acc: &mut Completions, expanded: &ast::String) -> Option<()> {
|
||||||
acc: &mut Completions,
|
|
||||||
expanded: &ast::String,
|
|
||||||
) -> Option<()> {
|
|
||||||
guard_env_macro(expanded)?;
|
guard_env_macro(expanded)?;
|
||||||
let range = expanded.text_range_between_quotes()?;
|
let range = expanded.text_range_between_quotes()?;
|
||||||
|
|
||||||
|
@ -57,15 +54,25 @@ mod tests {
|
||||||
use crate::tests::{check_edit, completion_list};
|
use crate::tests::{check_edit, completion_list};
|
||||||
|
|
||||||
fn check(macro_name: &str) {
|
fn check(macro_name: &str) {
|
||||||
check_edit("CARGO_BIN_NAME",&format!(r#"
|
check_edit(
|
||||||
|
"CARGO_BIN_NAME",
|
||||||
|
&format!(
|
||||||
|
r#"
|
||||||
fn main() {{
|
fn main() {{
|
||||||
let foo = {}!("CAR$0");
|
let foo = {}!("CAR$0");
|
||||||
}}
|
}}
|
||||||
"#, macro_name), &format!(r#"
|
"#,
|
||||||
|
macro_name
|
||||||
|
),
|
||||||
|
&format!(
|
||||||
|
r#"
|
||||||
fn main() {{
|
fn main() {{
|
||||||
let foo = {}!("CARGO_BIN_NAME");
|
let foo = {}!("CARGO_BIN_NAME");
|
||||||
}}
|
}}
|
||||||
"#, macro_name));
|
"#,
|
||||||
|
macro_name
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn completes_env_variable_in_env() {
|
fn completes_env_variable_in_env() {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
//! Tools to work with format string literals for the `format_args!` family of macros.
|
//! Tools to work with format string literals for the `format_args!` family of macros.
|
||||||
use syntax::{
|
use syntax::{
|
||||||
ast::{self, IsString}, TextRange, TextSize,
|
ast::{self, IsString},
|
||||||
|
TextRange, TextSize,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::node_ext::get_outer_macro_name;
|
use super::node_ext::get_outer_macro_name;
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use parser::T;
|
use parser::T;
|
||||||
use syntax::{
|
use syntax::{
|
||||||
ast::{self, HasLoopBody, PathSegmentKind, VisibilityKind, NameRef},
|
ast::{self, HasLoopBody, NameRef, PathSegmentKind, VisibilityKind},
|
||||||
AstNode, Preorder, RustLanguage, WalkEvent, AstToken,
|
AstNode, AstToken, Preorder, RustLanguage, WalkEvent,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn expr_as_name_ref(expr: &ast::Expr) -> Option<ast::NameRef> {
|
pub fn expr_as_name_ref(expr: &ast::Expr) -> Option<ast::NameRef> {
|
||||||
|
@ -463,4 +463,4 @@ pub fn get_outer_macro_name(string: &ast::String) -> Option<NameRef> {
|
||||||
let name = macro_call.path()?.segment()?.name_ref()?;
|
let name = macro_call.path()?.segment()?.name_ref()?;
|
||||||
|
|
||||||
Some(name)
|
Some(name)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue