aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-30 21:56:11 +0100
committerAleksey Kladov <[email protected]>2020-07-30 21:56:43 +0100
commit848f446a5abdc1c5512782267427f72c217b1556 (patch)
tree6fe185db8002c331e539c0cb5543da8571e65bba /crates/ra_hir
parent239dd506f68db0cbe4417b6e5c7f737d8ff8a159 (diff)
simplify
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/source_analyzer.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs
index 8f438bba0..f2e630ef1 100644
--- a/crates/ra_hir/src/source_analyzer.rs
+++ b/crates/ra_hir/src/source_analyzer.rs
@@ -405,8 +405,7 @@ fn scope_for_offset(
405 ) 405 )
406 }) 406 })
407 .map(|(expr_range, scope)| { 407 .map(|(expr_range, scope)| {
408 adjust(db, scopes, source_map, expr_range, offset.file_id, offset.value) 408 adjust(db, scopes, source_map, expr_range, offset).unwrap_or(*scope)
409 .unwrap_or(*scope)
410 }) 409 })
411} 410}
412 411
@@ -417,8 +416,7 @@ fn adjust(
417 scopes: &ExprScopes, 416 scopes: &ExprScopes,
418 source_map: &BodySourceMap, 417 source_map: &BodySourceMap,
419 expr_range: TextRange, 418 expr_range: TextRange,
420 file_id: HirFileId, 419 offset: InFile<TextSize>,
421 offset: TextSize,
422) -> Option<ScopeId> { 420) -> Option<ScopeId> {
423 let child_scopes = scopes 421 let child_scopes = scopes
424 .scope_by_expr() 422 .scope_by_expr()
@@ -426,7 +424,7 @@ fn adjust(
426 .filter_map(|(id, scope)| { 424 .filter_map(|(id, scope)| {
427 let source = source_map.expr_syntax(*id).ok()?; 425 let source = source_map.expr_syntax(*id).ok()?;
428 // FIXME: correctly handle macro expansion 426 // FIXME: correctly handle macro expansion
429 if source.file_id != file_id { 427 if source.file_id != offset.file_id {
430 return None; 428 return None;
431 } 429 }
432 let root = source.file_syntax(db.upcast()); 430 let root = source.file_syntax(db.upcast());
@@ -434,7 +432,7 @@ fn adjust(
434 Some((node.syntax().text_range(), scope)) 432 Some((node.syntax().text_range(), scope))
435 }) 433 })
436 .filter(|&(range, _)| { 434 .filter(|&(range, _)| {
437 range.start() <= offset && expr_range.contains_range(range) && range != expr_range 435 range.start() <= offset.value && expr_range.contains_range(range) && range != expr_range
438 }); 436 });
439 437
440 child_scopes 438 child_scopes