aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ssr/src/resolving.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ssr/src/resolving.rs')
-rw-r--r--crates/ra_ssr/src/resolving.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ra_ssr/src/resolving.rs
index e9d052111..63fd217ce 100644
--- a/crates/ra_ssr/src/resolving.rs
+++ b/crates/ra_ssr/src/resolving.rs
@@ -22,6 +22,7 @@ pub(crate) struct ResolvedPattern {
22 22
23pub(crate) struct ResolvedPath { 23pub(crate) struct ResolvedPath {
24 pub(crate) resolution: hir::PathResolution, 24 pub(crate) resolution: hir::PathResolution,
25 pub(crate) depth: u32,
25} 26}
26 27
27impl ResolvedRule { 28impl ResolvedRule {
@@ -62,7 +63,7 @@ struct Resolver<'a, 'db> {
62impl Resolver<'_, '_> { 63impl Resolver<'_, '_> {
63 fn resolve_pattern_tree(&self, pattern: SyntaxNode) -> Result<ResolvedPattern, SsrError> { 64 fn resolve_pattern_tree(&self, pattern: SyntaxNode) -> Result<ResolvedPattern, SsrError> {
64 let mut resolved_paths = FxHashMap::default(); 65 let mut resolved_paths = FxHashMap::default();
65 self.resolve(pattern.clone(), &mut resolved_paths)?; 66 self.resolve(pattern.clone(), 0, &mut resolved_paths)?;
66 Ok(ResolvedPattern { 67 Ok(ResolvedPattern {
67 node: pattern, 68 node: pattern,
68 resolved_paths, 69 resolved_paths,
@@ -73,6 +74,7 @@ impl Resolver<'_, '_> {
73 fn resolve( 74 fn resolve(
74 &self, 75 &self,
75 node: SyntaxNode, 76 node: SyntaxNode,
77 depth: u32,
76 resolved_paths: &mut FxHashMap<SyntaxNode, ResolvedPath>, 78 resolved_paths: &mut FxHashMap<SyntaxNode, ResolvedPath>,
77 ) -> Result<(), SsrError> { 79 ) -> Result<(), SsrError> {
78 use ra_syntax::ast::AstNode; 80 use ra_syntax::ast::AstNode;
@@ -86,12 +88,12 @@ impl Resolver<'_, '_> {
86 let resolution = self 88 let resolution = self
87 .resolve_path(&path) 89 .resolve_path(&path)
88 .ok_or_else(|| error!("Failed to resolve path `{}`", node.text()))?; 90 .ok_or_else(|| error!("Failed to resolve path `{}`", node.text()))?;
89 resolved_paths.insert(node, ResolvedPath { resolution }); 91 resolved_paths.insert(node, ResolvedPath { resolution, depth });
90 return Ok(()); 92 return Ok(());
91 } 93 }
92 } 94 }
93 for node in node.children() { 95 for node in node.children() {
94 self.resolve(node, resolved_paths)?; 96 self.resolve(node, depth + 1, resolved_paths)?;
95 } 97 }
96 Ok(()) 98 Ok(())
97 } 99 }