mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
hide keyword suggestions in non trivial paths
This commit is contained in:
parent
478d435640
commit
7b20904e8b
3 changed files with 10 additions and 16 deletions
|
@ -20,6 +20,10 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
|
||||||
cov_mark::hit!(no_keyword_completion_in_attr_of_expr);
|
cov_mark::hit!(no_keyword_completion_in_attr_of_expr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ctx.is_non_trivial_path() {
|
||||||
|
cov_mark::hit!(no_keyword_completion_in_non_trivial_path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Suggest .await syntax for types that implement Future trait
|
// Suggest .await syntax for types that implement Future trait
|
||||||
if let Some(receiver) = ctx.dot_receiver() {
|
if let Some(receiver) = ctx.dot_receiver() {
|
||||||
|
|
|
@ -353,6 +353,10 @@ impl<'a> CompletionContext<'a> {
|
||||||
matches!(self.path_context, Some(PathCompletionContext { is_trivial_path: true, .. }))
|
matches!(self.path_context, Some(PathCompletionContext { is_trivial_path: true, .. }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn is_non_trivial_path(&self) -> bool {
|
||||||
|
matches!(self.path_context, Some(PathCompletionContext { is_trivial_path: false, .. }))
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn path_qual(&self) -> Option<&ast::Path> {
|
pub(crate) fn path_qual(&self) -> Option<&ast::Path> {
|
||||||
self.path_context.as_ref().and_then(|it| it.qualifier.as_ref())
|
self.path_context.as_ref().and_then(|it| it.qualifier.as_ref())
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,25 +101,11 @@ fn in_item_list_after_attr() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn in_qualified_path() {
|
fn in_qualified_path() {
|
||||||
|
cov_mark::check!(no_keyword_completion_in_non_trivial_path);
|
||||||
check(
|
check(
|
||||||
r#"crate::$0"#,
|
r#"crate::$0"#,
|
||||||
expect![[r##"
|
expect![[r##"
|
||||||
kw pub(crate)
|
ma makro!(…) #[macro_export] macro_rules! makro
|
||||||
kw pub
|
|
||||||
kw unsafe
|
|
||||||
kw fn
|
|
||||||
kw const
|
|
||||||
kw type
|
|
||||||
kw impl
|
|
||||||
kw extern
|
|
||||||
kw use
|
|
||||||
kw trait
|
|
||||||
kw static
|
|
||||||
kw mod
|
|
||||||
kw enum
|
|
||||||
kw struct
|
|
||||||
kw union
|
|
||||||
ma makro!(…) #[macro_export] macro_rules! makro
|
|
||||||
md module
|
md module
|
||||||
"##]],
|
"##]],
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue