get matches from code.descendants

This commit is contained in:
adamrk 2020-02-25 23:53:29 +01:00
parent 94603d9848
commit b1ee6d17a4

View File

@ -223,15 +223,17 @@ fn find(pattern: &SsrPattern, code: &SyntaxNode) -> SsrMatches {
}
let kind = pattern.pattern.kind();
let matches = code
.descendants_with_tokens()
.descendants()
.filter(|n| n.kind() == kind)
.filter_map(|code| {
let match_ = Match {
place: code.as_node().unwrap().clone(),
binding: HashMap::new(),
ignored_comments: vec![],
};
check(&SyntaxElement::from(pattern.pattern.clone()), &code, &pattern.vars, match_)
let match_ =
Match { place: code.clone(), binding: HashMap::new(), ignored_comments: vec![] };
check(
&SyntaxElement::from(pattern.pattern.clone()),
&SyntaxElement::from(code),
&pattern.vars,
match_,
)
})
.collect();
SsrMatches { matches }