make grammar independent of syntax tree

This commit is contained in:
Aleksey Kladov 2019-02-21 12:12:04 +03:00
parent 1b2e70df99
commit cd0d2866fc
2 changed files with 18 additions and 14 deletions

View file

@ -83,7 +83,11 @@ fn find_reparsable_node(
range: TextRange,
) -> Option<(&SyntaxNode, fn(&mut Parser))> {
let node = algo::find_covering_node(node, range);
node.ancestors().find_map(|node| grammar::reparser(node).map(|r| (node, r)))
node.ancestors().find_map(|node| {
let first_child = node.first_child().map(|it| it.kind());
let parent = node.parent().map(|it| it.kind());
grammar::reparser(node.kind(), first_child, parent).map(|r| (node, r))
})
}
fn is_balanced(tokens: &[Token]) -> bool {