diff options
author | Aleksey Kladov <[email protected]> | 2019-11-15 21:40:54 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-15 21:40:54 +0000 |
commit | 0404e647e69f758ac84c742b06dddefb01cc4ad6 (patch) | |
tree | c0fb90f2bfa0cec5eb62e80bfe5cf7c009a3fc18 /crates/ra_hir/src | |
parent | bd8af6a413bb2f762bb696d20727e21cb2d4cb62 (diff) |
Prepare SourceAnalyzer for macros
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index f3bccd8ed..540ddd0b5 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -91,7 +91,7 @@ fn def_with_body_from_child_node( | |||
91 | #[derive(Debug)] | 91 | #[derive(Debug)] |
92 | pub struct SourceAnalyzer { | 92 | pub struct SourceAnalyzer { |
93 | // FIXME: this doesn't handle macros at all | 93 | // FIXME: this doesn't handle macros at all |
94 | file_id: FileId, | 94 | file_id: HirFileId, |
95 | resolver: Resolver, | 95 | resolver: Resolver, |
96 | body_owner: Option<DefWithBody>, | 96 | body_owner: Option<DefWithBody>, |
97 | body_source_map: Option<Arc<BodySourceMap>>, | 97 | body_source_map: Option<Arc<BodySourceMap>>, |
@@ -159,7 +159,7 @@ impl SourceAnalyzer { | |||
159 | body_source_map: Some(source_map), | 159 | body_source_map: Some(source_map), |
160 | infer: Some(def.infer(db)), | 160 | infer: Some(def.infer(db)), |
161 | scopes: Some(scopes), | 161 | scopes: Some(scopes), |
162 | file_id, | 162 | file_id: file_id.into(), |
163 | } | 163 | } |
164 | } else { | 164 | } else { |
165 | SourceAnalyzer { | 165 | SourceAnalyzer { |
@@ -171,18 +171,18 @@ impl SourceAnalyzer { | |||
171 | body_source_map: None, | 171 | body_source_map: None, |
172 | infer: None, | 172 | infer: None, |
173 | scopes: None, | 173 | scopes: None, |
174 | file_id, | 174 | file_id: file_id.into(), |
175 | } | 175 | } |
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
179 | fn expr_id(&self, expr: &ast::Expr) -> Option<ExprId> { | 179 | fn expr_id(&self, expr: &ast::Expr) -> Option<ExprId> { |
180 | let src = Source { file_id: self.file_id.into(), ast: expr }; | 180 | let src = Source { file_id: self.file_id, ast: expr }; |
181 | self.body_source_map.as_ref()?.node_expr(src) | 181 | self.body_source_map.as_ref()?.node_expr(src) |
182 | } | 182 | } |
183 | 183 | ||
184 | fn pat_id(&self, pat: &ast::Pat) -> Option<PatId> { | 184 | fn pat_id(&self, pat: &ast::Pat) -> Option<PatId> { |
185 | let src = Source { file_id: self.file_id.into(), ast: pat }; | 185 | let src = Source { file_id: self.file_id, ast: pat }; |
186 | self.body_source_map.as_ref()?.node_pat(src) | 186 | self.body_source_map.as_ref()?.node_pat(src) |
187 | } | 187 | } |
188 | 188 | ||
@@ -290,8 +290,7 @@ impl SourceAnalyzer { | |||
290 | let name = name_ref.as_name(); | 290 | let name = name_ref.as_name(); |
291 | let source_map = self.body_source_map.as_ref()?; | 291 | let source_map = self.body_source_map.as_ref()?; |
292 | let scopes = self.scopes.as_ref()?; | 292 | let scopes = self.scopes.as_ref()?; |
293 | let scope = | 293 | let scope = scope_for(scopes, source_map, Source::new(self.file_id, name_ref.syntax()))?; |
294 | scope_for(scopes, source_map, Source::new(self.file_id.into(), name_ref.syntax()))?; | ||
295 | let entry = scopes.resolve_name_in_scope(scope, &name)?; | 294 | let entry = scopes.resolve_name_in_scope(scope, &name)?; |
296 | Some(ScopeEntryWithSyntax { | 295 | Some(ScopeEntryWithSyntax { |
297 | name: entry.name().clone(), | 296 | name: entry.name().clone(), |