aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/source_binder.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-28 09:50:26 +0000
committerAleksey Kladov <[email protected]>2019-11-28 09:50:26 +0000
commitccd1b0800a5de5e046e6e9a4b6f49030c1ce3639 (patch)
treee878f88aebf11c0e54eff2e107dfaa4d192ab272 /crates/ra_hir/src/source_binder.rs
parent2702fa1c5d6d8ad504c0d7703b6363ea09ba5570 (diff)
Rename Source -> InFile
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r--crates/ra_hir/src/source_binder.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 76c493f1a..1661d92a2 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -18,7 +18,7 @@ use hir_def::{
18 AssocItemId, DefWithBodyId, 18 AssocItemId, DefWithBodyId,
19}; 19};
20use hir_expand::{ 20use hir_expand::{
21 hygiene::Hygiene, name::AsName, AstId, HirFileId, MacroCallId, MacroFileKind, Source, 21 hygiene::Hygiene, name::AsName, AstId, HirFileId, InFile, MacroCallId, MacroFileKind,
22}; 22};
23use ra_syntax::{ 23use ra_syntax::{
24 ast::{self, AstNode}, 24 ast::{self, AstNode},
@@ -37,7 +37,7 @@ use crate::{
37 GenericParam, Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, 37 GenericParam, Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias,
38}; 38};
39 39
40fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -> Option<Resolver> { 40fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) -> Option<Resolver> {
41 match_ast! { 41 match_ast! {
42 match (node.value) { 42 match (node.value) {
43 ast::Module(it) => { 43 ast::Module(it) => {
@@ -71,7 +71,7 @@ fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -
71 71
72fn def_with_body_from_child_node( 72fn def_with_body_from_child_node(
73 db: &impl HirDatabase, 73 db: &impl HirDatabase,
74 child: Source<&SyntaxNode>, 74 child: InFile<&SyntaxNode>,
75) -> Option<DefWithBody> { 75) -> Option<DefWithBody> {
76 child.value.ancestors().find_map(|node| { 76 child.value.ancestors().find_map(|node| {
77 match_ast! { 77 match_ast! {
@@ -141,8 +141,8 @@ impl Expansion {
141 pub fn map_token_down( 141 pub fn map_token_down(
142 &self, 142 &self,
143 db: &impl HirDatabase, 143 db: &impl HirDatabase,
144 token: Source<&SyntaxToken>, 144 token: InFile<&SyntaxToken>,
145 ) -> Option<Source<SyntaxToken>> { 145 ) -> Option<InFile<SyntaxToken>> {
146 let exp_info = self.file_id().expansion_info(db)?; 146 let exp_info = self.file_id().expansion_info(db)?;
147 exp_info.map_token_down(token) 147 exp_info.map_token_down(token)
148 } 148 }
@@ -155,7 +155,7 @@ impl Expansion {
155impl SourceAnalyzer { 155impl SourceAnalyzer {
156 pub fn new( 156 pub fn new(
157 db: &impl HirDatabase, 157 db: &impl HirDatabase,
158 node: Source<&SyntaxNode>, 158 node: InFile<&SyntaxNode>,
159 offset: Option<TextUnit>, 159 offset: Option<TextUnit>,
160 ) -> SourceAnalyzer { 160 ) -> SourceAnalyzer {
161 let def_with_body = def_with_body_from_child_node(db, node); 161 let def_with_body = def_with_body_from_child_node(db, node);
@@ -192,12 +192,12 @@ impl SourceAnalyzer {
192 } 192 }
193 193
194 fn expr_id(&self, expr: &ast::Expr) -> Option<ExprId> { 194 fn expr_id(&self, expr: &ast::Expr) -> Option<ExprId> {
195 let src = Source { file_id: self.file_id, value: expr }; 195 let src = InFile { file_id: self.file_id, value: expr };
196 self.body_source_map.as_ref()?.node_expr(src) 196 self.body_source_map.as_ref()?.node_expr(src)
197 } 197 }
198 198
199 fn pat_id(&self, pat: &ast::Pat) -> Option<PatId> { 199 fn pat_id(&self, pat: &ast::Pat) -> Option<PatId> {
200 let src = Source { file_id: self.file_id, value: pat }; 200 let src = InFile { file_id: self.file_id, value: pat };
201 self.body_source_map.as_ref()?.node_pat(src) 201 self.body_source_map.as_ref()?.node_pat(src)
202 } 202 }
203 203
@@ -243,7 +243,7 @@ impl SourceAnalyzer {
243 pub fn resolve_macro_call( 243 pub fn resolve_macro_call(
244 &self, 244 &self,
245 db: &impl HirDatabase, 245 db: &impl HirDatabase,
246 macro_call: Source<&ast::MacroCall>, 246 macro_call: InFile<&ast::MacroCall>,
247 ) -> Option<MacroDef> { 247 ) -> Option<MacroDef> {
248 let hygiene = Hygiene::new(db, macro_call.file_id); 248 let hygiene = Hygiene::new(db, macro_call.file_id);
249 let path = macro_call.value.path().and_then(|ast| Path::from_src(ast, &hygiene))?; 249 let path = macro_call.value.path().and_then(|ast| Path::from_src(ast, &hygiene))?;
@@ -318,7 +318,7 @@ impl SourceAnalyzer {
318 let name = name_ref.as_name(); 318 let name = name_ref.as_name();
319 let source_map = self.body_source_map.as_ref()?; 319 let source_map = self.body_source_map.as_ref()?;
320 let scopes = self.scopes.as_ref()?; 320 let scopes = self.scopes.as_ref()?;
321 let scope = scope_for(scopes, source_map, Source::new(self.file_id, name_ref.syntax()))?; 321 let scope = scope_for(scopes, source_map, InFile::new(self.file_id, name_ref.syntax()))?;
322 let entry = scopes.resolve_name_in_scope(scope, &name)?; 322 let entry = scopes.resolve_name_in_scope(scope, &name)?;
323 Some(ScopeEntryWithSyntax { 323 Some(ScopeEntryWithSyntax {
324 name: entry.name().clone(), 324 name: entry.name().clone(),
@@ -446,7 +446,7 @@ impl SourceAnalyzer {
446 pub fn expand( 446 pub fn expand(
447 &self, 447 &self,
448 db: &impl HirDatabase, 448 db: &impl HirDatabase,
449 macro_call: Source<&ast::MacroCall>, 449 macro_call: InFile<&ast::MacroCall>,
450 ) -> Option<Expansion> { 450 ) -> Option<Expansion> {
451 let def = self.resolve_macro_call(db, macro_call)?.id; 451 let def = self.resolve_macro_call(db, macro_call)?.id;
452 let ast_id = AstId::new( 452 let ast_id = AstId::new(
@@ -463,19 +463,19 @@ impl SourceAnalyzer {
463fn scope_for( 463fn scope_for(
464 scopes: &ExprScopes, 464 scopes: &ExprScopes,
465 source_map: &BodySourceMap, 465 source_map: &BodySourceMap,
466 node: Source<&SyntaxNode>, 466 node: InFile<&SyntaxNode>,
467) -> Option<ScopeId> { 467) -> Option<ScopeId> {
468 node.value 468 node.value
469 .ancestors() 469 .ancestors()
470 .filter_map(ast::Expr::cast) 470 .filter_map(ast::Expr::cast)
471 .filter_map(|it| source_map.node_expr(Source::new(node.file_id, &it))) 471 .filter_map(|it| source_map.node_expr(InFile::new(node.file_id, &it)))
472 .find_map(|it| scopes.scope_for(it)) 472 .find_map(|it| scopes.scope_for(it))
473} 473}
474 474
475fn scope_for_offset( 475fn scope_for_offset(
476 scopes: &ExprScopes, 476 scopes: &ExprScopes,
477 source_map: &BodySourceMap, 477 source_map: &BodySourceMap,
478 offset: Source<TextUnit>, 478 offset: InFile<TextUnit>,
479) -> Option<ScopeId> { 479) -> Option<ScopeId> {
480 scopes 480 scopes
481 .scope_by_expr() 481 .scope_by_expr()