aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/lib.rs
diff options
context:
space:
mode:
authordarksv <[email protected]>2018-09-14 18:26:48 +0100
committerdarksv <[email protected]>2018-09-14 18:26:48 +0100
commitbc94bf95ce858ef247ebee006d50cfdc33f6bf5f (patch)
tree15063d69790346368b6a7ff8d12fb5778f5d72ab /crates/libsyntax2/src/lib.rs
parentc300135322730cd685b03d1adc8b8c7c7e714b0a (diff)
correctly handle IDENTs when changed to contextual keywords
Diffstat (limited to 'crates/libsyntax2/src/lib.rs')
-rw-r--r--crates/libsyntax2/src/lib.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/libsyntax2/src/lib.rs b/crates/libsyntax2/src/lib.rs
index d124d3284..7c9fbc421 100644
--- a/crates/libsyntax2/src/lib.rs
+++ b/crates/libsyntax2/src/lib.rs
@@ -100,7 +100,12 @@ impl File {
100 | RAW_STRING => { 100 | RAW_STRING => {
101 let text = get_text_after_edit(node, &edit); 101 let text = get_text_after_edit(node, &edit);
102 let tokens = tokenize(&text); 102 let tokens = tokenize(&text);
103 if tokens.len() != 1 || tokens[0].kind != node.kind() { 103 let token = match tokens[..] {
104 [token] if token.kind == node.kind() => token,
105 _ => return None,
106 };
107
108 if token.kind == IDENT && is_contextual_kw(&text) {
104 return None; 109 return None;
105 } 110 }
106 111
@@ -167,6 +172,15 @@ fn get_text_after_edit(node: SyntaxNodeRef, edit: &AtomEdit) -> String {
167 ) 172 )
168} 173}
169 174
175fn is_contextual_kw(text: &str) -> bool {
176 match text {
177 | "auto"
178 | "default"
179 | "union" => true,
180 _ => false,
181 }
182}
183
170fn find_reparsable_node(node: SyntaxNodeRef, range: TextRange) -> Option<(SyntaxNodeRef, fn(&mut Parser))> { 184fn find_reparsable_node(node: SyntaxNodeRef, range: TextRange) -> Option<(SyntaxNodeRef, fn(&mut Parser))> {
171 let node = algo::find_covering_node(node, range); 185 let node = algo::find_covering_node(node, range);
172 return algo::ancestors(node) 186 return algo::ancestors(node)