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.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ra_ssr/src/resolving.rs
index 63fd217ce..75f556785 100644
--- a/crates/ra_ssr/src/resolving.rs
+++ b/crates/ra_ssr/src/resolving.rs
@@ -18,10 +18,12 @@ pub(crate) struct ResolvedPattern {
18 pub(crate) node: SyntaxNode, 18 pub(crate) node: SyntaxNode,
19 // Paths in `node` that we've resolved. 19 // Paths in `node` that we've resolved.
20 pub(crate) resolved_paths: FxHashMap<SyntaxNode, ResolvedPath>, 20 pub(crate) resolved_paths: FxHashMap<SyntaxNode, ResolvedPath>,
21 pub(crate) ufcs_function_calls: FxHashMap<SyntaxNode, hir::Function>,
21} 22}
22 23
23pub(crate) struct ResolvedPath { 24pub(crate) struct ResolvedPath {
24 pub(crate) resolution: hir::PathResolution, 25 pub(crate) resolution: hir::PathResolution,
26 /// The depth of the ast::Path that was resolved within the pattern.
25 pub(crate) depth: u32, 27 pub(crate) depth: u32,
26} 28}
27 29
@@ -64,10 +66,26 @@ impl Resolver<'_, '_> {
64 fn resolve_pattern_tree(&self, pattern: SyntaxNode) -> Result<ResolvedPattern, SsrError> { 66 fn resolve_pattern_tree(&self, pattern: SyntaxNode) -> Result<ResolvedPattern, SsrError> {
65 let mut resolved_paths = FxHashMap::default(); 67 let mut resolved_paths = FxHashMap::default();
66 self.resolve(pattern.clone(), 0, &mut resolved_paths)?; 68 self.resolve(pattern.clone(), 0, &mut resolved_paths)?;
69 let ufcs_function_calls = resolved_paths
70 .iter()
71 .filter_map(|(path_node, resolved)| {
72 if let Some(grandparent) = path_node.parent().and_then(|parent| parent.parent()) {
73 if grandparent.kind() == SyntaxKind::CALL_EXPR {
74 if let hir::PathResolution::AssocItem(hir::AssocItem::Function(function)) =
75 &resolved.resolution
76 {
77 return Some((grandparent, *function));
78 }
79 }
80 }
81 None
82 })
83 .collect();
67 Ok(ResolvedPattern { 84 Ok(ResolvedPattern {
68 node: pattern, 85 node: pattern,
69 resolved_paths, 86 resolved_paths,
70 placeholders_by_stand_in: self.placeholders_by_stand_in.clone(), 87 placeholders_by_stand_in: self.placeholders_by_stand_in.clone(),
88 ufcs_function_calls,
71 }) 89 })
72 } 90 }
73 91