Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide_completion/src/context.rs')
-rw-r--r--crates/ide_completion/src/context.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs
index d9024157ce..a112f57391 100644
--- a/crates/ide_completion/src/context.rs
+++ b/crates/ide_completion/src/context.rs
@@ -236,21 +236,14 @@ impl<'a> CompletionContext<'a> {
let kind = self.token.kind();
if kind == IDENT || kind == LIFETIME_IDENT || kind == UNDERSCORE || kind.is_keyword() {
cov_mark::hit!(completes_if_prefix_is_keyword);
- return self.original_token.text_range();
+ self.original_token.text_range()
} else if kind == CHAR {
// assume we are completing a lifetime but the user has only typed the '
cov_mark::hit!(completes_if_lifetime_without_idents);
- return TextRange::at(self.original_token.text_range().start(), TextSize::from(1));
- } else if kind == BANG {
- if let Some(n) = self.token.parent() {
- if n.kind() == SyntaxKind::MACRO_CALL {
- cov_mark::hit!(completes_macro_call_if_cursor_at_bang_token);
- return n.text_range();
- }
- }
+ TextRange::at(self.original_token.text_range().start(), TextSize::from(1))
+ } else {
+ TextRange::empty(self.position.offset)
}
-
- TextRange::empty(self.position.offset)
}
pub(crate) fn previous_token_is(&self, kind: SyntaxKind) -> bool {
@@ -402,6 +395,10 @@ impl<'a> CompletionContext<'a> {
}
}
+ pub(crate) fn is_immediately_after_macro_bang(&self) -> bool {
+ self.token.kind() == BANG && self.token.parent().map_or(false, |it| it.kind() == MACRO_CALL)
+ }
+
/// A version of [`SemanticsScope::process_all_names`] that filters out `#[doc(hidden)]` items.
pub(crate) fn process_all_names(&self, f: &mut dyn FnMut(Name, ScopeDef)) {
self.scope.process_all_names(&mut |name, def| {