diff options
Diffstat (limited to 'crates/ra_syntax/src/parsing/reparsing.rs')
-rw-r--r-- | crates/ra_syntax/src/parsing/reparsing.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs index f2d218ab9..2c860b3df 100644 --- a/crates/ra_syntax/src/parsing/reparsing.rs +++ b/crates/ra_syntax/src/parsing/reparsing.rs | |||
@@ -5,7 +5,7 @@ use crate::{ | |||
5 | syntax_error::SyntaxError, | 5 | syntax_error::SyntaxError, |
6 | parsing::{ | 6 | parsing::{ |
7 | grammar, parse_with, | 7 | grammar, parse_with, |
8 | builder::GreenBuilder, | 8 | builder::TreeBuilder, |
9 | parser::Parser, | 9 | parser::Parser, |
10 | lexer::{tokenize, Token}, | 10 | lexer::{tokenize, Token}, |
11 | } | 11 | } |
@@ -61,7 +61,8 @@ fn reparse_block<'node>( | |||
61 | if !is_balanced(&tokens) { | 61 | if !is_balanced(&tokens) { |
62 | return None; | 62 | return None; |
63 | } | 63 | } |
64 | let (green, new_errors) = parse_with(GreenBuilder::default(), &text, &tokens, reparser); | 64 | let tree_sink = TreeBuilder::new(&text, &tokens); |
65 | let (green, new_errors) = parse_with(tree_sink, &text, &tokens, reparser); | ||
65 | Some((node, green, new_errors)) | 66 | Some((node, green, new_errors)) |
66 | } | 67 | } |
67 | 68 | ||
@@ -82,7 +83,11 @@ fn find_reparsable_node( | |||
82 | range: TextRange, | 83 | range: TextRange, |
83 | ) -> Option<(&SyntaxNode, fn(&mut Parser))> { | 84 | ) -> Option<(&SyntaxNode, fn(&mut Parser))> { |
84 | let node = algo::find_covering_node(node, range); | 85 | let node = algo::find_covering_node(node, range); |
85 | node.ancestors().find_map(|node| grammar::reparser(node).map(|r| (node, r))) | 86 | node.ancestors().find_map(|node| { |
87 | let first_child = node.first_child().map(|it| it.kind()); | ||
88 | let parent = node.parent().map(|it| it.kind()); | ||
89 | grammar::reparser(node.kind(), first_child, parent).map(|r| (node, r)) | ||
90 | }) | ||
86 | } | 91 | } |
87 | 92 | ||
88 | fn is_balanced(tokens: &[Token]) -> bool { | 93 | fn is_balanced(tokens: &[Token]) -> bool { |