diff options
Diffstat (limited to 'crates/ra_ssr/src/lib.rs')
-rw-r--r-- | crates/ra_ssr/src/lib.rs | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/crates/ra_ssr/src/lib.rs b/crates/ra_ssr/src/lib.rs index 2fb326b45..7014a6ac6 100644 --- a/crates/ra_ssr/src/lib.rs +++ b/crates/ra_ssr/src/lib.rs | |||
@@ -51,8 +51,7 @@ pub struct MatchFinder<'db> { | |||
51 | /// Our source of information about the user's code. | 51 | /// Our source of information about the user's code. |
52 | sema: Semantics<'db, ra_ide_db::RootDatabase>, | 52 | sema: Semantics<'db, ra_ide_db::RootDatabase>, |
53 | rules: Vec<ResolvedRule>, | 53 | rules: Vec<ResolvedRule>, |
54 | scope: hir::SemanticsScope<'db>, | 54 | resolution_scope: resolving::ResolutionScope<'db>, |
55 | hygiene: hir::Hygiene, | ||
56 | } | 55 | } |
57 | 56 | ||
58 | impl<'db> MatchFinder<'db> { | 57 | impl<'db> MatchFinder<'db> { |
@@ -63,21 +62,8 @@ impl<'db> MatchFinder<'db> { | |||
63 | lookup_context: FilePosition, | 62 | lookup_context: FilePosition, |
64 | ) -> MatchFinder<'db> { | 63 | ) -> MatchFinder<'db> { |
65 | let sema = Semantics::new(db); | 64 | let sema = Semantics::new(db); |
66 | let file = sema.parse(lookup_context.file_id); | 65 | let resolution_scope = resolving::ResolutionScope::new(&sema, lookup_context); |
67 | // Find a node at the requested position, falling back to the whole file. | 66 | MatchFinder { sema: Semantics::new(db), rules: Vec::new(), resolution_scope } |
68 | let node = file | ||
69 | .syntax() | ||
70 | .token_at_offset(lookup_context.offset) | ||
71 | .left_biased() | ||
72 | .map(|token| token.parent()) | ||
73 | .unwrap_or_else(|| file.syntax().clone()); | ||
74 | let scope = sema.scope(&node); | ||
75 | MatchFinder { | ||
76 | sema: Semantics::new(db), | ||
77 | rules: Vec::new(), | ||
78 | scope, | ||
79 | hygiene: hir::Hygiene::new(db, lookup_context.file_id.into()), | ||
80 | } | ||
81 | } | 67 | } |
82 | 68 | ||
83 | /// Constructs an instance using the start of the first file in `db` as the lookup context. | 69 | /// Constructs an instance using the start of the first file in `db` as the lookup context. |
@@ -106,8 +92,7 @@ impl<'db> MatchFinder<'db> { | |||
106 | for parsed_rule in rule.parsed_rules { | 92 | for parsed_rule in rule.parsed_rules { |
107 | self.rules.push(ResolvedRule::new( | 93 | self.rules.push(ResolvedRule::new( |
108 | parsed_rule, | 94 | parsed_rule, |
109 | &self.scope, | 95 | &self.resolution_scope, |
110 | &self.hygiene, | ||
111 | self.rules.len(), | 96 | self.rules.len(), |
112 | )?); | 97 | )?); |
113 | } | 98 | } |
@@ -140,8 +125,7 @@ impl<'db> MatchFinder<'db> { | |||
140 | for parsed_rule in pattern.parsed_rules { | 125 | for parsed_rule in pattern.parsed_rules { |
141 | self.rules.push(ResolvedRule::new( | 126 | self.rules.push(ResolvedRule::new( |
142 | parsed_rule, | 127 | parsed_rule, |
143 | &self.scope, | 128 | &self.resolution_scope, |
144 | &self.hygiene, | ||
145 | self.rules.len(), | 129 | self.rules.len(), |
146 | )?); | 130 | )?); |
147 | } | 131 | } |