aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/algo.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-01-10 17:26:18 +0000
committerFlorian Diebold <[email protected]>2020-01-11 22:33:04 +0000
commit15fc643e05bf8273e378243edbfb3be7aea7ce11 (patch)
tree9b5bad379840dd25b548158ad962fadd31c54d33 /crates/ra_syntax/src/algo.rs
parent12905e5b58f22df026ef30afa6f0bdf7319cbddd (diff)
Fix ordering problem between qualifying paths and substituting params
Diffstat (limited to 'crates/ra_syntax/src/algo.rs')
-rw-r--r--crates/ra_syntax/src/algo.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/ra_syntax/src/algo.rs b/crates/ra_syntax/src/algo.rs
index 2b2b295f9..30a479f01 100644
--- a/crates/ra_syntax/src/algo.rs
+++ b/crates/ra_syntax/src/algo.rs
@@ -184,17 +184,17 @@ pub fn replace_children(
184/// to create a type-safe abstraction on top of it instead. 184/// to create a type-safe abstraction on top of it instead.
185pub fn replace_descendants( 185pub fn replace_descendants(
186 parent: &SyntaxNode, 186 parent: &SyntaxNode,
187 map: &FxHashMap<SyntaxElement, SyntaxElement>, 187 map: &impl Fn(&SyntaxElement) -> Option<SyntaxElement>,
188) -> SyntaxNode { 188) -> SyntaxNode {
189 // FIXME: this could be made much faster. 189 // FIXME: this could be made much faster.
190 let new_children = parent.children_with_tokens().map(|it| go(map, it)).collect::<Vec<_>>(); 190 let new_children = parent.children_with_tokens().map(|it| go(map, it)).collect::<Vec<_>>();
191 return with_children(parent, new_children); 191 return with_children(parent, new_children);
192 192
193 fn go( 193 fn go(
194 map: &FxHashMap<SyntaxElement, SyntaxElement>, 194 map: &impl Fn(&SyntaxElement) -> Option<SyntaxElement>,
195 element: SyntaxElement, 195 element: SyntaxElement,
196 ) -> NodeOrToken<rowan::GreenNode, rowan::GreenToken> { 196 ) -> NodeOrToken<rowan::GreenNode, rowan::GreenToken> {
197 if let Some(replacement) = map.get(&element) { 197 if let Some(replacement) = map(&element) {
198 return match replacement { 198 return match replacement {
199 NodeOrToken::Node(it) => NodeOrToken::Node(it.green().clone()), 199 NodeOrToken::Node(it) => NodeOrToken::Node(it.green().clone()),
200 NodeOrToken::Token(it) => NodeOrToken::Token(it.green().clone()), 200 NodeOrToken::Token(it) => NodeOrToken::Token(it.green().clone()),