[ty] Remove offset from `CompletionTargetTokens::Unknown`

At some point, the surrounding code was refactored so that the
cursor offset was always passed around, so storing it here is
no longer necessary.
This commit is contained in:
Andrew Gallant 2025-07-24 12:26:49 -04:00 committed by Andrew Gallant
parent d449c541cb
commit 865a9b3424
1 changed files with 6 additions and 6 deletions

View File

@ -66,9 +66,9 @@ enum CompletionTargetTokens<'t> {
/// A token was found under the cursor, but it didn't /// A token was found under the cursor, but it didn't
/// match any of our anticipated token patterns. /// match any of our anticipated token patterns.
Generic { token: &'t Token }, Generic { token: &'t Token },
/// No token was found, but we have the offset of the /// No token was found. We generally treat this like
/// cursor. /// `Generic` (i.e., offer scope based completions).
Unknown { offset: TextSize }, Unknown,
} }
impl<'t> CompletionTargetTokens<'t> { impl<'t> CompletionTargetTokens<'t> {
@ -78,7 +78,7 @@ impl<'t> CompletionTargetTokens<'t> {
static OBJECT_DOT_NON_EMPTY: [TokenKind; 2] = [TokenKind::Dot, TokenKind::Name]; static OBJECT_DOT_NON_EMPTY: [TokenKind; 2] = [TokenKind::Dot, TokenKind::Name];
let offset = match parsed.tokens().at_offset(offset) { let offset = match parsed.tokens().at_offset(offset) {
TokenAt::None => return Some(CompletionTargetTokens::Unknown { offset }), TokenAt::None => return Some(CompletionTargetTokens::Unknown),
TokenAt::Single(tok) => tok.end(), TokenAt::Single(tok) => tok.end(),
TokenAt::Between(_, tok) => tok.start(), TokenAt::Between(_, tok) => tok.start(),
}; };
@ -122,7 +122,7 @@ impl<'t> CompletionTargetTokens<'t> {
return None; return None;
} else { } else {
let Some(last) = before.last() else { let Some(last) = before.last() else {
return Some(CompletionTargetTokens::Unknown { offset }); return Some(CompletionTargetTokens::Unknown);
}; };
CompletionTargetTokens::Generic { token: last } CompletionTargetTokens::Generic { token: last }
}, },
@ -171,7 +171,7 @@ impl<'t> CompletionTargetTokens<'t> {
node: covering_node.node(), node: covering_node.node(),
}) })
} }
CompletionTargetTokens::Unknown { offset } => { CompletionTargetTokens::Unknown => {
let range = TextRange::empty(offset); let range = TextRange::empty(offset);
let covering_node = covering_node(parsed.syntax().into(), range); let covering_node = covering_node(parsed.syntax().into(), range);
Some(CompletionTargetAst::Scoped { Some(CompletionTargetAst::Scoped {