mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
internal: Add offset param to token descending API
This commit is contained in:
parent
b14770934a
commit
53b292478d
21 changed files with 185 additions and 143 deletions
|
@ -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! {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue