mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Change <|> to $0 - Rebase
This commit is contained in:
parent
171c3c08fe
commit
72b9a4fbd3
110 changed files with 1745 additions and 1765 deletions
|
@ -413,7 +413,7 @@ mod tests {
|
|||
fn empty_derive_completion() {
|
||||
check(
|
||||
r#"
|
||||
#[derive(<|>)]
|
||||
#[derive($0)]
|
||||
struct Test {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -434,7 +434,7 @@ struct Test {}
|
|||
fn no_completion_for_incorrect_derive() {
|
||||
check(
|
||||
r#"
|
||||
#[derive{<|>)]
|
||||
#[derive{$0)]
|
||||
struct Test {}
|
||||
"#,
|
||||
expect![[r#""#]],
|
||||
|
@ -445,7 +445,7 @@ struct Test {}
|
|||
fn derive_with_input_completion() {
|
||||
check(
|
||||
r#"
|
||||
#[derive(serde::Serialize, PartialEq, <|>)]
|
||||
#[derive(serde::Serialize, PartialEq, $0)]
|
||||
struct Test {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -464,7 +464,7 @@ struct Test {}
|
|||
#[test]
|
||||
fn test_attribute_completion() {
|
||||
check(
|
||||
r#"#[<|>]"#,
|
||||
r#"#[$0]"#,
|
||||
expect![[r#"
|
||||
at allow(…)
|
||||
at automatically_derived
|
||||
|
@ -504,13 +504,13 @@ struct Test {}
|
|||
|
||||
#[test]
|
||||
fn test_attribute_completion_inside_nested_attr() {
|
||||
check(r#"#[cfg(<|>)]"#, expect![[]])
|
||||
check(r#"#[cfg($0)]"#, expect![[]])
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_inner_attribute_completion() {
|
||||
check(
|
||||
r"#![<|>]",
|
||||
r"#![$0]",
|
||||
expect![[r#"
|
||||
at allow(…)
|
||||
at automatically_derived
|
||||
|
|
|
@ -79,7 +79,7 @@ struct S { foo: u32 }
|
|||
impl S {
|
||||
fn bar(&self) {}
|
||||
}
|
||||
fn foo(s: S) { s.<|> }
|
||||
fn foo(s: S) { s.$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fd foo u32
|
||||
|
@ -94,7 +94,7 @@ fn foo(s: S) { s.<|> }
|
|||
r#"
|
||||
struct S { the_field: (u32,) }
|
||||
impl S {
|
||||
fn foo(self) { self.<|> }
|
||||
fn foo(self) { self.$0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -110,7 +110,7 @@ impl S {
|
|||
r#"
|
||||
struct A { the_field: (u32, i32) }
|
||||
impl A {
|
||||
fn foo(&self) { self.<|> }
|
||||
fn foo(&self) { self.$0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -126,7 +126,7 @@ impl A {
|
|||
check(
|
||||
r#"
|
||||
struct A { the_field: u32 }
|
||||
fn foo(a: A) { a.<|>() }
|
||||
fn foo(a: A) { a.$0() }
|
||||
"#,
|
||||
expect![[""]],
|
||||
);
|
||||
|
@ -144,7 +144,7 @@ mod inner {
|
|||
pub(crate) super_field: u32,
|
||||
}
|
||||
}
|
||||
fn foo(a: inner::A) { a.<|> }
|
||||
fn foo(a: inner::A) { a.$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fd pub_field u32
|
||||
|
@ -162,7 +162,7 @@ mod m {
|
|||
pub(crate) fn the_method(&self) {}
|
||||
}
|
||||
}
|
||||
fn foo(a: A) { a.<|> }
|
||||
fn foo(a: A) { a.$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
me the_method() pub(crate) fn the_method(&self)
|
||||
|
@ -175,7 +175,7 @@ fn foo(a: A) { a.<|> }
|
|||
check(
|
||||
r#"
|
||||
union U { field: u8, other: u16 }
|
||||
fn foo(u: U) { u.<|> }
|
||||
fn foo(u: U) { u.$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fd field u8
|
||||
|
@ -195,7 +195,7 @@ impl A<u32> {
|
|||
impl A<i32> {
|
||||
fn the_other_method(&self) {}
|
||||
}
|
||||
fn foo(a: A<u32>) { a.<|> }
|
||||
fn foo(a: A<u32>) { a.$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
me the_method() fn the_method(&self)
|
||||
|
@ -210,7 +210,7 @@ fn foo(a: A<u32>) { a.<|> }
|
|||
struct A {}
|
||||
trait Trait { fn the_method(&self); }
|
||||
impl Trait for A {}
|
||||
fn foo(a: A) { a.<|> }
|
||||
fn foo(a: A) { a.$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
me the_method() fn the_method(&self)
|
||||
|
@ -225,7 +225,7 @@ fn foo(a: A) { a.<|> }
|
|||
struct A {}
|
||||
trait Trait { fn the_method(&self); }
|
||||
impl<T> Trait for T {}
|
||||
fn foo(a: &A) { a.<|> }
|
||||
fn foo(a: &A) { a.$0 }
|
||||
",
|
||||
expect![[r#"
|
||||
me the_method() fn the_method(&self)
|
||||
|
@ -243,7 +243,7 @@ mod m {
|
|||
}
|
||||
use m::Trait;
|
||||
impl Trait for A {}
|
||||
fn foo(a: A) { a.<|> }
|
||||
fn foo(a: A) { a.$0 }
|
||||
",
|
||||
expect![[r#"
|
||||
me the_method() fn the_method(&self)
|
||||
|
@ -260,7 +260,7 @@ impl A {
|
|||
fn the_method() {}
|
||||
}
|
||||
fn foo(a: A) {
|
||||
a.<|>
|
||||
a.$0
|
||||
}
|
||||
"#,
|
||||
expect![[""]],
|
||||
|
@ -273,7 +273,7 @@ fn foo(a: A) {
|
|||
r#"
|
||||
fn foo() {
|
||||
let b = (0, 3.14);
|
||||
b.<|>
|
||||
b.$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -295,7 +295,7 @@ struct T(S);
|
|||
impl T {
|
||||
fn foo(&self) {
|
||||
// FIXME: This doesn't work without the trailing `a` as `0.` is a float
|
||||
self.0.a<|>
|
||||
self.0.a$0
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
@ -311,7 +311,7 @@ impl T {
|
|||
r#"
|
||||
struct A { the_field: u32 }
|
||||
const X: u32 = {
|
||||
A { the_field: 92 }.<|>
|
||||
A { the_field: 92 }.$0
|
||||
};
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -327,7 +327,7 @@ const X: u32 = {
|
|||
macro_rules! m { ($e:expr) => { $e } }
|
||||
struct A { the_field: u32 }
|
||||
fn foo(a: A) {
|
||||
m!(a.x<|>)
|
||||
m!(a.x$0)
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -344,7 +344,7 @@ fn foo(a: A) {
|
|||
macro_rules! m { ($e:expr) => { $e } }
|
||||
struct A { the_field: u32 }
|
||||
fn foo(a: A) {
|
||||
m!(a.<|>)
|
||||
m!(a.$0)
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -360,7 +360,7 @@ fn foo(a: A) {
|
|||
macro_rules! m { ($e:expr) => { $e } }
|
||||
struct A { the_field: u32 }
|
||||
fn foo(a: A) {
|
||||
m!(m!(m!(a.x<|>)))
|
||||
m!(m!(m!(a.x$0)))
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -386,7 +386,7 @@ macro_rules! dbg {
|
|||
}
|
||||
struct A { the_field: u32 }
|
||||
fn foo(a: A) {
|
||||
dbg!(a.<|>)
|
||||
dbg!(a.$0)
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -405,7 +405,7 @@ impl<T> HashSet<T> {
|
|||
}
|
||||
fn foo() {
|
||||
let s: HashSet<_>;
|
||||
s.<|>
|
||||
s.$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -421,7 +421,7 @@ fn foo() {
|
|||
struct S;
|
||||
impl S { fn foo(&self) {} }
|
||||
macro_rules! make_s { () => { S }; }
|
||||
fn main() { make_s!().f<|>; }
|
||||
fn main() { make_s!().f$0; }
|
||||
"#,
|
||||
expect![[r#"
|
||||
me foo() fn foo(&self)
|
||||
|
|
|
@ -81,7 +81,7 @@ mod tests {
|
|||
r#"
|
||||
fn foo(file_id: FileId) {}
|
||||
fn bar(file_id: FileId) {}
|
||||
fn baz(file<|>) {}
|
||||
fn baz(file$0) {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
bn file_id: FileId
|
||||
|
@ -94,7 +94,7 @@ fn baz(file<|>) {}
|
|||
check(
|
||||
r#"
|
||||
fn foo(file_id: FileId) {}
|
||||
fn baz(file<|>, x: i32) {}
|
||||
fn baz(file$0, x: i32) {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
bn file_id: FileId
|
||||
|
@ -110,7 +110,7 @@ pub(crate) trait SourceRoot {
|
|||
pub fn contains(&self, file_id: FileId) -> bool;
|
||||
pub fn module_map(&self) -> &ModuleMap;
|
||||
pub fn lines(&self, file_id: FileId) -> &LineIndex;
|
||||
pub fn syntax(&self, file<|>)
|
||||
pub fn syntax(&self, file$0)
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -124,7 +124,7 @@ pub(crate) trait SourceRoot {
|
|||
check(
|
||||
r#"
|
||||
fn outer(text: String) {
|
||||
fn inner(<|>)
|
||||
fn inner($0)
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
|
|
@ -193,7 +193,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_keywords_in_use_stmt() {
|
||||
check(
|
||||
r"use <|>",
|
||||
r"use $0",
|
||||
expect![[r#"
|
||||
kw crate::
|
||||
kw self
|
||||
|
@ -202,7 +202,7 @@ mod tests {
|
|||
);
|
||||
|
||||
check(
|
||||
r"use a::<|>",
|
||||
r"use a::$0",
|
||||
expect![[r#"
|
||||
kw self
|
||||
kw super::
|
||||
|
@ -210,7 +210,7 @@ mod tests {
|
|||
);
|
||||
|
||||
check(
|
||||
r"use a::{b, <|>}",
|
||||
r"use a::{b, $0}",
|
||||
expect![[r#"
|
||||
kw self
|
||||
kw super::
|
||||
|
@ -221,7 +221,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_keywords_at_source_file_level() {
|
||||
check(
|
||||
r"m<|>",
|
||||
r"m$0",
|
||||
expect![[r#"
|
||||
kw fn
|
||||
kw use
|
||||
|
@ -245,7 +245,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_keywords_in_function() {
|
||||
check(
|
||||
r"fn quux() { <|> }",
|
||||
r"fn quux() { $0 }",
|
||||
expect![[r#"
|
||||
kw fn
|
||||
kw use
|
||||
|
@ -271,7 +271,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_keywords_inside_block() {
|
||||
check(
|
||||
r"fn quux() { if true { <|> } }",
|
||||
r"fn quux() { if true { $0 } }",
|
||||
expect![[r#"
|
||||
kw fn
|
||||
kw use
|
||||
|
@ -297,7 +297,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_keywords_after_if() {
|
||||
check(
|
||||
r#"fn quux() { if true { () } <|> }"#,
|
||||
r#"fn quux() { if true { () } $0 }"#,
|
||||
expect![[r#"
|
||||
kw fn
|
||||
kw use
|
||||
|
@ -322,7 +322,7 @@ mod tests {
|
|||
);
|
||||
check_edit(
|
||||
"else",
|
||||
r#"fn quux() { if true { () } <|> }"#,
|
||||
r#"fn quux() { if true { () } $0 }"#,
|
||||
r#"fn quux() { if true { () } else {$0} }"#,
|
||||
);
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ mod tests {
|
|||
check(
|
||||
r#"
|
||||
fn quux() -> i32 {
|
||||
match () { () => <|> }
|
||||
match () { () => $0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -350,7 +350,7 @@ fn quux() -> i32 {
|
|||
#[test]
|
||||
fn test_keywords_in_trait_def() {
|
||||
check(
|
||||
r"trait My { <|> }",
|
||||
r"trait My { $0 }",
|
||||
expect![[r#"
|
||||
kw fn
|
||||
kw const
|
||||
|
@ -363,7 +363,7 @@ fn quux() -> i32 {
|
|||
#[test]
|
||||
fn test_keywords_in_impl_def() {
|
||||
check(
|
||||
r"impl My { <|> }",
|
||||
r"impl My { $0 }",
|
||||
expect![[r#"
|
||||
kw fn
|
||||
kw const
|
||||
|
@ -378,7 +378,7 @@ fn quux() -> i32 {
|
|||
#[test]
|
||||
fn test_keywords_in_loop() {
|
||||
check(
|
||||
r"fn my() { loop { <|> } }",
|
||||
r"fn my() { loop { $0 } }",
|
||||
expect![[r#"
|
||||
kw fn
|
||||
kw use
|
||||
|
@ -406,7 +406,7 @@ fn quux() -> i32 {
|
|||
#[test]
|
||||
fn test_keywords_after_unsafe_in_item_list() {
|
||||
check(
|
||||
r"unsafe <|>",
|
||||
r"unsafe $0",
|
||||
expect![[r#"
|
||||
kw fn
|
||||
kw trait
|
||||
|
@ -418,7 +418,7 @@ fn quux() -> i32 {
|
|||
#[test]
|
||||
fn test_keywords_after_unsafe_in_block_expr() {
|
||||
check(
|
||||
r"fn my_fn() { unsafe <|> }",
|
||||
r"fn my_fn() { unsafe $0 }",
|
||||
expect![[r#"
|
||||
kw fn
|
||||
kw trait
|
||||
|
@ -430,19 +430,19 @@ fn quux() -> i32 {
|
|||
#[test]
|
||||
fn test_mut_in_ref_and_in_fn_parameters_list() {
|
||||
check(
|
||||
r"fn my_fn(&<|>) {}",
|
||||
r"fn my_fn(&$0) {}",
|
||||
expect![[r#"
|
||||
kw mut
|
||||
"#]],
|
||||
);
|
||||
check(
|
||||
r"fn my_fn(<|>) {}",
|
||||
r"fn my_fn($0) {}",
|
||||
expect![[r#"
|
||||
kw mut
|
||||
"#]],
|
||||
);
|
||||
check(
|
||||
r"fn my_fn() { let &<|> }",
|
||||
r"fn my_fn() { let &$0 }",
|
||||
expect![[r#"
|
||||
kw mut
|
||||
"#]],
|
||||
|
@ -452,13 +452,13 @@ fn quux() -> i32 {
|
|||
#[test]
|
||||
fn test_where_keyword() {
|
||||
check(
|
||||
r"trait A <|>",
|
||||
r"trait A $0",
|
||||
expect![[r#"
|
||||
kw where
|
||||
"#]],
|
||||
);
|
||||
check(
|
||||
r"impl A <|>",
|
||||
r"impl A $0",
|
||||
expect![[r#"
|
||||
kw where
|
||||
"#]],
|
||||
|
@ -471,7 +471,7 @@ fn quux() -> i32 {
|
|||
check(
|
||||
r#"
|
||||
fn test() {
|
||||
let x = 2; // A comment<|>
|
||||
let x = 2; // A comment$0
|
||||
}
|
||||
"#,
|
||||
expect![[""]],
|
||||
|
@ -479,7 +479,7 @@ fn test() {
|
|||
check(
|
||||
r#"
|
||||
/*
|
||||
Some multi-line comment<|>
|
||||
Some multi-line comment$0
|
||||
*/
|
||||
"#,
|
||||
expect![[""]],
|
||||
|
@ -487,7 +487,7 @@ Some multi-line comment<|>
|
|||
check(
|
||||
r#"
|
||||
/// Some doc comment
|
||||
/// let test<|> = 1
|
||||
/// let test$0 = 1
|
||||
"#,
|
||||
expect![[""]],
|
||||
);
|
||||
|
@ -501,7 +501,7 @@ Some multi-line comment<|>
|
|||
use std::future::*;
|
||||
struct A {}
|
||||
impl Future for A {}
|
||||
fn foo(a: A) { a.<|> }
|
||||
fn foo(a: A) { a.$0 }
|
||||
|
||||
//- /std/lib.rs crate:std
|
||||
pub mod future {
|
||||
|
@ -520,7 +520,7 @@ pub mod future {
|
|||
use std::future::*;
|
||||
fn foo() {
|
||||
let a = async {};
|
||||
a.<|>
|
||||
a.$0
|
||||
}
|
||||
|
||||
//- /std/lib.rs crate:std
|
||||
|
@ -540,7 +540,7 @@ pub mod future {
|
|||
#[test]
|
||||
fn after_let() {
|
||||
check(
|
||||
r#"fn main() { let _ = <|> }"#,
|
||||
r#"fn main() { let _ = $0 }"#,
|
||||
expect![[r#"
|
||||
kw match
|
||||
kw while
|
||||
|
@ -557,7 +557,7 @@ pub mod future {
|
|||
check(
|
||||
r#"
|
||||
struct Foo {
|
||||
<|>
|
||||
$0
|
||||
pub f: i32,
|
||||
}
|
||||
"#,
|
||||
|
@ -578,7 +578,7 @@ struct Foo {
|
|||
}
|
||||
fn foo() {
|
||||
Foo {
|
||||
<|>
|
||||
$0
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
@ -595,7 +595,7 @@ struct Foo {
|
|||
}
|
||||
fn foo() {
|
||||
Foo {
|
||||
f: <|>
|
||||
f: $0
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
|
|
@ -31,7 +31,7 @@ mod tests {
|
|||
macro_rules! foo { () => {} }
|
||||
fn foo() {}
|
||||
|
||||
<|>
|
||||
$0
|
||||
"#,
|
||||
expect![[r#"
|
||||
ma foo!(…) macro_rules! foo
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::{CompletionItem, CompletionItemKind};
|
|||
|
||||
use crate::{context::CompletionContext, item::CompletionKind, Completions};
|
||||
|
||||
/// Complete mod declaration, i.e. `mod <|> ;`
|
||||
/// Complete mod declaration, i.e. `mod $0 ;`
|
||||
pub(crate) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
|
||||
let mod_under_caret = match &ctx.mod_declaration_under_caret {
|
||||
Some(mod_under_caret) if mod_under_caret.item_list().is_some() => return None,
|
||||
|
@ -159,7 +159,7 @@ mod tests {
|
|||
check(
|
||||
r#"
|
||||
//- /lib.rs
|
||||
mod <|>
|
||||
mod $0
|
||||
//- /foo.rs
|
||||
fn foo() {}
|
||||
//- /foo/ignored_foo.rs
|
||||
|
@ -181,7 +181,7 @@ mod tests {
|
|||
check(
|
||||
r#"
|
||||
//- /lib.rs
|
||||
mod <|> {
|
||||
mod $0 {
|
||||
|
||||
}
|
||||
//- /foo.rs
|
||||
|
@ -196,7 +196,7 @@ mod tests {
|
|||
check(
|
||||
r#"
|
||||
//- /main.rs
|
||||
mod <|>
|
||||
mod $0
|
||||
//- /foo.rs
|
||||
fn foo() {}
|
||||
//- /foo/ignored_foo.rs
|
||||
|
@ -219,7 +219,7 @@ mod tests {
|
|||
r#"
|
||||
//- /main.rs
|
||||
mod tests {
|
||||
mod <|>;
|
||||
mod $0;
|
||||
}
|
||||
//- /tests/foo.rs
|
||||
fn foo() {}
|
||||
|
@ -237,7 +237,7 @@ mod tests {
|
|||
//- /lib.rs
|
||||
mod foo;
|
||||
//- /foo.rs
|
||||
mod <|>;
|
||||
mod $0;
|
||||
//- /foo/bar.rs
|
||||
fn bar() {}
|
||||
//- /foo/bar/ignored_bar.rs
|
||||
|
@ -262,7 +262,7 @@ mod tests {
|
|||
mod foo;
|
||||
//- /foo.rs
|
||||
mod bar {
|
||||
mod <|>
|
||||
mod $0
|
||||
}
|
||||
//- /foo/bar/baz.rs
|
||||
fn baz() {}
|
||||
|
@ -288,7 +288,7 @@ mod tests {
|
|||
// //- /src/bin.rs
|
||||
// fn main() {}
|
||||
// //- /src/bin/foo.rs
|
||||
// mod <|>
|
||||
// mod $0
|
||||
// //- /src/bin/bar.rs
|
||||
// fn bar() {}
|
||||
// //- /src/bin/bar/bar_ignored.rs
|
||||
|
@ -307,7 +307,7 @@ mod tests {
|
|||
//- /src/bin.rs crate:main
|
||||
fn main() {}
|
||||
//- /src/bin/foo.rs
|
||||
mod <|>
|
||||
mod $0
|
||||
//- /src/bin/bar.rs
|
||||
mod foo;
|
||||
fn bar() {}
|
||||
|
|
|
@ -71,7 +71,7 @@ static FOO: E = E::X;
|
|||
struct Bar { f: u32 }
|
||||
|
||||
fn foo() {
|
||||
match E::X { <|> }
|
||||
match E::X { $0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -92,7 +92,7 @@ macro_rules! m { ($e:expr) => { $e } }
|
|||
enum E { X }
|
||||
|
||||
fn foo() {
|
||||
m!(match E::X { <|> })
|
||||
m!(match E::X { $0 })
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -115,7 +115,7 @@ static FOO: E = E::X;
|
|||
struct Bar { f: u32 }
|
||||
|
||||
fn foo() {
|
||||
let <|>
|
||||
let $0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -133,7 +133,7 @@ enum E { X }
|
|||
static FOO: E = E::X;
|
||||
struct Bar { f: u32 }
|
||||
|
||||
fn foo(<|>) {
|
||||
fn foo($0) {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -149,7 +149,7 @@ fn foo(<|>) {
|
|||
struct Bar { f: u32 }
|
||||
|
||||
fn foo() {
|
||||
let <|>
|
||||
let $0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -165,7 +165,7 @@ fn foo() {
|
|||
struct Foo { bar: String, baz: String }
|
||||
struct Bar(String, String);
|
||||
struct Baz;
|
||||
fn outer(<|>) {}
|
||||
fn outer($0) {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
bn Foo Foo { bar$1, baz$2 }: Foo$0
|
||||
|
@ -182,7 +182,7 @@ struct Foo { bar: String, baz: String }
|
|||
struct Bar(String, String);
|
||||
struct Baz;
|
||||
fn outer() {
|
||||
let <|>
|
||||
let $0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -201,7 +201,7 @@ struct Bar(String, String);
|
|||
struct Baz;
|
||||
fn outer() {
|
||||
match () {
|
||||
<|>
|
||||
$0
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
@ -225,7 +225,7 @@ use foo::*;
|
|||
|
||||
fn outer() {
|
||||
match () {
|
||||
<|>
|
||||
$0
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
@ -244,7 +244,7 @@ fn outer() {
|
|||
struct Foo(i32);
|
||||
fn main() {
|
||||
match Foo(92) {
|
||||
<|>(92) => (),
|
||||
$0(92) => (),
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//! Postfix completions, like `Ok(10).ifl<|>` => `if let Ok() = Ok(10) { <|> }`.
|
||||
//! Postfix completions, like `Ok(10).ifl$0` => `if let Ok() = Ok(10) { $0 }`.
|
||||
|
||||
mod format_like;
|
||||
|
||||
|
@ -310,7 +310,7 @@ mod tests {
|
|||
r#"
|
||||
fn main() {
|
||||
let bar = true;
|
||||
bar.<|>
|
||||
bar.$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -342,7 +342,7 @@ fn foo(elt: bool) -> bool {
|
|||
|
||||
fn main() {
|
||||
let bar = true;
|
||||
foo(bar.<|>)
|
||||
foo(bar.$0)
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -368,7 +368,7 @@ fn main() {
|
|||
r#"
|
||||
fn main() {
|
||||
let bar: u8 = 12;
|
||||
bar.<|>
|
||||
bar.$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -392,7 +392,7 @@ fn main() {
|
|||
check(
|
||||
r#"
|
||||
fn main() {
|
||||
baz.l<|>
|
||||
baz.l$0
|
||||
res
|
||||
}
|
||||
"#,
|
||||
|
@ -424,7 +424,7 @@ enum Option<T> { Some(T), None }
|
|||
|
||||
fn main() {
|
||||
let bar = Option::Some(true);
|
||||
bar.<|>
|
||||
bar.$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -449,7 +449,7 @@ enum Result<T, E> { Ok(T), Err(E) }
|
|||
|
||||
fn main() {
|
||||
let bar = Result::Ok(true);
|
||||
bar.<|>
|
||||
bar.$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -468,7 +468,7 @@ fn main() {
|
|||
|
||||
#[test]
|
||||
fn postfix_completion_works_for_ambiguous_float_literal() {
|
||||
check_edit("refm", r#"fn main() { 42.<|> }"#, r#"fn main() { &mut 42 }"#)
|
||||
check_edit("refm", r#"fn main() { 42.$0 }"#, r#"fn main() { &mut 42 }"#)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -479,7 +479,7 @@ fn main() {
|
|||
macro_rules! m { ($e:expr) => { $e } }
|
||||
fn main() {
|
||||
let bar: u8 = 12;
|
||||
m!(bar.d<|>)
|
||||
m!(bar.d$0)
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -494,55 +494,47 @@ fn main() {
|
|||
|
||||
#[test]
|
||||
fn postfix_completion_for_references() {
|
||||
check_edit("dbg", r#"fn main() { &&42.<|> }"#, r#"fn main() { dbg!(&&42) }"#);
|
||||
check_edit("refm", r#"fn main() { &&42.<|> }"#, r#"fn main() { &&&mut 42 }"#);
|
||||
check_edit("dbg", r#"fn main() { &&42.$0 }"#, r#"fn main() { dbg!(&&42) }"#);
|
||||
check_edit("refm", r#"fn main() { &&42.$0 }"#, r#"fn main() { &&&mut 42 }"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn postfix_completion_for_format_like_strings() {
|
||||
check_edit(
|
||||
"format",
|
||||
r#"fn main() { "{some_var:?}".<|> }"#,
|
||||
r#"fn main() { "{some_var:?}".$0 }"#,
|
||||
r#"fn main() { format!("{:?}", some_var) }"#,
|
||||
);
|
||||
check_edit(
|
||||
"panic",
|
||||
r#"fn main() { "Panic with {a}".<|> }"#,
|
||||
r#"fn main() { "Panic with {a}".$0 }"#,
|
||||
r#"fn main() { panic!("Panic with {}", a) }"#,
|
||||
);
|
||||
check_edit(
|
||||
"println",
|
||||
r#"fn main() { "{ 2+2 } { SomeStruct { val: 1, other: 32 } :?}".<|> }"#,
|
||||
r#"fn main() { "{ 2+2 } { SomeStruct { val: 1, other: 32 } :?}".$0 }"#,
|
||||
r#"fn main() { println!("{} {:?}", 2+2, SomeStruct { val: 1, other: 32 }) }"#,
|
||||
);
|
||||
check_edit(
|
||||
"loge",
|
||||
r#"fn main() { "{2+2}".<|> }"#,
|
||||
r#"fn main() { "{2+2}".$0 }"#,
|
||||
r#"fn main() { log::error!("{}", 2+2) }"#,
|
||||
);
|
||||
check_edit(
|
||||
"logt",
|
||||
r#"fn main() { "{2+2}".<|> }"#,
|
||||
r#"fn main() { "{2+2}".$0 }"#,
|
||||
r#"fn main() { log::trace!("{}", 2+2) }"#,
|
||||
);
|
||||
check_edit(
|
||||
"logd",
|
||||
r#"fn main() { "{2+2}".<|> }"#,
|
||||
r#"fn main() { "{2+2}".$0 }"#,
|
||||
r#"fn main() { log::debug!("{}", 2+2) }"#,
|
||||
);
|
||||
check_edit(
|
||||
"logi",
|
||||
r#"fn main() { "{2+2}".<|> }"#,
|
||||
r#"fn main() { log::info!("{}", 2+2) }"#,
|
||||
);
|
||||
check_edit(
|
||||
"logw",
|
||||
r#"fn main() { "{2+2}".<|> }"#,
|
||||
r#"fn main() { log::warn!("{}", 2+2) }"#,
|
||||
);
|
||||
check_edit("logi", r#"fn main() { "{2+2}".$0 }"#, r#"fn main() { log::info!("{}", 2+2) }"#);
|
||||
check_edit("logw", r#"fn main() { "{2+2}".$0 }"#, r#"fn main() { log::warn!("{}", 2+2) }"#);
|
||||
check_edit(
|
||||
"loge",
|
||||
r#"fn main() { "{2+2}".<|> }"#,
|
||||
r#"fn main() { "{2+2}".$0 }"#,
|
||||
r#"fn main() { log::error!("{}", 2+2) }"#,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//! Completion of paths, i.e. `some::prefix::<|>`.
|
||||
//! Completion of paths, i.e. `some::prefix::$0`.
|
||||
|
||||
use hir::{Adt, HasVisibility, PathResolution, ScopeDef};
|
||||
use rustc_hash::FxHashSet;
|
||||
|
@ -38,7 +38,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
|
|||
if let ScopeDef::Unknown = def {
|
||||
if let Some(name_ref) = ctx.name_ref_syntax.as_ref() {
|
||||
if name_ref.syntax().text() == name.to_string().as_str() {
|
||||
// for `use self::foo<|>`, don't suggest `foo` as a completion
|
||||
// for `use self::foo$0`, don't suggest `foo` as a completion
|
||||
mark::hit!(dont_complete_current_use);
|
||||
continue;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ mod tests {
|
|||
#[test]
|
||||
fn dont_complete_current_use() {
|
||||
mark::check!(dont_complete_current_use);
|
||||
check(r#"use self::foo<|>;"#, expect![[""]]);
|
||||
check(r#"use self::foo$0;"#, expect![[""]]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -181,7 +181,7 @@ mod tests {
|
|||
check(
|
||||
r#"
|
||||
mod foo { pub struct S; }
|
||||
use self::{foo::*, bar<|>};
|
||||
use self::{foo::*, bar$0};
|
||||
"#,
|
||||
expect![[r#"
|
||||
st S
|
||||
|
@ -192,18 +192,18 @@ use self::{foo::*, bar<|>};
|
|||
|
||||
#[test]
|
||||
fn dont_complete_primitive_in_use() {
|
||||
check_builtin(r#"use self::<|>;"#, expect![[""]]);
|
||||
check_builtin(r#"use self::$0;"#, expect![[""]]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dont_complete_primitive_in_module_scope() {
|
||||
check_builtin(r#"fn foo() { self::<|> }"#, expect![[""]]);
|
||||
check_builtin(r#"fn foo() { self::$0 }"#, expect![[""]]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_primitives() {
|
||||
check_builtin(
|
||||
r#"fn main() { let _: <|> = 92; }"#,
|
||||
r#"fn main() { let _: $0 = 92; }"#,
|
||||
expect![[r#"
|
||||
bt u32
|
||||
bt bool
|
||||
|
@ -230,7 +230,7 @@ use self::{foo::*, bar<|>};
|
|||
fn completes_mod_with_same_name_as_function() {
|
||||
check(
|
||||
r#"
|
||||
use self::my::<|>;
|
||||
use self::my::$0;
|
||||
|
||||
mod my { pub struct Bar; }
|
||||
fn my() {}
|
||||
|
@ -245,7 +245,7 @@ fn my() {}
|
|||
fn filters_visibility() {
|
||||
check(
|
||||
r#"
|
||||
use self::my::<|>;
|
||||
use self::my::$0;
|
||||
|
||||
mod my {
|
||||
struct Bar;
|
||||
|
@ -264,7 +264,7 @@ mod my {
|
|||
fn completes_use_item_starting_with_self() {
|
||||
check(
|
||||
r#"
|
||||
use self::m::<|>;
|
||||
use self::m::$0;
|
||||
|
||||
mod m { pub struct Bar; }
|
||||
"#,
|
||||
|
@ -282,7 +282,7 @@ mod m { pub struct Bar; }
|
|||
mod foo;
|
||||
struct Spam;
|
||||
//- /foo.rs
|
||||
use crate::Sp<|>
|
||||
use crate::Sp$0
|
||||
"#,
|
||||
expect![[r#"
|
||||
md foo
|
||||
|
@ -299,7 +299,7 @@ use crate::Sp<|>
|
|||
mod foo;
|
||||
struct Spam;
|
||||
//- /foo.rs
|
||||
use crate::{Sp<|>};
|
||||
use crate::{Sp$0};
|
||||
"#,
|
||||
expect![[r#"
|
||||
md foo
|
||||
|
@ -320,7 +320,7 @@ pub mod bar {
|
|||
}
|
||||
}
|
||||
//- /foo.rs
|
||||
use crate::{bar::{baz::Sp<|>}};
|
||||
use crate::{bar::{baz::Sp$0}};
|
||||
"#,
|
||||
expect![[r#"
|
||||
st Spam
|
||||
|
@ -333,7 +333,7 @@ use crate::{bar::{baz::Sp<|>}};
|
|||
check(
|
||||
r#"
|
||||
enum E { Foo, Bar(i32) }
|
||||
fn foo() { let _ = E::<|> }
|
||||
fn foo() { let _ = E::$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
ev Foo ()
|
||||
|
@ -356,7 +356,7 @@ impl S {
|
|||
type T = i32;
|
||||
}
|
||||
|
||||
fn foo() { let _ = S::<|> }
|
||||
fn foo() { let _ = S::$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn a() fn a()
|
||||
|
@ -384,7 +384,7 @@ mod m {
|
|||
}
|
||||
}
|
||||
|
||||
fn foo() { let _ = S::<|> }
|
||||
fn foo() { let _ = S::$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn public_method() pub(crate) fn public_method()
|
||||
|
@ -401,7 +401,7 @@ fn foo() { let _ = S::<|> }
|
|||
enum E {};
|
||||
impl E { fn m() { } }
|
||||
|
||||
fn foo() { let _ = E::<|> }
|
||||
fn foo() { let _ = E::$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn m() fn m()
|
||||
|
@ -416,7 +416,7 @@ fn foo() { let _ = E::<|> }
|
|||
union U {};
|
||||
impl U { fn m() { } }
|
||||
|
||||
fn foo() { let _ = U::<|> }
|
||||
fn foo() { let _ = U::$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn m() fn m()
|
||||
|
@ -429,7 +429,7 @@ fn foo() { let _ = U::<|> }
|
|||
check(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:foo
|
||||
use foo::<|>;
|
||||
use foo::$0;
|
||||
|
||||
//- /foo/lib.rs crate:foo
|
||||
pub mod bar { pub struct S; }
|
||||
|
@ -446,7 +446,7 @@ pub mod bar { pub struct S; }
|
|||
r#"
|
||||
trait Trait { fn m(); }
|
||||
|
||||
fn foo() { let _ = Trait::<|> }
|
||||
fn foo() { let _ = Trait::$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn m() fn m()
|
||||
|
@ -463,7 +463,7 @@ trait Trait { fn m(); }
|
|||
struct S;
|
||||
impl Trait for S {}
|
||||
|
||||
fn foo() { let _ = S::<|> }
|
||||
fn foo() { let _ = S::$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn m() fn m()
|
||||
|
@ -480,7 +480,7 @@ trait Trait { fn m(); }
|
|||
struct S;
|
||||
impl Trait for S {}
|
||||
|
||||
fn foo() { let _ = <S as Trait>::<|> }
|
||||
fn foo() { let _ = <S as Trait>::$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn m() fn m()
|
||||
|
@ -506,7 +506,7 @@ trait Sub: Super {
|
|||
fn submethod(&self) {}
|
||||
}
|
||||
|
||||
fn foo<T: Sub>() { T::<|> }
|
||||
fn foo<T: Sub>() { T::$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
ta SubTy type SubTy;
|
||||
|
@ -544,7 +544,7 @@ impl<T> Super for Wrap<T> {}
|
|||
impl<T> Sub for Wrap<T> {
|
||||
fn subfunc() {
|
||||
// Should be able to assume `Self: Sub + Super`
|
||||
Self::<|>
|
||||
Self::$0
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
@ -570,7 +570,7 @@ impl S { fn foo() {} }
|
|||
type T = S;
|
||||
impl T { fn bar() {} }
|
||||
|
||||
fn main() { T::<|>; }
|
||||
fn main() { T::$0; }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn foo() fn foo()
|
||||
|
@ -586,7 +586,7 @@ fn main() { T::<|>; }
|
|||
#[macro_export]
|
||||
macro_rules! foo { () => {} }
|
||||
|
||||
fn main() { let _ = crate::<|> }
|
||||
fn main() { let _ = crate::$0 }
|
||||
"#,
|
||||
expect![[r##"
|
||||
fn main() fn main()
|
||||
|
@ -604,7 +604,7 @@ mod a {
|
|||
const A: usize = 0;
|
||||
mod b {
|
||||
const B: usize = 0;
|
||||
mod c { use super::super::<|> }
|
||||
mod c { use super::super::$0 }
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
@ -619,7 +619,7 @@ mod a {
|
|||
fn completes_reexported_items_under_correct_name() {
|
||||
check(
|
||||
r#"
|
||||
fn foo() { self::m::<|> }
|
||||
fn foo() { self::m::$0 }
|
||||
|
||||
mod m {
|
||||
pub use super::p::wrong_fn as right_fn;
|
||||
|
@ -642,7 +642,7 @@ mod p {
|
|||
check_edit(
|
||||
"RightType",
|
||||
r#"
|
||||
fn foo() { self::m::<|> }
|
||||
fn foo() { self::m::$0 }
|
||||
|
||||
mod m {
|
||||
pub use super::p::wrong_fn as right_fn;
|
||||
|
@ -677,7 +677,7 @@ mod p {
|
|||
check(
|
||||
r#"
|
||||
macro_rules! m { ($e:expr) => { $e } }
|
||||
fn main() { m!(self::f<|>); }
|
||||
fn main() { m!(self::f$0); }
|
||||
fn foo() {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -691,7 +691,7 @@ fn foo() {}
|
|||
fn function_mod_share_name() {
|
||||
check(
|
||||
r#"
|
||||
fn foo() { self::m::<|> }
|
||||
fn foo() { self::m::$0 }
|
||||
|
||||
mod m {
|
||||
pub mod z {}
|
||||
|
@ -716,7 +716,7 @@ impl<K, V> HashMap<K, V, RandomState> {
|
|||
pub fn new() -> HashMap<K, V, RandomState> { }
|
||||
}
|
||||
fn foo() {
|
||||
HashMap::<|>
|
||||
HashMap::$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -730,7 +730,7 @@ fn foo() {
|
|||
check(
|
||||
r#"
|
||||
mod foo { pub struct Foo; }
|
||||
#[foo::<|>]
|
||||
#[foo::$0]
|
||||
fn f() {}
|
||||
"#,
|
||||
expect![[""]],
|
||||
|
@ -749,7 +749,7 @@ fn foo(
|
|||
}
|
||||
|
||||
fn main() {
|
||||
fo<|>
|
||||
fo$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -770,7 +770,7 @@ enum Foo {
|
|||
|
||||
impl Foo {
|
||||
fn foo(self) {
|
||||
Self::<|>
|
||||
Self::$0
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
|
|
@ -99,7 +99,7 @@ impl core::default::Default for S {
|
|||
fn process(f: S) {
|
||||
let other = S {
|
||||
foo: 5,
|
||||
.<|>
|
||||
.$0
|
||||
};
|
||||
}
|
||||
"#;
|
||||
|
@ -139,7 +139,7 @@ impl core::default::Default for S {
|
|||
fn process(f: S) {
|
||||
let other = S {
|
||||
foo: 5,
|
||||
.<|>
|
||||
.$0
|
||||
};
|
||||
}
|
||||
"#,
|
||||
|
@ -173,7 +173,7 @@ struct S { foo: u32, bar: usize }
|
|||
fn process(f: S) {
|
||||
let other = S {
|
||||
foo: 5,
|
||||
.<|>
|
||||
.$0
|
||||
};
|
||||
}
|
||||
"#;
|
||||
|
@ -201,7 +201,7 @@ struct S { foo: u32 }
|
|||
|
||||
fn process(f: S) {
|
||||
match f {
|
||||
S { f<|>: 92 } => (),
|
||||
S { f$0: 92 } => (),
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
@ -219,7 +219,7 @@ enum E { S { foo: u32, bar: () } }
|
|||
|
||||
fn process(e: E) {
|
||||
match e {
|
||||
E::S { <|> } => (),
|
||||
E::S { $0 } => (),
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
@ -239,7 +239,7 @@ struct S { foo: u32 }
|
|||
|
||||
fn process(f: S) {
|
||||
m!(match f {
|
||||
S { f<|>: 92 } => (),
|
||||
S { f$0: 92 } => (),
|
||||
})
|
||||
}
|
||||
",
|
||||
|
@ -263,7 +263,7 @@ fn main() {
|
|||
foo1: 1, foo2: 2,
|
||||
bar: 3, baz: 4,
|
||||
};
|
||||
if let S { foo1, foo2: a, <|> } = s {}
|
||||
if let S { foo1, foo2: a, $0 } = s {}
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -279,7 +279,7 @@ fn main() {
|
|||
r#"
|
||||
struct A { the_field: u32 }
|
||||
fn foo() {
|
||||
A { the<|> }
|
||||
A { the$0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -294,7 +294,7 @@ fn foo() {
|
|||
r#"
|
||||
enum E { A { a: u32 } }
|
||||
fn foo() {
|
||||
let _ = E::A { <|> }
|
||||
let _ = E::A { $0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -311,7 +311,7 @@ struct A { a: u32 }
|
|||
struct B { b: u32 }
|
||||
|
||||
fn foo() {
|
||||
let _: A = B { <|> }
|
||||
let _: A = B { $0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -327,7 +327,7 @@ fn foo() {
|
|||
struct A<T> { a: T }
|
||||
|
||||
fn foo() {
|
||||
let _: A<u32> = A { <|> }
|
||||
let _: A<u32> = A { $0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -343,7 +343,7 @@ fn foo() {
|
|||
macro_rules! m { ($e:expr) => { $e } }
|
||||
struct A { the_field: u32 }
|
||||
fn foo() {
|
||||
m!(A { the<|> })
|
||||
m!(A { the$0 })
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -363,7 +363,7 @@ struct S {
|
|||
|
||||
fn main() {
|
||||
let foo1 = 1;
|
||||
let s = S { foo1, foo2: 5, <|> }
|
||||
let s = S { foo1, foo2: 5, $0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -381,7 +381,7 @@ struct S { foo1: u32, foo2: u32 }
|
|||
|
||||
fn main() {
|
||||
let foo1 = 1;
|
||||
let s = S { foo1, <|> .. loop {} }
|
||||
let s = S { foo1, $0 .. loop {} }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
|
|
@ -83,7 +83,7 @@ mod tests {
|
|||
#[test]
|
||||
fn completes_snippets_in_expressions() {
|
||||
check(
|
||||
r#"fn foo(x: i32) { <|> }"#,
|
||||
r#"fn foo(x: i32) { $0 }"#,
|
||||
expect![[r#"
|
||||
sn pd
|
||||
sn ppd
|
||||
|
@ -93,8 +93,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn should_not_complete_snippets_in_path() {
|
||||
check(r#"fn foo(x: i32) { ::foo<|> }"#, expect![[""]]);
|
||||
check(r#"fn foo(x: i32) { ::<|> }"#, expect![[""]]);
|
||||
check(r#"fn foo(x: i32) { ::foo$0 }"#, expect![[""]]);
|
||||
check(r#"fn foo(x: i32) { ::$0 }"#, expect![[""]]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -103,7 +103,7 @@ mod tests {
|
|||
r#"
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
<|>
|
||||
$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
//! }
|
||||
//!
|
||||
//! impl SomeTrait for () {
|
||||
//! fn f<|>
|
||||
//! fn f$0
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
|
@ -27,7 +27,7 @@
|
|||
//! # }
|
||||
//!
|
||||
//! impl SomeTrait for () {
|
||||
//! fn foo() {}<|>
|
||||
//! fn foo() {}$0
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
|
@ -82,7 +82,7 @@ pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext
|
|||
|
||||
fn completion_match(ctx: &CompletionContext) -> Option<(ImplCompletionKind, SyntaxNode, Impl)> {
|
||||
let mut token = ctx.token.clone();
|
||||
// For keywork without name like `impl .. { fn <|> }`, the current position is inside
|
||||
// For keywork without name like `impl .. { fn $0 }`, the current position is inside
|
||||
// the whitespace token, which is outside `FN` syntax node.
|
||||
// We need to follow the previous token in this case.
|
||||
if token.kind() == SyntaxKind::WHITESPACE {
|
||||
|
@ -90,20 +90,20 @@ fn completion_match(ctx: &CompletionContext) -> Option<(ImplCompletionKind, Synt
|
|||
}
|
||||
|
||||
let impl_item_offset = match token.kind() {
|
||||
// `impl .. { const <|> }`
|
||||
// `impl .. { const $0 }`
|
||||
// ERROR 0
|
||||
// CONST_KW <- *
|
||||
SyntaxKind::CONST_KW => 0,
|
||||
// `impl .. { fn/type <|> }`
|
||||
// `impl .. { fn/type $0 }`
|
||||
// FN/TYPE_ALIAS 0
|
||||
// FN_KW <- *
|
||||
SyntaxKind::FN_KW | SyntaxKind::TYPE_KW => 0,
|
||||
// `impl .. { fn/type/const foo<|> }`
|
||||
// `impl .. { fn/type/const foo$0 }`
|
||||
// FN/TYPE_ALIAS/CONST 1
|
||||
// NAME 0
|
||||
// IDENT <- *
|
||||
SyntaxKind::IDENT if token.parent().kind() == SyntaxKind::NAME => 1,
|
||||
// `impl .. { foo<|> }`
|
||||
// `impl .. { foo$0 }`
|
||||
// MACRO_CALL 3
|
||||
// PATH 2
|
||||
// PATH_SEGMENT 1
|
||||
|
@ -120,7 +120,7 @@ fn completion_match(ctx: &CompletionContext) -> Option<(ImplCompletionKind, Synt
|
|||
// <item>
|
||||
let impl_def = ast::Impl::cast(impl_item.parent()?.parent()?)?;
|
||||
let kind = match impl_item.kind() {
|
||||
// `impl ... { const <|> fn/type/const }`
|
||||
// `impl ... { const $0 fn/type/const }`
|
||||
_ if token.kind() == SyntaxKind::CONST_KW => ImplCompletionKind::Const,
|
||||
SyntaxKind::CONST | SyntaxKind::ERROR => ImplCompletionKind::Const,
|
||||
SyntaxKind::TYPE_ALIAS => ImplCompletionKind::TypeAlias,
|
||||
|
@ -267,7 +267,7 @@ trait Test {
|
|||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
t<|>
|
||||
t$0
|
||||
}
|
||||
"#,
|
||||
expect![["
|
||||
|
@ -287,7 +287,7 @@ struct T;
|
|||
|
||||
impl Test for T {
|
||||
fn test() {
|
||||
t<|>
|
||||
t$0
|
||||
}
|
||||
}
|
||||
",
|
||||
|
@ -301,7 +301,7 @@ struct T;
|
|||
|
||||
impl Test for T {
|
||||
fn test() {
|
||||
fn t<|>
|
||||
fn t$0
|
||||
}
|
||||
}
|
||||
",
|
||||
|
@ -315,7 +315,7 @@ struct T;
|
|||
|
||||
impl Test for T {
|
||||
fn test() {
|
||||
fn <|>
|
||||
fn $0
|
||||
}
|
||||
}
|
||||
",
|
||||
|
@ -330,7 +330,7 @@ struct T;
|
|||
|
||||
impl Test for T {
|
||||
fn test() {
|
||||
foo.<|>
|
||||
foo.$0
|
||||
}
|
||||
}
|
||||
",
|
||||
|
@ -343,7 +343,7 @@ trait Test { fn test(_: i32); fn test2(); }
|
|||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
fn test(t<|>)
|
||||
fn test(t$0)
|
||||
}
|
||||
",
|
||||
expect![[""]],
|
||||
|
@ -355,7 +355,7 @@ trait Test { fn test(_: fn()); fn test2(); }
|
|||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
fn test(f: fn <|>)
|
||||
fn test(f: fn $0)
|
||||
}
|
||||
",
|
||||
expect![[""]],
|
||||
|
@ -370,7 +370,7 @@ trait Test { const TEST: fn(); const TEST2: u32; type Test; fn test(); }
|
|||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
const TEST: fn <|>
|
||||
const TEST: fn $0
|
||||
}
|
||||
",
|
||||
expect![[""]],
|
||||
|
@ -382,7 +382,7 @@ trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
|
|||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
const TEST: T<|>
|
||||
const TEST: T$0
|
||||
}
|
||||
",
|
||||
expect![[""]],
|
||||
|
@ -394,7 +394,7 @@ trait Test { const TEST: u32; const TEST2: u32; type Test; fn test(); }
|
|||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
const TEST: u32 = f<|>
|
||||
const TEST: u32 = f$0
|
||||
}
|
||||
",
|
||||
expect![[""]],
|
||||
|
@ -407,7 +407,7 @@ struct T;
|
|||
|
||||
impl Test for T {
|
||||
const TEST: u32 = {
|
||||
t<|>
|
||||
t$0
|
||||
};
|
||||
}
|
||||
",
|
||||
|
@ -421,7 +421,7 @@ struct T;
|
|||
|
||||
impl Test for T {
|
||||
const TEST: u32 = {
|
||||
fn <|>
|
||||
fn $0
|
||||
};
|
||||
}
|
||||
",
|
||||
|
@ -435,7 +435,7 @@ struct T;
|
|||
|
||||
impl Test for T {
|
||||
const TEST: u32 = {
|
||||
fn t<|>
|
||||
fn t$0
|
||||
};
|
||||
}
|
||||
",
|
||||
|
@ -451,7 +451,7 @@ trait Test { type Test; type Test2; fn test(); }
|
|||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
type Test = T<|>;
|
||||
type Test = T$0;
|
||||
}
|
||||
",
|
||||
expect![[""]],
|
||||
|
@ -463,7 +463,7 @@ trait Test { type Test; type Test2; fn test(); }
|
|||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
type Test = fn <|>;
|
||||
type Test = fn $0;
|
||||
}
|
||||
",
|
||||
expect![[""]],
|
||||
|
@ -481,7 +481,7 @@ trait Test {
|
|||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
t<|>
|
||||
t$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -510,7 +510,7 @@ trait Test {
|
|||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
fn t<|>
|
||||
fn t$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -540,7 +540,7 @@ struct T;
|
|||
|
||||
impl Test for T {
|
||||
fn foo() {}
|
||||
fn f<|>
|
||||
fn f$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -560,7 +560,7 @@ trait Test {
|
|||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
fn f<|>
|
||||
fn f$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -585,7 +585,7 @@ trait Test {
|
|||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
fn f<|>
|
||||
fn f$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -614,7 +614,7 @@ trait Test {
|
|||
}
|
||||
|
||||
impl Test for () {
|
||||
type S<|>
|
||||
type S$0
|
||||
}
|
||||
"#,
|
||||
"
|
||||
|
@ -639,7 +639,7 @@ trait Test {
|
|||
}
|
||||
|
||||
impl Test for () {
|
||||
const S<|>
|
||||
const S$0
|
||||
}
|
||||
"#,
|
||||
"
|
||||
|
@ -661,7 +661,7 @@ trait Test {
|
|||
}
|
||||
|
||||
impl Test for () {
|
||||
const S<|>
|
||||
const S$0
|
||||
}
|
||||
"#,
|
||||
"
|
||||
|
@ -724,7 +724,7 @@ impl Test for T {{
|
|||
// Enumerate some possible next siblings.
|
||||
for next_sibling in &[
|
||||
"",
|
||||
"fn other_fn() {}", // `const <|> fn` -> `const fn`
|
||||
"fn other_fn() {}", // `const $0 fn` -> `const fn`
|
||||
"type OtherType = i32;",
|
||||
"const OTHER_CONST: i32 = 0;",
|
||||
"async fn other_fn() {}",
|
||||
|
@ -733,9 +733,9 @@ impl Test for T {{
|
|||
"default type OtherType = i32;",
|
||||
"default const OTHER_CONST: i32 = 0;",
|
||||
] {
|
||||
test("bar", "fn <|>", "fn bar() {\n $0\n}", next_sibling);
|
||||
test("Foo", "type <|>", "type Foo = ", next_sibling);
|
||||
test("CONST", "const <|>", "const CONST: u16 = ", next_sibling);
|
||||
test("bar", "fn $0", "fn bar() {\n $0\n}", next_sibling);
|
||||
test("Foo", "type $0", "type Foo = ", next_sibling);
|
||||
test("CONST", "const $0", "const CONST: u16 = ", next_sibling);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T
|
|||
//
|
||||
// ```
|
||||
// fn main() {
|
||||
// pda<|>
|
||||
// pda$0
|
||||
// }
|
||||
// # pub mod std { pub mod marker { pub struct PhantomData { } } }
|
||||
// ```
|
||||
|
@ -212,7 +212,7 @@ mod tests {
|
|||
mark::check!(self_fulfilling_completion);
|
||||
check(
|
||||
r#"
|
||||
use foo<|>
|
||||
use foo$0
|
||||
use std::collections;
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -229,7 +229,7 @@ enum Enum { A, B }
|
|||
fn quux(x: Option<Enum>) {
|
||||
match x {
|
||||
None => (),
|
||||
Some(en<|> @ Enum::A) => (),
|
||||
Some(en$0 @ Enum::A) => (),
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
@ -245,7 +245,7 @@ enum Enum { A, B }
|
|||
fn quux(x: Option<Enum>) {
|
||||
match x {
|
||||
None => (),
|
||||
Some(ref en<|>) => (),
|
||||
Some(ref en$0) => (),
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
@ -261,7 +261,7 @@ enum Enum { A, B }
|
|||
fn quux(x: Option<Enum>) {
|
||||
match x {
|
||||
None => (),
|
||||
Some(En<|>) => (),
|
||||
Some(En$0) => (),
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
@ -277,7 +277,7 @@ fn quux(x: Option<Enum>) {
|
|||
r#"
|
||||
fn quux(x: i32) {
|
||||
let y = 92;
|
||||
1 + <|>;
|
||||
1 + $0;
|
||||
let z = ();
|
||||
}
|
||||
"#,
|
||||
|
@ -299,7 +299,7 @@ fn quux() {
|
|||
};
|
||||
if let Some(a) = bar() {
|
||||
let b = 62;
|
||||
1 + <|>
|
||||
1 + $0
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
@ -316,7 +316,7 @@ fn quux() {
|
|||
check(
|
||||
r#"
|
||||
fn quux() {
|
||||
for x in &[1, 2, 3] { <|> }
|
||||
for x in &[1, 2, 3] { $0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -334,7 +334,7 @@ fn quux() {
|
|||
r#"
|
||||
fn main() {
|
||||
let wherewolf = 92;
|
||||
drop(where<|>)
|
||||
drop(where$0)
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -349,7 +349,7 @@ fn main() {
|
|||
#[test]
|
||||
fn completes_generic_params() {
|
||||
check(
|
||||
r#"fn quux<T>() { <|> }"#,
|
||||
r#"fn quux<T>() { $0 }"#,
|
||||
expect![[r#"
|
||||
tp T
|
||||
fn quux() fn quux<T>()
|
||||
|
@ -360,7 +360,7 @@ fn main() {
|
|||
#[test]
|
||||
fn completes_generic_params_in_struct() {
|
||||
check(
|
||||
r#"struct S<T> { x: <|>}"#,
|
||||
r#"struct S<T> { x: $0}"#,
|
||||
expect![[r#"
|
||||
tp Self
|
||||
tp T
|
||||
|
@ -372,7 +372,7 @@ fn main() {
|
|||
#[test]
|
||||
fn completes_self_in_enum() {
|
||||
check(
|
||||
r#"enum X { Y(<|>) }"#,
|
||||
r#"enum X { Y($0) }"#,
|
||||
expect![[r#"
|
||||
tp Self
|
||||
en X
|
||||
|
@ -386,7 +386,7 @@ fn main() {
|
|||
r#"
|
||||
struct S;
|
||||
enum E {}
|
||||
fn quux() { <|> }
|
||||
fn quux() { $0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
st S
|
||||
|
@ -403,7 +403,7 @@ fn quux() { <|> }
|
|||
"_alpha",
|
||||
r#"
|
||||
fn main() {
|
||||
_<|>
|
||||
_$0
|
||||
}
|
||||
fn _alpha() {}
|
||||
"#,
|
||||
|
@ -421,7 +421,7 @@ fn _alpha() {}
|
|||
check(
|
||||
r#"
|
||||
//- /lib.rs crate:main deps:other_crate
|
||||
use <|>;
|
||||
use $0;
|
||||
|
||||
//- /other_crate/lib.rs crate:other_crate
|
||||
// nothing here
|
||||
|
@ -439,7 +439,7 @@ use <|>;
|
|||
struct Foo;
|
||||
mod m {
|
||||
struct Bar;
|
||||
fn quux() { <|> }
|
||||
fn quux() { $0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -454,7 +454,7 @@ mod m {
|
|||
check(
|
||||
r#"
|
||||
struct Foo;
|
||||
fn x() -> <|>
|
||||
fn x() -> $0
|
||||
"#,
|
||||
expect![[r#"
|
||||
st Foo
|
||||
|
@ -471,7 +471,7 @@ fn foo() {
|
|||
let bar = 92;
|
||||
{
|
||||
let bar = 62;
|
||||
drop(<|>)
|
||||
drop($0)
|
||||
}
|
||||
}
|
||||
"#,
|
||||
|
@ -487,7 +487,7 @@ fn foo() {
|
|||
#[test]
|
||||
fn completes_self_in_methods() {
|
||||
check(
|
||||
r#"impl S { fn foo(&self) { <|> } }"#,
|
||||
r#"impl S { fn foo(&self) { $0 } }"#,
|
||||
expect![[r#"
|
||||
bn self &{unknown}
|
||||
tp Self
|
||||
|
@ -500,7 +500,7 @@ fn foo() {
|
|||
check(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:std
|
||||
fn foo() { let x: <|> }
|
||||
fn foo() { let x: $0 }
|
||||
|
||||
//- /std/lib.rs crate:std
|
||||
#[prelude_import]
|
||||
|
@ -521,7 +521,7 @@ mod prelude { struct Option; }
|
|||
check(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:core,std
|
||||
fn foo() { let x: <|> }
|
||||
fn foo() { let x: $0 }
|
||||
|
||||
//- /core/lib.rs crate:core
|
||||
#[prelude_import]
|
||||
|
@ -562,7 +562,7 @@ mod m2 {
|
|||
macro_rules! baz { () => {} }
|
||||
}
|
||||
|
||||
fn main() { let v = <|> }
|
||||
fn main() { let v = $0 }
|
||||
"#,
|
||||
expect![[r##"
|
||||
md m1
|
||||
|
@ -581,7 +581,7 @@ fn main() { let v = <|> }
|
|||
check(
|
||||
r#"
|
||||
macro_rules! foo { () => {} }
|
||||
fn foo() { <|> }
|
||||
fn foo() { $0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn foo() fn foo()
|
||||
|
@ -595,7 +595,7 @@ fn foo() { <|> }
|
|||
check(
|
||||
r#"
|
||||
macro_rules! foo { () => {} }
|
||||
fn main() { let x: <|> }
|
||||
fn main() { let x: $0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn main() fn main()
|
||||
|
@ -609,7 +609,7 @@ fn main() { let x: <|> }
|
|||
check(
|
||||
r#"
|
||||
macro_rules! foo { () => {} }
|
||||
fn main() { <|> }
|
||||
fn main() { $0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn main() fn main()
|
||||
|
@ -623,7 +623,7 @@ fn main() { <|> }
|
|||
check(
|
||||
r#"
|
||||
fn main() {
|
||||
return f<|>;
|
||||
return f$0;
|
||||
fn frobnicate() {}
|
||||
}
|
||||
"#,
|
||||
|
@ -641,7 +641,7 @@ fn main() {
|
|||
macro_rules! m { ($e:expr) => { $e } }
|
||||
fn quux(x: i32) {
|
||||
let y = 92;
|
||||
m!(<|>);
|
||||
m!($0);
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -660,7 +660,7 @@ fn quux(x: i32) {
|
|||
macro_rules! m { ($e:expr) => { $e } }
|
||||
fn quux(x: i32) {
|
||||
let y = 92;
|
||||
m!(x<|>);
|
||||
m!(x$0);
|
||||
}
|
||||
",
|
||||
expect![[r#"
|
||||
|
@ -679,7 +679,7 @@ fn quux(x: i32) {
|
|||
macro_rules! m { ($e:expr) => { $e } }
|
||||
fn quux(x: i32) {
|
||||
let y = 92;
|
||||
m!(x<|>
|
||||
m!(x$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -697,7 +697,7 @@ fn quux(x: i32) {
|
|||
r#"
|
||||
use spam::Quux;
|
||||
|
||||
fn main() { <|> }
|
||||
fn main() { $0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn main() fn main()
|
||||
|
@ -714,7 +714,7 @@ enum Foo { Bar, Baz, Quux }
|
|||
|
||||
fn main() {
|
||||
let foo = Foo::Quux;
|
||||
match foo { Qu<|> }
|
||||
match foo { Qu$0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -734,7 +734,7 @@ enum Foo { Bar, Baz, Quux }
|
|||
|
||||
fn main() {
|
||||
let foo = Foo::Quux;
|
||||
match &foo { Qu<|> }
|
||||
match &foo { Qu$0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -754,7 +754,7 @@ enum Foo { Bar, Baz, Quux }
|
|||
|
||||
fn main() {
|
||||
let foo = Foo::Quux;
|
||||
if let Qu<|> = foo { }
|
||||
if let Qu$0 = foo { }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
@ -771,7 +771,7 @@ fn main() {
|
|||
check(
|
||||
r#"
|
||||
enum Foo { Bar, Baz, Quux }
|
||||
fn main() { let foo: Foo = Q<|> }
|
||||
fn main() { let foo: Foo = Q$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
ev Foo::Bar ()
|
||||
|
@ -788,7 +788,7 @@ fn main() { let foo: Foo = Q<|> }
|
|||
check(
|
||||
r#"
|
||||
mod m { pub enum E { V } }
|
||||
fn f() -> m::E { V<|> }
|
||||
fn f() -> m::E { V$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
ev m::E::V ()
|
||||
|
@ -803,7 +803,7 @@ fn f() -> m::E { V<|> }
|
|||
check(
|
||||
r#"
|
||||
struct Foo;
|
||||
#[<|>]
|
||||
#[$0]
|
||||
fn f() {}
|
||||
"#,
|
||||
expect![[""]],
|
||||
|
@ -817,7 +817,7 @@ fn f() {}
|
|||
trait MyTrait {}
|
||||
struct MyStruct {}
|
||||
|
||||
impl My<|>
|
||||
impl My$0
|
||||
"#,
|
||||
expect![[r#"
|
||||
tp Self
|
||||
|
@ -840,7 +840,7 @@ pub mod io {
|
|||
|
||||
//- /main.rs crate:main deps:dep
|
||||
fn main() {
|
||||
stdi<|>
|
||||
stdi$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -868,7 +868,7 @@ macro_rules! macro_with_curlies {
|
|||
|
||||
//- /main.rs crate:main deps:dep
|
||||
fn main() {
|
||||
curli<|>
|
||||
curli$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -898,7 +898,7 @@ pub mod some_module {
|
|||
use dep::{FirstStruct, some_module::SecondStruct};
|
||||
|
||||
fn main() {
|
||||
this<|>
|
||||
this$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -936,7 +936,7 @@ pub mod some_module {
|
|||
use dep::{FirstStruct, some_module::SecondStruct};
|
||||
|
||||
fn main() {
|
||||
hir<|>
|
||||
hir$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
|
|
|
@ -63,7 +63,7 @@ pub(crate) struct CompletionContext<'a> {
|
|||
pub(super) is_expr: bool,
|
||||
/// Something is typed at the "top" level, in module or impl/trait.
|
||||
pub(super) is_new_item: bool,
|
||||
/// The receiver if this is a field or method access, i.e. writing something.<|>
|
||||
/// The receiver if this is a field or method access, i.e. writing something.$0
|
||||
pub(super) dot_receiver: Option<ast::Expr>,
|
||||
pub(super) dot_receiver_is_ambiguous_float_literal: bool,
|
||||
/// If this is a call (method or function) in particular, i.e. the () are already there.
|
||||
|
@ -228,9 +228,9 @@ impl<'a> CompletionContext<'a> {
|
|||
|
||||
/// Checks whether completions in that particular case don't make much sense.
|
||||
/// Examples:
|
||||
/// - `fn <|>` -- we expect function name, it's unlikely that "hint" will be helpful.
|
||||
/// - `fn $0` -- we expect function name, it's unlikely that "hint" will be helpful.
|
||||
/// Exception for this case is `impl Trait for Foo`, where we would like to hint trait method names.
|
||||
/// - `for _ i<|>` -- obviously, it'll be "in" keyword.
|
||||
/// - `for _ i$0` -- obviously, it'll be "in" keyword.
|
||||
pub(crate) fn no_completion_required(&self) -> bool {
|
||||
(self.fn_is_prev && !self.inside_impl_trait_block) || self.for_is_prev2
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ impl<'a> CompletionContext<'a> {
|
|||
offset: TextSize,
|
||||
) {
|
||||
// FIXME: this is wrong in at least two cases:
|
||||
// * when there's no token `foo(<|>)`
|
||||
// * when there's no token `foo($0)`
|
||||
// * when there is a token, but it happens to have type of it's own
|
||||
self.expected_type = self
|
||||
.token
|
||||
|
|
|
@ -43,7 +43,7 @@ pub struct CompletionItem {
|
|||
/// Lookup is used to check if completion item indeed can complete current
|
||||
/// ident.
|
||||
///
|
||||
/// That is, in `foo.bar<|>` lookup of `abracadabra` will be accepted (it
|
||||
/// That is, in `foo.bar$0` lookup of `abracadabra` will be accepted (it
|
||||
/// contains `bar` sub sequence), and `quux` will rejected.
|
||||
lookup: Option<String>,
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ pub use crate::{
|
|||
// - `expr.while` -> `while expr {}` or `while let ... {}` for `Option` or `Result`
|
||||
// - `expr.ref` -> `&expr`
|
||||
// - `expr.refm` -> `&mut expr`
|
||||
// - `expr.let` -> `let <|> = expr;`
|
||||
// - `expr.letm` -> `let mut <|> = expr;`
|
||||
// - `expr.let` -> `let $0 = expr;`
|
||||
// - `expr.letm` -> `let mut $0 = expr;`
|
||||
// - `expr.not` -> `!expr`
|
||||
// - `expr.dbg` -> `dbg!(expr)`
|
||||
// - `expr.dbgr` -> `dbg!(&expr)`
|
||||
|
@ -92,7 +92,7 @@ pub use crate::{
|
|||
/// ```no_run
|
||||
/// fn f() {
|
||||
/// let foo = 92;
|
||||
/// let _ = bar<|>
|
||||
/// let _ = bar$0
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
@ -220,7 +220,7 @@ mod tests {
|
|||
|
||||
fn foo() {
|
||||
let bar = Bar;
|
||||
bar.fo<|>;
|
||||
bar.fo$0;
|
||||
}
|
||||
"#,
|
||||
DetailAndDocumentation { detail: "fn foo(&self)", documentation: "Do the foo" },
|
||||
|
@ -246,7 +246,7 @@ mod tests {
|
|||
|
||||
fn foo() {
|
||||
let bar = Bar;
|
||||
bar.fo<|>;
|
||||
bar.fo$0;
|
||||
}
|
||||
"#,
|
||||
DetailAndDocumentation { detail: "fn foo(&self)", documentation: " Do the foo" },
|
||||
|
@ -259,7 +259,7 @@ mod tests {
|
|||
check_no_completion(
|
||||
r#"
|
||||
fn foo() {
|
||||
for i i<|>
|
||||
for i i$0
|
||||
}
|
||||
"#,
|
||||
);
|
||||
|
@ -270,7 +270,7 @@ mod tests {
|
|||
fn foo() -> &'static str { "foo" }
|
||||
|
||||
fn bar() {
|
||||
for c in fo<|>
|
||||
for c in fo$0
|
||||
}
|
||||
"#,
|
||||
DetailAndDocumentation {
|
||||
|
|
|
@ -20,7 +20,7 @@ pub(crate) fn has_trait_parent(element: SyntaxElement) -> bool {
|
|||
}
|
||||
#[test]
|
||||
fn test_has_trait_parent() {
|
||||
check_pattern_is_applicable(r"trait A { f<|> }", has_trait_parent);
|
||||
check_pattern_is_applicable(r"trait A { f$0 }", has_trait_parent);
|
||||
}
|
||||
|
||||
pub(crate) fn has_impl_parent(element: SyntaxElement) -> bool {
|
||||
|
@ -32,7 +32,7 @@ pub(crate) fn has_impl_parent(element: SyntaxElement) -> bool {
|
|||
}
|
||||
#[test]
|
||||
fn test_has_impl_parent() {
|
||||
check_pattern_is_applicable(r"impl A { f<|> }", has_impl_parent);
|
||||
check_pattern_is_applicable(r"impl A { f$0 }", has_impl_parent);
|
||||
}
|
||||
|
||||
pub(crate) fn inside_impl_trait_block(element: SyntaxElement) -> bool {
|
||||
|
@ -47,10 +47,10 @@ pub(crate) fn inside_impl_trait_block(element: SyntaxElement) -> bool {
|
|||
}
|
||||
#[test]
|
||||
fn test_inside_impl_trait_block() {
|
||||
check_pattern_is_applicable(r"impl Foo for Bar { f<|> }", inside_impl_trait_block);
|
||||
check_pattern_is_applicable(r"impl Foo for Bar { fn f<|> }", inside_impl_trait_block);
|
||||
check_pattern_is_not_applicable(r"impl A { f<|> }", inside_impl_trait_block);
|
||||
check_pattern_is_not_applicable(r"impl A { fn f<|> }", inside_impl_trait_block);
|
||||
check_pattern_is_applicable(r"impl Foo for Bar { f$0 }", inside_impl_trait_block);
|
||||
check_pattern_is_applicable(r"impl Foo for Bar { fn f$0 }", inside_impl_trait_block);
|
||||
check_pattern_is_not_applicable(r"impl A { f$0 }", inside_impl_trait_block);
|
||||
check_pattern_is_not_applicable(r"impl A { fn f$0 }", inside_impl_trait_block);
|
||||
}
|
||||
|
||||
pub(crate) fn has_field_list_parent(element: SyntaxElement) -> bool {
|
||||
|
@ -58,8 +58,8 @@ pub(crate) fn has_field_list_parent(element: SyntaxElement) -> bool {
|
|||
}
|
||||
#[test]
|
||||
fn test_has_field_list_parent() {
|
||||
check_pattern_is_applicable(r"struct Foo { f<|> }", has_field_list_parent);
|
||||
check_pattern_is_applicable(r"struct Foo { f<|> pub f: i32}", has_field_list_parent);
|
||||
check_pattern_is_applicable(r"struct Foo { f$0 }", has_field_list_parent);
|
||||
check_pattern_is_applicable(r"struct Foo { f$0 pub f: i32}", has_field_list_parent);
|
||||
}
|
||||
|
||||
pub(crate) fn has_block_expr_parent(element: SyntaxElement) -> bool {
|
||||
|
@ -67,7 +67,7 @@ pub(crate) fn has_block_expr_parent(element: SyntaxElement) -> bool {
|
|||
}
|
||||
#[test]
|
||||
fn test_has_block_expr_parent() {
|
||||
check_pattern_is_applicable(r"fn my_fn() { let a = 2; f<|> }", has_block_expr_parent);
|
||||
check_pattern_is_applicable(r"fn my_fn() { let a = 2; f$0 }", has_block_expr_parent);
|
||||
}
|
||||
|
||||
pub(crate) fn has_bind_pat_parent(element: SyntaxElement) -> bool {
|
||||
|
@ -75,8 +75,8 @@ pub(crate) fn has_bind_pat_parent(element: SyntaxElement) -> bool {
|
|||
}
|
||||
#[test]
|
||||
fn test_has_bind_pat_parent() {
|
||||
check_pattern_is_applicable(r"fn my_fn(m<|>) {}", has_bind_pat_parent);
|
||||
check_pattern_is_applicable(r"fn my_fn() { let m<|> }", has_bind_pat_parent);
|
||||
check_pattern_is_applicable(r"fn my_fn(m$0) {}", has_bind_pat_parent);
|
||||
check_pattern_is_applicable(r"fn my_fn() { let m$0 }", has_bind_pat_parent);
|
||||
}
|
||||
|
||||
pub(crate) fn has_ref_parent(element: SyntaxElement) -> bool {
|
||||
|
@ -86,8 +86,8 @@ pub(crate) fn has_ref_parent(element: SyntaxElement) -> bool {
|
|||
}
|
||||
#[test]
|
||||
fn test_has_ref_parent() {
|
||||
check_pattern_is_applicable(r"fn my_fn(&m<|>) {}", has_ref_parent);
|
||||
check_pattern_is_applicable(r"fn my() { let &m<|> }", has_ref_parent);
|
||||
check_pattern_is_applicable(r"fn my_fn(&m$0) {}", has_ref_parent);
|
||||
check_pattern_is_applicable(r"fn my() { let &m$0 }", has_ref_parent);
|
||||
}
|
||||
|
||||
pub(crate) fn has_item_list_or_source_file_parent(element: SyntaxElement) -> bool {
|
||||
|
@ -99,8 +99,8 @@ pub(crate) fn has_item_list_or_source_file_parent(element: SyntaxElement) -> boo
|
|||
}
|
||||
#[test]
|
||||
fn test_has_item_list_or_source_file_parent() {
|
||||
check_pattern_is_applicable(r"i<|>", has_item_list_or_source_file_parent);
|
||||
check_pattern_is_applicable(r"mod foo { f<|> }", has_item_list_or_source_file_parent);
|
||||
check_pattern_is_applicable(r"i$0", has_item_list_or_source_file_parent);
|
||||
check_pattern_is_applicable(r"mod foo { f$0 }", has_item_list_or_source_file_parent);
|
||||
}
|
||||
|
||||
pub(crate) fn is_match_arm(element: SyntaxElement) -> bool {
|
||||
|
@ -112,7 +112,7 @@ pub(crate) fn is_match_arm(element: SyntaxElement) -> bool {
|
|||
}
|
||||
#[test]
|
||||
fn test_is_match_arm() {
|
||||
check_pattern_is_applicable(r"fn my_fn() { match () { () => m<|> } }", is_match_arm);
|
||||
check_pattern_is_applicable(r"fn my_fn() { match () { () => m$0 } }", is_match_arm);
|
||||
}
|
||||
|
||||
pub(crate) fn unsafe_is_prev(element: SyntaxElement) -> bool {
|
||||
|
@ -124,7 +124,7 @@ pub(crate) fn unsafe_is_prev(element: SyntaxElement) -> bool {
|
|||
}
|
||||
#[test]
|
||||
fn test_unsafe_is_prev() {
|
||||
check_pattern_is_applicable(r"unsafe i<|>", unsafe_is_prev);
|
||||
check_pattern_is_applicable(r"unsafe i$0", unsafe_is_prev);
|
||||
}
|
||||
|
||||
pub(crate) fn if_is_prev(element: SyntaxElement) -> bool {
|
||||
|
@ -144,11 +144,11 @@ pub(crate) fn fn_is_prev(element: SyntaxElement) -> bool {
|
|||
}
|
||||
#[test]
|
||||
fn test_fn_is_prev() {
|
||||
check_pattern_is_applicable(r"fn l<|>", fn_is_prev);
|
||||
check_pattern_is_applicable(r"fn l$0", fn_is_prev);
|
||||
}
|
||||
|
||||
/// Check if the token previous to the previous one is `for`.
|
||||
/// For example, `for _ i<|>` => true.
|
||||
/// For example, `for _ i$0` => true.
|
||||
pub(crate) fn for_is_prev2(element: SyntaxElement) -> bool {
|
||||
element
|
||||
.into_token()
|
||||
|
@ -159,12 +159,12 @@ pub(crate) fn for_is_prev2(element: SyntaxElement) -> bool {
|
|||
}
|
||||
#[test]
|
||||
fn test_for_is_prev2() {
|
||||
check_pattern_is_applicable(r"for i i<|>", for_is_prev2);
|
||||
check_pattern_is_applicable(r"for i i$0", for_is_prev2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_if_is_prev() {
|
||||
check_pattern_is_applicable(r"if l<|>", if_is_prev);
|
||||
check_pattern_is_applicable(r"if l$0", if_is_prev);
|
||||
}
|
||||
|
||||
pub(crate) fn has_trait_as_prev_sibling(element: SyntaxElement) -> bool {
|
||||
|
@ -172,7 +172,7 @@ pub(crate) fn has_trait_as_prev_sibling(element: SyntaxElement) -> bool {
|
|||
}
|
||||
#[test]
|
||||
fn test_has_trait_as_prev_sibling() {
|
||||
check_pattern_is_applicable(r"trait A w<|> {}", has_trait_as_prev_sibling);
|
||||
check_pattern_is_applicable(r"trait A w$0 {}", has_trait_as_prev_sibling);
|
||||
}
|
||||
|
||||
pub(crate) fn has_impl_as_prev_sibling(element: SyntaxElement) -> bool {
|
||||
|
@ -180,7 +180,7 @@ pub(crate) fn has_impl_as_prev_sibling(element: SyntaxElement) -> bool {
|
|||
}
|
||||
#[test]
|
||||
fn test_has_impl_as_prev_sibling() {
|
||||
check_pattern_is_applicable(r"impl A w<|> {}", has_impl_as_prev_sibling);
|
||||
check_pattern_is_applicable(r"impl A w$0 {}", has_impl_as_prev_sibling);
|
||||
}
|
||||
|
||||
pub(crate) fn is_in_loop_body(element: SyntaxElement) -> bool {
|
||||
|
|
|
@ -358,7 +358,7 @@ mod tests {
|
|||
r#"
|
||||
enum Foo { Foo { x: i32, y: i32 } }
|
||||
|
||||
fn main() { Foo::Fo<|> }
|
||||
fn main() { Foo::Fo$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
[
|
||||
|
@ -381,7 +381,7 @@ fn main() { Foo::Fo<|> }
|
|||
r#"
|
||||
enum Foo { Foo (i32, i32) }
|
||||
|
||||
fn main() { Foo::Fo<|> }
|
||||
fn main() { Foo::Fo$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
[
|
||||
|
@ -406,7 +406,7 @@ fn main() { Foo::Fo<|> }
|
|||
r#"
|
||||
enum Foo { Foo }
|
||||
|
||||
fn main() { Foo::Fo<|> }
|
||||
fn main() { Foo::Fo$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
[
|
||||
|
@ -430,7 +430,7 @@ fn main() { Foo::Fo<|> }
|
|||
mod m {
|
||||
pub enum Spam { Foo, Bar(i32) }
|
||||
}
|
||||
fn main() { let _: m::Spam = S<|> }
|
||||
fn main() { let _: m::Spam = S$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
[
|
||||
|
@ -483,7 +483,7 @@ fn something_deprecated() {}
|
|||
#[deprecated(since = "1.0.0")]
|
||||
fn something_else_deprecated() {}
|
||||
|
||||
fn main() { som<|> }
|
||||
fn main() { som$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
[
|
||||
|
@ -523,7 +523,7 @@ fn main() { som<|> }
|
|||
check(
|
||||
r#"
|
||||
struct A { #[deprecated] the_field: u32 }
|
||||
fn foo() { A { the<|> } }
|
||||
fn foo() { A { the$0 } }
|
||||
"#,
|
||||
expect![[r#"
|
||||
[
|
||||
|
@ -551,7 +551,7 @@ struct S {
|
|||
}
|
||||
impl S {
|
||||
/// Method docs
|
||||
fn bar(self) { self.<|> }
|
||||
fn bar(self) { self.$0 }
|
||||
}"#,
|
||||
expect![[r#"
|
||||
[
|
||||
|
@ -584,7 +584,7 @@ impl S {
|
|||
|
||||
check(
|
||||
r#"
|
||||
use self::my<|>;
|
||||
use self::my$0;
|
||||
|
||||
/// mod docs
|
||||
mod my { }
|
||||
|
@ -643,7 +643,7 @@ impl S {
|
|||
#[inline]
|
||||
fn the_method(&self) { }
|
||||
}
|
||||
fn foo(s: S) { s.<|> }
|
||||
fn foo(s: S) { s.$0 }
|
||||
"#,
|
||||
expect![[r#"
|
||||
[
|
||||
|
@ -671,7 +671,7 @@ fn foo(foo: u8, bar: u8) {}
|
|||
struct ManualVtable { f: fn(u8, u8) }
|
||||
|
||||
fn main() -> ManualVtable {
|
||||
ManualVtable { f: f<|> }
|
||||
ManualVtable { f: f$0 }
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -692,7 +692,7 @@ fn main() -> ManualVtable {
|
|||
"foo",
|
||||
r#"
|
||||
mod m { pub fn foo() {} }
|
||||
use crate::m::f<|>;
|
||||
use crate::m::f$0;
|
||||
"#,
|
||||
r#"
|
||||
mod m { pub fn foo() {} }
|
||||
|
@ -707,7 +707,7 @@ use crate::m::foo;
|
|||
"foo",
|
||||
r#"
|
||||
fn foo(x: i32) {}
|
||||
fn main() { f<|>(); }
|
||||
fn main() { f$0(); }
|
||||
"#,
|
||||
r#"
|
||||
fn foo(x: i32) {}
|
||||
|
@ -719,7 +719,7 @@ fn main() { foo(); }
|
|||
r#"
|
||||
struct Foo;
|
||||
impl Foo { fn foo(&self){} }
|
||||
fn f(foo: &Foo) { foo.f<|>(); }
|
||||
fn f(foo: &Foo) { foo.f$0(); }
|
||||
"#,
|
||||
r#"
|
||||
struct Foo;
|
||||
|
@ -736,7 +736,7 @@ fn f(foo: &Foo) { foo.foo(); }
|
|||
"Vec",
|
||||
r#"
|
||||
struct Vec<T> {}
|
||||
fn foo(xs: Ve<|>)
|
||||
fn foo(xs: Ve$0)
|
||||
"#,
|
||||
r#"
|
||||
struct Vec<T> {}
|
||||
|
@ -747,7 +747,7 @@ fn foo(xs: Vec<$0>)
|
|||
"Vec",
|
||||
r#"
|
||||
type Vec<T> = (T,);
|
||||
fn foo(xs: Ve<|>)
|
||||
fn foo(xs: Ve$0)
|
||||
"#,
|
||||
r#"
|
||||
type Vec<T> = (T,);
|
||||
|
@ -758,7 +758,7 @@ fn foo(xs: Vec<$0>)
|
|||
"Vec",
|
||||
r#"
|
||||
struct Vec<T = i128> {}
|
||||
fn foo(xs: Ve<|>)
|
||||
fn foo(xs: Ve$0)
|
||||
"#,
|
||||
r#"
|
||||
struct Vec<T = i128> {}
|
||||
|
@ -769,7 +769,7 @@ fn foo(xs: Vec)
|
|||
"Vec",
|
||||
r#"
|
||||
struct Vec<T> {}
|
||||
fn foo(xs: Ve<|><i128>)
|
||||
fn foo(xs: Ve$0<i128>)
|
||||
"#,
|
||||
r#"
|
||||
struct Vec<T> {}
|
||||
|
@ -785,7 +785,7 @@ fn foo(xs: Vec<i128>)
|
|||
r#"
|
||||
struct S { foo: i64, bar: u32, baz: u32 }
|
||||
fn test(bar: u32) { }
|
||||
fn foo(s: S) { test(s.<|>) }
|
||||
fn foo(s: S) { test(s.$0) }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fd bar [type+name]
|
||||
|
@ -802,7 +802,7 @@ fn foo(s: S) { test(s.<|>) }
|
|||
r#"
|
||||
struct A { foo: i64, bar: u32, baz: u32 }
|
||||
struct B { x: (), y: f32, bar: u32 }
|
||||
fn foo(a: A) { B { bar: a.<|> }; }
|
||||
fn foo(a: A) { B { bar: a.$0 }; }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fd bar [type+name]
|
||||
|
@ -819,7 +819,7 @@ fn foo(a: A) { B { bar: a.<|> }; }
|
|||
struct A { foo: i64, bar: u32, baz: u32 }
|
||||
struct B { x: (), y: f32, bar: u32 }
|
||||
fn f(foo: i64) { }
|
||||
fn foo(a: A) { B { bar: f(a.<|>) }; }
|
||||
fn foo(a: A) { B { bar: f(a.$0) }; }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fd foo [type+name]
|
||||
|
@ -832,7 +832,7 @@ fn foo(a: A) { B { bar: f(a.<|>) }; }
|
|||
struct A { foo: i64, bar: u32, baz: u32 }
|
||||
struct B { x: (), y: f32, bar: u32 }
|
||||
fn f(foo: i64) { }
|
||||
fn foo(a: A) { f(B { bar: a.<|> }); }
|
||||
fn foo(a: A) { f(B { bar: a.$0 }); }
|
||||
"#,
|
||||
expect![[r#"
|
||||
fd bar [type+name]
|
||||
|
@ -847,7 +847,7 @@ fn foo(a: A) { f(B { bar: a.<|> }); }
|
|||
check_scores(
|
||||
r#"
|
||||
struct WorldSnapshot { _f: () };
|
||||
fn go(world: &WorldSnapshot) { go(w<|>) }
|
||||
fn go(world: &WorldSnapshot) { go(w$0) }
|
||||
"#,
|
||||
expect![[r#"
|
||||
bn world [type+name]
|
||||
|
@ -862,7 +862,7 @@ fn go(world: &WorldSnapshot) { go(w<|>) }
|
|||
check_scores(
|
||||
r#"
|
||||
struct Foo;
|
||||
fn f(foo: &Foo) { f(foo, w<|>) }
|
||||
fn f(foo: &Foo) { f(foo, w$0) }
|
||||
"#,
|
||||
expect![[r#"
|
||||
st Foo []
|
||||
|
|
|
@ -115,7 +115,7 @@ mod tests {
|
|||
enum Option<T> { Some(T), None }
|
||||
use Option::*;
|
||||
fn main() -> Option<i32> {
|
||||
Som<|>
|
||||
Som$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
|
|
@ -124,7 +124,7 @@ mod tests {
|
|||
"no_args",
|
||||
r#"
|
||||
fn no_args() {}
|
||||
fn main() { no_<|> }
|
||||
fn main() { no_$0 }
|
||||
"#,
|
||||
r#"
|
||||
fn no_args() {}
|
||||
|
@ -136,7 +136,7 @@ fn main() { no_args()$0 }
|
|||
"with_args",
|
||||
r#"
|
||||
fn with_args(x: i32, y: String) {}
|
||||
fn main() { with_<|> }
|
||||
fn main() { with_$0 }
|
||||
"#,
|
||||
r#"
|
||||
fn with_args(x: i32, y: String) {}
|
||||
|
@ -151,7 +151,7 @@ struct S;
|
|||
impl S {
|
||||
fn foo(&self) {}
|
||||
}
|
||||
fn bar(s: &S) { s.f<|> }
|
||||
fn bar(s: &S) { s.f$0 }
|
||||
"#,
|
||||
r#"
|
||||
struct S;
|
||||
|
@ -170,7 +170,7 @@ impl S {
|
|||
fn foo(&self, x: i32) {}
|
||||
}
|
||||
fn bar(s: &S) {
|
||||
s.f<|>
|
||||
s.f$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -195,7 +195,7 @@ struct S;
|
|||
impl S {
|
||||
fn foo(&self) {}
|
||||
}
|
||||
fn main() { S::f<|> }
|
||||
fn main() { S::f$0 }
|
||||
"#,
|
||||
r#"
|
||||
struct S;
|
||||
|
@ -215,7 +215,7 @@ fn main() { S::foo(${1:&self})$0 }
|
|||
"with_args",
|
||||
r#"
|
||||
fn with_args(x: i32, y: String) {}
|
||||
fn main() { with_<|> }
|
||||
fn main() { with_$0 }
|
||||
"#,
|
||||
r#"
|
||||
fn with_args(x: i32, y: String) {}
|
||||
|
@ -230,7 +230,7 @@ fn main() { with_args($0) }
|
|||
"foo",
|
||||
r#"
|
||||
fn foo(_foo: i32, ___bar: bool, ho_ge_: String) {}
|
||||
fn main() { f<|> }
|
||||
fn main() { f$0 }
|
||||
"#,
|
||||
r#"
|
||||
fn foo(_foo: i32, ___bar: bool, ho_ge_: String) {}
|
||||
|
@ -248,7 +248,7 @@ struct Foo {}
|
|||
fn ref_arg(x: &Foo) {}
|
||||
fn main() {
|
||||
let x = Foo {};
|
||||
ref_ar<|>
|
||||
ref_ar$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -271,7 +271,7 @@ struct Foo {}
|
|||
fn ref_arg(x: &mut Foo) {}
|
||||
fn main() {
|
||||
let x = Foo {};
|
||||
ref_ar<|>
|
||||
ref_ar$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -299,7 +299,7 @@ impl Bar {
|
|||
fn main() {
|
||||
let x = Foo {};
|
||||
let y = Bar {};
|
||||
y.<|>
|
||||
y.$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
@ -326,7 +326,7 @@ fn main() {
|
|||
fn take_mutably(mut x: &i32) {}
|
||||
|
||||
fn main() {
|
||||
take_m<|>
|
||||
take_m$0
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
|
|
|
@ -135,7 +135,7 @@ mod tests {
|
|||
"frobnicate!",
|
||||
r#"
|
||||
//- /main.rs crate:main deps:foo
|
||||
use foo::<|>;
|
||||
use foo::$0;
|
||||
//- /foo/lib.rs crate:foo
|
||||
#[macro_export]
|
||||
macro_rules! frobnicate { () => () }
|
||||
|
@ -149,7 +149,7 @@ use foo::frobnicate;
|
|||
"frobnicate!",
|
||||
r#"
|
||||
macro_rules! frobnicate { () => () }
|
||||
fn main() { frob<|>!(); }
|
||||
fn main() { frob$0!(); }
|
||||
"#,
|
||||
r#"
|
||||
macro_rules! frobnicate { () => () }
|
||||
|
@ -173,7 +173,7 @@ fn main() { frobnicate!(); }
|
|||
/// ```
|
||||
macro_rules! vec { () => {} }
|
||||
|
||||
fn fn main() { v<|> }
|
||||
fn fn main() { v$0 }
|
||||
"#,
|
||||
r#"
|
||||
/// Creates a [`Vec`] containing the arguments.
|
||||
|
@ -198,7 +198,7 @@ fn fn main() { vec![$0] }
|
|||
/// Don't call `fooo!()` `fooo!()`, or `_foo![]` `_foo![]`,
|
||||
/// call as `let _=foo! { hello world };`
|
||||
macro_rules! foo { () => {} }
|
||||
fn main() { <|> }
|
||||
fn main() { $0 }
|
||||
"#,
|
||||
r#"
|
||||
/// Foo
|
||||
|
|
|
@ -22,12 +22,12 @@ pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig {
|
|||
merge: Some(MergeBehavior::Full),
|
||||
};
|
||||
|
||||
/// Creates analysis from a multi-file fixture, returns positions marked with <|>.
|
||||
/// Creates analysis from a multi-file fixture, returns positions marked with $0.
|
||||
pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) {
|
||||
let change_fixture = ChangeFixture::parse(ra_fixture);
|
||||
let mut database = RootDatabase::default();
|
||||
database.apply_change(change_fixture.change);
|
||||
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker (<|>)");
|
||||
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
|
||||
let offset = match range_or_offset {
|
||||
RangeOrOffset::Range(_) => panic!(),
|
||||
RangeOrOffset::Offset(it) => it,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue