internal: Remove previous_token field from CompletionContext

This commit is contained in:
Lukas Wirth 2022-06-20 15:07:48 +02:00
parent 90483321ee
commit bcf10cde13
7 changed files with 50 additions and 37 deletions

View file

@ -259,8 +259,11 @@ pub(super) enum NameRefKind {
DotAccess(DotAccess),
/// Position where we are only interested in keyword completions
Keyword(ast::Item),
/// The record expression this nameref is a field of
RecordExpr(ast::RecordExpr),
/// The record expression this nameref is a field of and whether a dot precedes the completion identifier.
RecordExpr {
dot_prefix: bool,
expr: ast::RecordExpr,
},
Pattern(PatternContext),
}
@ -279,6 +282,7 @@ pub(super) enum IdentContext {
},
/// Set if we are currently completing in an unexpanded attribute, this usually implies a builtin attribute like `allow($0)`
UnexpandedAttrTT {
colon_prefix: bool,
fake_attribute_under_caret: Option<ast::Attr>,
},
}
@ -334,9 +338,6 @@ pub(crate) struct CompletionContext<'a> {
/// The expected type of what we are completing.
pub(super) expected_type: Option<Type>,
// FIXME: This shouldn't exist
pub(super) previous_token: Option<SyntaxToken>,
// We might wanna split these out of CompletionContext
pub(super) ident_ctx: IdentContext,
pub(super) qualifier_ctx: QualifierCtx,
@ -361,11 +362,6 @@ impl<'a> CompletionContext<'a> {
}
}
// FIXME: This shouldn't exist
pub(crate) fn previous_token_is(&self, kind: SyntaxKind) -> bool {
self.previous_token.as_ref().map_or(false, |tok| tok.kind() == kind)
}
pub(crate) fn famous_defs(&self) -> FamousDefs {
FamousDefs(&self.sema, self.krate)
}
@ -507,9 +503,11 @@ impl<'a> CompletionContext<'a> {
module,
expected_name: None,
expected_type: None,
previous_token: None,
// dummy value, will be overwritten
ident_ctx: IdentContext::UnexpandedAttrTT { fake_attribute_under_caret: None },
ident_ctx: IdentContext::UnexpandedAttrTT {
fake_attribute_under_caret: None,
colon_prefix: false,
},
qualifier_ctx: Default::default(),
locals,
};