internal: Add offset param to token descending API

This commit is contained in:
Lukas Wirth 2023-08-16 10:07:18 +02:00
parent b14770934a
commit 53b292478d
21 changed files with 185 additions and 143 deletions

View file

@ -67,17 +67,20 @@ impl SignatureHelp {
}
/// Computes parameter information for the given position.
pub(crate) fn signature_help(db: &RootDatabase, position: FilePosition) -> Option<SignatureHelp> {
pub(crate) fn signature_help(
db: &RootDatabase,
FilePosition { file_id, offset }: FilePosition,
) -> Option<SignatureHelp> {
let sema = Semantics::new(db);
let file = sema.parse(position.file_id);
let file = sema.parse(file_id);
let file = file.syntax();
let token = file
.token_at_offset(position.offset)
.token_at_offset(offset)
.left_biased()
// if the cursor is sandwiched between two space tokens and the call is unclosed
// this prevents us from leaving the CallExpression
.and_then(|tok| algo::skip_trivia_token(tok, Direction::Prev))?;
let token = sema.descend_into_macros_single(token);
let token = sema.descend_into_macros_single(token, offset);
for node in token.parent_ancestors() {
match_ast! {