mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Merge #5615
5615: simplify r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
7d18109af4
1 changed files with 4 additions and 6 deletions
|
@ -405,8 +405,7 @@ fn scope_for_offset(
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.map(|(expr_range, scope)| {
|
.map(|(expr_range, scope)| {
|
||||||
adjust(db, scopes, source_map, expr_range, offset.file_id, offset.value)
|
adjust(db, scopes, source_map, expr_range, offset).unwrap_or(*scope)
|
||||||
.unwrap_or(*scope)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,8 +416,7 @@ fn adjust(
|
||||||
scopes: &ExprScopes,
|
scopes: &ExprScopes,
|
||||||
source_map: &BodySourceMap,
|
source_map: &BodySourceMap,
|
||||||
expr_range: TextRange,
|
expr_range: TextRange,
|
||||||
file_id: HirFileId,
|
offset: InFile<TextSize>,
|
||||||
offset: TextSize,
|
|
||||||
) -> Option<ScopeId> {
|
) -> Option<ScopeId> {
|
||||||
let child_scopes = scopes
|
let child_scopes = scopes
|
||||||
.scope_by_expr()
|
.scope_by_expr()
|
||||||
|
@ -426,7 +424,7 @@ fn adjust(
|
||||||
.filter_map(|(id, scope)| {
|
.filter_map(|(id, scope)| {
|
||||||
let source = source_map.expr_syntax(*id).ok()?;
|
let source = source_map.expr_syntax(*id).ok()?;
|
||||||
// FIXME: correctly handle macro expansion
|
// FIXME: correctly handle macro expansion
|
||||||
if source.file_id != file_id {
|
if source.file_id != offset.file_id {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let root = source.file_syntax(db.upcast());
|
let root = source.file_syntax(db.upcast());
|
||||||
|
@ -434,7 +432,7 @@ fn adjust(
|
||||||
Some((node.syntax().text_range(), scope))
|
Some((node.syntax().text_range(), scope))
|
||||||
})
|
})
|
||||||
.filter(|&(range, _)| {
|
.filter(|&(range, _)| {
|
||||||
range.start() <= offset && expr_range.contains_range(range) && range != expr_range
|
range.start() <= offset.value && expr_range.contains_range(range) && range != expr_range
|
||||||
});
|
});
|
||||||
|
|
||||||
child_scopes
|
child_scopes
|
||||||
|
|
Loading…
Reference in a new issue