diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-23 14:37:57 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-23 14:37:57 +0000 |
commit | a583070b7d47852094b498c3191b4b5d87520fc3 (patch) | |
tree | dfe8364efeeaca6f8f32e1d922fb615119b8012b /crates/ra_hir | |
parent | 81fcfc55d247bfe6090741f2e4ae9aa89947bf32 (diff) | |
parent | 7b901f86cd1d0198994e5a2ab7eea18f444dd148 (diff) |
Merge #610
610: move SyntaxPtr to ra_syntax r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/code_model_impl/function/scope.rs | 13 | ||||
-rw-r--r-- | crates/ra_hir/src/expr.rs | 50 | ||||
-rw-r--r-- | crates/ra_hir/src/macros.rs | 13 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/lower.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 2 |
5 files changed, 44 insertions, 44 deletions
diff --git a/crates/ra_hir/src/code_model_impl/function/scope.rs b/crates/ra_hir/src/code_model_impl/function/scope.rs index 3a7d53a93..c5d1de5eb 100644 --- a/crates/ra_hir/src/code_model_impl/function/scope.rs +++ b/crates/ra_hir/src/code_model_impl/function/scope.rs | |||
@@ -3,12 +3,11 @@ use std::sync::Arc; | |||
3 | use rustc_hash::{FxHashMap, FxHashSet}; | 3 | use rustc_hash::{FxHashMap, FxHashSet}; |
4 | 4 | ||
5 | use ra_syntax::{ | 5 | use ra_syntax::{ |
6 | AstNode, SyntaxNode, TextUnit, TextRange, | 6 | AstNode, SyntaxNode, TextUnit, TextRange, SyntaxNodePtr, |
7 | algo::generate, | 7 | algo::generate, |
8 | ast, | 8 | ast, |
9 | }; | 9 | }; |
10 | use ra_arena::{Arena, RawId, impl_arena_id}; | 10 | use ra_arena::{Arena, RawId, impl_arena_id}; |
11 | use ra_db::LocalSyntaxPtr; | ||
12 | 11 | ||
13 | use crate::{Name, AsName, expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySyntaxMapping}}; | 12 | use crate::{Name, AsName, expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySyntaxMapping}}; |
14 | 13 | ||
@@ -126,7 +125,7 @@ pub struct ScopesWithSyntaxMapping { | |||
126 | #[derive(Debug, Clone, PartialEq, Eq)] | 125 | #[derive(Debug, Clone, PartialEq, Eq)] |
127 | pub struct ScopeEntryWithSyntax { | 126 | pub struct ScopeEntryWithSyntax { |
128 | name: Name, | 127 | name: Name, |
129 | ptr: LocalSyntaxPtr, | 128 | ptr: SyntaxNodePtr, |
130 | } | 129 | } |
131 | 130 | ||
132 | impl ScopeEntryWithSyntax { | 131 | impl ScopeEntryWithSyntax { |
@@ -134,7 +133,7 @@ impl ScopeEntryWithSyntax { | |||
134 | &self.name | 133 | &self.name |
135 | } | 134 | } |
136 | 135 | ||
137 | pub fn ptr(&self) -> LocalSyntaxPtr { | 136 | pub fn ptr(&self) -> SyntaxNodePtr { |
138 | self.ptr | 137 | self.ptr |
139 | } | 138 | } |
140 | } | 139 | } |
@@ -169,7 +168,7 @@ impl ScopesWithSyntaxMapping { | |||
169 | 168 | ||
170 | // XXX: during completion, cursor might be outside of any particular | 169 | // XXX: during completion, cursor might be outside of any particular |
171 | // expression. Try to figure out the correct scope... | 170 | // expression. Try to figure out the correct scope... |
172 | fn adjust(&self, ptr: LocalSyntaxPtr, original_scope: ScopeId, offset: TextUnit) -> ScopeId { | 171 | fn adjust(&self, ptr: SyntaxNodePtr, original_scope: ScopeId, offset: TextUnit) -> ScopeId { |
173 | let r = ptr.range(); | 172 | let r = ptr.range(); |
174 | let child_scopes = self | 173 | let child_scopes = self |
175 | .scopes | 174 | .scopes |
@@ -212,7 +211,7 @@ impl ScopesWithSyntaxMapping { | |||
212 | 211 | ||
213 | pub fn find_all_refs(&self, pat: &ast::BindPat) -> Vec<ReferenceDescriptor> { | 212 | pub fn find_all_refs(&self, pat: &ast::BindPat) -> Vec<ReferenceDescriptor> { |
214 | let fn_def = pat.syntax().ancestors().find_map(ast::FnDef::cast).unwrap(); | 213 | let fn_def = pat.syntax().ancestors().find_map(ast::FnDef::cast).unwrap(); |
215 | let name_ptr = LocalSyntaxPtr::new(pat.syntax()); | 214 | let name_ptr = SyntaxNodePtr::new(pat.syntax()); |
216 | fn_def | 215 | fn_def |
217 | .syntax() | 216 | .syntax() |
218 | .descendants() | 217 | .descendants() |
@@ -230,7 +229,7 @@ impl ScopesWithSyntaxMapping { | |||
230 | 229 | ||
231 | fn scope_for(&self, node: &SyntaxNode) -> Option<ScopeId> { | 230 | fn scope_for(&self, node: &SyntaxNode) -> Option<ScopeId> { |
232 | node.ancestors() | 231 | node.ancestors() |
233 | .map(LocalSyntaxPtr::new) | 232 | .map(SyntaxNodePtr::new) |
234 | .filter_map(|ptr| self.syntax_mapping.syntax_expr(ptr)) | 233 | .filter_map(|ptr| self.syntax_mapping.syntax_expr(ptr)) |
235 | .find_map(|it| self.scopes.scope_for(it)) | 234 | .find_map(|it| self.scopes.scope_for(it)) |
236 | } | 235 | } |
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 51dae8e25..1a3821692 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -4,8 +4,10 @@ use std::sync::Arc; | |||
4 | use rustc_hash::FxHashMap; | 4 | use rustc_hash::FxHashMap; |
5 | 5 | ||
6 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; | 6 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; |
7 | use ra_db::LocalSyntaxPtr; | 7 | use ra_syntax::{ |
8 | use ra_syntax::ast::{self, AstNode, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor}; | 8 | SyntaxNodePtr, AstNode, |
9 | ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor} | ||
10 | }; | ||
9 | 11 | ||
10 | use crate::{Path, type_ref::{Mutability, TypeRef}, Name, HirDatabase, DefId, Def, name::AsName}; | 12 | use crate::{Path, type_ref::{Mutability, TypeRef}, Name, HirDatabase, DefId, Def, name::AsName}; |
11 | use crate::ty::primitive::{UintTy, UncertainIntTy, UncertainFloatTy}; | 13 | use crate::ty::primitive::{UintTy, UncertainIntTy, UncertainFloatTy}; |
@@ -38,10 +40,10 @@ pub struct Body { | |||
38 | #[derive(Debug, Eq, PartialEq)] | 40 | #[derive(Debug, Eq, PartialEq)] |
39 | pub struct BodySyntaxMapping { | 41 | pub struct BodySyntaxMapping { |
40 | body: Arc<Body>, | 42 | body: Arc<Body>, |
41 | expr_syntax_mapping: FxHashMap<LocalSyntaxPtr, ExprId>, | 43 | expr_syntax_mapping: FxHashMap<SyntaxNodePtr, ExprId>, |
42 | expr_syntax_mapping_back: ArenaMap<ExprId, LocalSyntaxPtr>, | 44 | expr_syntax_mapping_back: ArenaMap<ExprId, SyntaxNodePtr>, |
43 | pat_syntax_mapping: FxHashMap<LocalSyntaxPtr, PatId>, | 45 | pat_syntax_mapping: FxHashMap<SyntaxNodePtr, PatId>, |
44 | pat_syntax_mapping_back: ArenaMap<PatId, LocalSyntaxPtr>, | 46 | pat_syntax_mapping_back: ArenaMap<PatId, SyntaxNodePtr>, |
45 | } | 47 | } |
46 | 48 | ||
47 | impl Body { | 49 | impl Body { |
@@ -71,31 +73,31 @@ impl Index<PatId> for Body { | |||
71 | } | 73 | } |
72 | 74 | ||
73 | impl BodySyntaxMapping { | 75 | impl BodySyntaxMapping { |
74 | pub fn expr_syntax(&self, expr: ExprId) -> Option<LocalSyntaxPtr> { | 76 | pub fn expr_syntax(&self, expr: ExprId) -> Option<SyntaxNodePtr> { |
75 | self.expr_syntax_mapping_back.get(expr).cloned() | 77 | self.expr_syntax_mapping_back.get(expr).cloned() |
76 | } | 78 | } |
77 | 79 | ||
78 | pub fn syntax_expr(&self, ptr: LocalSyntaxPtr) -> Option<ExprId> { | 80 | pub fn syntax_expr(&self, ptr: SyntaxNodePtr) -> Option<ExprId> { |
79 | self.expr_syntax_mapping.get(&ptr).cloned() | 81 | self.expr_syntax_mapping.get(&ptr).cloned() |
80 | } | 82 | } |
81 | 83 | ||
82 | pub fn node_expr(&self, node: &ast::Expr) -> Option<ExprId> { | 84 | pub fn node_expr(&self, node: &ast::Expr) -> Option<ExprId> { |
83 | self.expr_syntax_mapping | 85 | self.expr_syntax_mapping |
84 | .get(&LocalSyntaxPtr::new(node.syntax())) | 86 | .get(&SyntaxNodePtr::new(node.syntax())) |
85 | .cloned() | 87 | .cloned() |
86 | } | 88 | } |
87 | 89 | ||
88 | pub fn pat_syntax(&self, pat: PatId) -> Option<LocalSyntaxPtr> { | 90 | pub fn pat_syntax(&self, pat: PatId) -> Option<SyntaxNodePtr> { |
89 | self.pat_syntax_mapping_back.get(pat).cloned() | 91 | self.pat_syntax_mapping_back.get(pat).cloned() |
90 | } | 92 | } |
91 | 93 | ||
92 | pub fn syntax_pat(&self, ptr: LocalSyntaxPtr) -> Option<PatId> { | 94 | pub fn syntax_pat(&self, ptr: SyntaxNodePtr) -> Option<PatId> { |
93 | self.pat_syntax_mapping.get(&ptr).cloned() | 95 | self.pat_syntax_mapping.get(&ptr).cloned() |
94 | } | 96 | } |
95 | 97 | ||
96 | pub fn node_pat(&self, node: &ast::Pat) -> Option<PatId> { | 98 | pub fn node_pat(&self, node: &ast::Pat) -> Option<PatId> { |
97 | self.pat_syntax_mapping | 99 | self.pat_syntax_mapping |
98 | .get(&LocalSyntaxPtr::new(node.syntax())) | 100 | .get(&SyntaxNodePtr::new(node.syntax())) |
99 | .cloned() | 101 | .cloned() |
100 | } | 102 | } |
101 | 103 | ||
@@ -440,10 +442,10 @@ pub(crate) fn body_hir(db: &impl HirDatabase, def_id: DefId) -> Arc<Body> { | |||
440 | struct ExprCollector { | 442 | struct ExprCollector { |
441 | exprs: Arena<ExprId, Expr>, | 443 | exprs: Arena<ExprId, Expr>, |
442 | pats: Arena<PatId, Pat>, | 444 | pats: Arena<PatId, Pat>, |
443 | expr_syntax_mapping: FxHashMap<LocalSyntaxPtr, ExprId>, | 445 | expr_syntax_mapping: FxHashMap<SyntaxNodePtr, ExprId>, |
444 | expr_syntax_mapping_back: ArenaMap<ExprId, LocalSyntaxPtr>, | 446 | expr_syntax_mapping_back: ArenaMap<ExprId, SyntaxNodePtr>, |
445 | pat_syntax_mapping: FxHashMap<LocalSyntaxPtr, PatId>, | 447 | pat_syntax_mapping: FxHashMap<SyntaxNodePtr, PatId>, |
446 | pat_syntax_mapping_back: ArenaMap<PatId, LocalSyntaxPtr>, | 448 | pat_syntax_mapping_back: ArenaMap<PatId, SyntaxNodePtr>, |
447 | } | 449 | } |
448 | 450 | ||
449 | impl ExprCollector { | 451 | impl ExprCollector { |
@@ -458,14 +460,14 @@ impl ExprCollector { | |||
458 | } | 460 | } |
459 | } | 461 | } |
460 | 462 | ||
461 | fn alloc_expr(&mut self, expr: Expr, syntax_ptr: LocalSyntaxPtr) -> ExprId { | 463 | fn alloc_expr(&mut self, expr: Expr, syntax_ptr: SyntaxNodePtr) -> ExprId { |
462 | let id = self.exprs.alloc(expr); | 464 | let id = self.exprs.alloc(expr); |
463 | self.expr_syntax_mapping.insert(syntax_ptr, id); | 465 | self.expr_syntax_mapping.insert(syntax_ptr, id); |
464 | self.expr_syntax_mapping_back.insert(id, syntax_ptr); | 466 | self.expr_syntax_mapping_back.insert(id, syntax_ptr); |
465 | id | 467 | id |
466 | } | 468 | } |
467 | 469 | ||
468 | fn alloc_pat(&mut self, pat: Pat, syntax_ptr: LocalSyntaxPtr) -> PatId { | 470 | fn alloc_pat(&mut self, pat: Pat, syntax_ptr: SyntaxNodePtr) -> PatId { |
469 | let id = self.pats.alloc(pat); | 471 | let id = self.pats.alloc(pat); |
470 | self.pat_syntax_mapping.insert(syntax_ptr, id); | 472 | self.pat_syntax_mapping.insert(syntax_ptr, id); |
471 | self.pat_syntax_mapping_back.insert(id, syntax_ptr); | 473 | self.pat_syntax_mapping_back.insert(id, syntax_ptr); |
@@ -481,7 +483,7 @@ impl ExprCollector { | |||
481 | } | 483 | } |
482 | 484 | ||
483 | fn collect_expr(&mut self, expr: &ast::Expr) -> ExprId { | 485 | fn collect_expr(&mut self, expr: &ast::Expr) -> ExprId { |
484 | let syntax_ptr = LocalSyntaxPtr::new(expr.syntax()); | 486 | let syntax_ptr = SyntaxNodePtr::new(expr.syntax()); |
485 | match expr.kind() { | 487 | match expr.kind() { |
486 | ast::ExprKind::IfExpr(e) => { | 488 | ast::ExprKind::IfExpr(e) => { |
487 | if let Some(pat) = e.condition().and_then(|c| c.pat()) { | 489 | if let Some(pat) = e.condition().and_then(|c| c.pat()) { |
@@ -643,9 +645,9 @@ impl ExprCollector { | |||
643 | // field shorthand | 645 | // field shorthand |
644 | let id = self.exprs.alloc(Expr::Path(Path::from_name_ref(nr))); | 646 | let id = self.exprs.alloc(Expr::Path(Path::from_name_ref(nr))); |
645 | self.expr_syntax_mapping | 647 | self.expr_syntax_mapping |
646 | .insert(LocalSyntaxPtr::new(nr.syntax()), id); | 648 | .insert(SyntaxNodePtr::new(nr.syntax()), id); |
647 | self.expr_syntax_mapping_back | 649 | self.expr_syntax_mapping_back |
648 | .insert(id, LocalSyntaxPtr::new(nr.syntax())); | 650 | .insert(id, SyntaxNodePtr::new(nr.syntax())); |
649 | id | 651 | id |
650 | } else { | 652 | } else { |
651 | self.exprs.alloc(Expr::Missing) | 653 | self.exprs.alloc(Expr::Missing) |
@@ -806,7 +808,7 @@ impl ExprCollector { | |||
806 | let tail = block.expr().map(|e| self.collect_expr(e)); | 808 | let tail = block.expr().map(|e| self.collect_expr(e)); |
807 | self.alloc_expr( | 809 | self.alloc_expr( |
808 | Expr::Block { statements, tail }, | 810 | Expr::Block { statements, tail }, |
809 | LocalSyntaxPtr::new(block.syntax()), | 811 | SyntaxNodePtr::new(block.syntax()), |
810 | ) | 812 | ) |
811 | } | 813 | } |
812 | 814 | ||
@@ -883,7 +885,7 @@ impl ExprCollector { | |||
883 | // TODO: implement | 885 | // TODO: implement |
884 | ast::PatKind::SlicePat(_) | ast::PatKind::RangePat(_) => Pat::Missing, | 886 | ast::PatKind::SlicePat(_) | ast::PatKind::RangePat(_) => Pat::Missing, |
885 | }; | 887 | }; |
886 | let syntax_ptr = LocalSyntaxPtr::new(pat.syntax()); | 888 | let syntax_ptr = SyntaxNodePtr::new(pat.syntax()); |
887 | self.alloc_pat(pattern, syntax_ptr) | 889 | self.alloc_pat(pattern, syntax_ptr) |
888 | } | 890 | } |
889 | 891 | ||
@@ -919,7 +921,7 @@ pub(crate) fn collect_fn_body_syntax(node: &ast::FnDef) -> BodySyntaxMapping { | |||
919 | let mut params = Vec::new(); | 921 | let mut params = Vec::new(); |
920 | 922 | ||
921 | if let Some(self_param) = param_list.self_param() { | 923 | if let Some(self_param) = param_list.self_param() { |
922 | let self_param = LocalSyntaxPtr::new( | 924 | let self_param = SyntaxNodePtr::new( |
923 | self_param | 925 | self_param |
924 | .self_kw() | 926 | .self_kw() |
925 | .expect("self param without self keyword") | 927 | .expect("self param without self keyword") |
diff --git a/crates/ra_hir/src/macros.rs b/crates/ra_hir/src/macros.rs index 220bee94e..7ca34d434 100644 --- a/crates/ra_hir/src/macros.rs +++ b/crates/ra_hir/src/macros.rs | |||
@@ -9,9 +9,8 @@ | |||
9 | /// those yet, so all macros are string based at the moment! | 9 | /// those yet, so all macros are string based at the moment! |
10 | use std::sync::Arc; | 10 | use std::sync::Arc; |
11 | 11 | ||
12 | use ra_db::LocalSyntaxPtr; | ||
13 | use ra_syntax::{ | 12 | use ra_syntax::{ |
14 | TextRange, TextUnit, SourceFile, AstNode, SyntaxNode, TreeArc, | 13 | TextRange, TextUnit, SourceFile, AstNode, SyntaxNode, TreeArc, SyntaxNodePtr, |
15 | ast::{self, NameOwner}, | 14 | ast::{self, NameOwner}, |
16 | }; | 15 | }; |
17 | 16 | ||
@@ -80,7 +79,7 @@ impl MacroDef { | |||
80 | let file = SourceFile::parse(&text); | 79 | let file = SourceFile::parse(&text); |
81 | let match_expr = file.syntax().descendants().find_map(ast::MatchExpr::cast)?; | 80 | let match_expr = file.syntax().descendants().find_map(ast::MatchExpr::cast)?; |
82 | let match_arg = match_expr.expr()?; | 81 | let match_arg = match_expr.expr()?; |
83 | let ptr = LocalSyntaxPtr::new(match_arg.syntax()); | 82 | let ptr = SyntaxNodePtr::new(match_arg.syntax()); |
84 | let src_range = TextRange::offset_len(0.into(), TextUnit::of_str(&input.text)); | 83 | let src_range = TextRange::offset_len(0.into(), TextUnit::of_str(&input.text)); |
85 | let ranges_map = vec![(src_range, match_arg.syntax().range())]; | 84 | let ranges_map = vec![(src_range, match_arg.syntax().range())]; |
86 | let res = MacroExpansion { | 85 | let res = MacroExpansion { |
@@ -94,7 +93,7 @@ impl MacroDef { | |||
94 | let text = format!(r"fn dummy() {{ {}; }}", input.text); | 93 | let text = format!(r"fn dummy() {{ {}; }}", input.text); |
95 | let file = SourceFile::parse(&text); | 94 | let file = SourceFile::parse(&text); |
96 | let array_expr = file.syntax().descendants().find_map(ast::ArrayExpr::cast)?; | 95 | let array_expr = file.syntax().descendants().find_map(ast::ArrayExpr::cast)?; |
97 | let ptr = LocalSyntaxPtr::new(array_expr.syntax()); | 96 | let ptr = SyntaxNodePtr::new(array_expr.syntax()); |
98 | let src_range = TextRange::offset_len(0.into(), TextUnit::of_str(&input.text)); | 97 | let src_range = TextRange::offset_len(0.into(), TextUnit::of_str(&input.text)); |
99 | let ranges_map = vec![(src_range, array_expr.syntax().range())]; | 98 | let ranges_map = vec![(src_range, array_expr.syntax().range())]; |
100 | let res = MacroExpansion { | 99 | let res = MacroExpansion { |
@@ -119,7 +118,7 @@ impl MacroDef { | |||
119 | let file = SourceFile::parse(&text); | 118 | let file = SourceFile::parse(&text); |
120 | let trait_def = file.syntax().descendants().find_map(ast::TraitDef::cast)?; | 119 | let trait_def = file.syntax().descendants().find_map(ast::TraitDef::cast)?; |
121 | let name = trait_def.name()?; | 120 | let name = trait_def.name()?; |
122 | let ptr = LocalSyntaxPtr::new(trait_def.syntax()); | 121 | let ptr = SyntaxNodePtr::new(trait_def.syntax()); |
123 | let ranges_map = vec![(src_range, name.syntax().range())]; | 122 | let ranges_map = vec![(src_range, name.syntax().range())]; |
124 | let res = MacroExpansion { | 123 | let res = MacroExpansion { |
125 | text, | 124 | text, |
@@ -146,7 +145,7 @@ pub struct MacroExpansion { | |||
146 | /// Implementation detail: internally, a macro is expanded to the whole file, | 145 | /// Implementation detail: internally, a macro is expanded to the whole file, |
147 | /// even if it is an expression. This `ptr` selects the actual expansion from | 146 | /// even if it is an expression. This `ptr` selects the actual expansion from |
148 | /// the expanded file. | 147 | /// the expanded file. |
149 | ptr: LocalSyntaxPtr, | 148 | ptr: SyntaxNodePtr, |
150 | } | 149 | } |
151 | 150 | ||
152 | impl MacroExpansion { | 151 | impl MacroExpansion { |
@@ -157,7 +156,7 @@ impl MacroExpansion { | |||
157 | } | 156 | } |
158 | 157 | ||
159 | pub fn syntax(&self) -> TreeArc<SyntaxNode> { | 158 | pub fn syntax(&self) -> TreeArc<SyntaxNode> { |
160 | self.ptr.resolve(&self.file()) | 159 | self.ptr.to_node(&self.file()).to_owned() |
161 | } | 160 | } |
162 | /// Maps range in the source code to the range in the expanded code. | 161 | /// Maps range in the source code to the range in the expanded code. |
163 | pub fn map_range_forward(&self, src_range: TextRange) -> Option<TextRange> { | 162 | pub fn map_range_forward(&self, src_range: TextRange) -> Option<TextRange> { |
diff --git a/crates/ra_hir/src/nameres/lower.rs b/crates/ra_hir/src/nameres/lower.rs index 52448644c..ab6f3a9bc 100644 --- a/crates/ra_hir/src/nameres/lower.rs +++ b/crates/ra_hir/src/nameres/lower.rs | |||
@@ -1,10 +1,10 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | SyntaxKind, AstNode, SourceFile, TreeArc, | 4 | SyntaxKind, AstNode, SourceFile, TreeArc, SyntaxNodePtr, |
5 | ast::{self, ModuleItemOwner}, | 5 | ast::{self, ModuleItemOwner}, |
6 | }; | 6 | }; |
7 | use ra_db::{SourceRootId, LocalSyntaxPtr}; | 7 | use ra_db::{SourceRootId}; |
8 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; | 8 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
@@ -72,13 +72,13 @@ pub struct LoweredModule { | |||
72 | 72 | ||
73 | #[derive(Debug, Default, PartialEq, Eq)] | 73 | #[derive(Debug, Default, PartialEq, Eq)] |
74 | pub struct ImportSourceMap { | 74 | pub struct ImportSourceMap { |
75 | map: ArenaMap<ImportId, LocalSyntaxPtr>, | 75 | map: ArenaMap<ImportId, SyntaxNodePtr>, |
76 | } | 76 | } |
77 | 77 | ||
78 | impl ImportSourceMap { | 78 | impl ImportSourceMap { |
79 | fn insert(&mut self, import: ImportId, segment: &ast::PathSegment) { | 79 | fn insert(&mut self, import: ImportId, segment: &ast::PathSegment) { |
80 | self.map | 80 | self.map |
81 | .insert(import, LocalSyntaxPtr::new(segment.syntax())) | 81 | .insert(import, SyntaxNodePtr::new(segment.syntax())) |
82 | } | 82 | } |
83 | 83 | ||
84 | pub fn get(&self, source: &ModuleSource, import: ImportId) -> TreeArc<ast::PathSegment> { | 84 | pub fn get(&self, source: &ModuleSource, import: ImportId) -> TreeArc<ast::PathSegment> { |
@@ -87,7 +87,7 @@ impl ImportSourceMap { | |||
87 | ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), | 87 | ModuleSource::Module(m) => m.syntax().ancestors().find_map(SourceFile::cast).unwrap(), |
88 | }; | 88 | }; |
89 | 89 | ||
90 | ast::PathSegment::cast(&self.map[import].resolve(file)) | 90 | ast::PathSegment::cast(self.map[import].to_node(file)) |
91 | .unwrap() | 91 | .unwrap() |
92 | .to_owned() | 92 | .to_owned() |
93 | } | 93 | } |
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 9bf1fd3b2..92c74cf00 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -562,7 +562,7 @@ fn infer(content: &str) -> String { | |||
562 | // sort ranges for consistency | 562 | // sort ranges for consistency |
563 | types.sort_by_key(|(ptr, _)| (ptr.range().start(), ptr.range().end())); | 563 | types.sort_by_key(|(ptr, _)| (ptr.range().start(), ptr.range().end())); |
564 | for (syntax_ptr, ty) in &types { | 564 | for (syntax_ptr, ty) in &types { |
565 | let node = syntax_ptr.resolve(&source_file); | 565 | let node = syntax_ptr.to_node(&source_file); |
566 | write!( | 566 | write!( |
567 | acc, | 567 | acc, |
568 | "{} '{}': {}\n", | 568 | "{} '{}': {}\n", |