correctly handle IDENTs when changed to contextual keywords

This commit is contained in:
darksv 2018-09-14 19:26:48 +02:00
parent c300135322
commit bc94bf95ce

View File

@ -100,7 +100,12 @@ impl File {
| RAW_STRING => {
let text = get_text_after_edit(node, &edit);
let tokens = tokenize(&text);
if tokens.len() != 1 || tokens[0].kind != node.kind() {
let token = match tokens[..] {
[token] if token.kind == node.kind() => token,
_ => return None,
};
if token.kind == IDENT && is_contextual_kw(&text) {
return None;
}
@ -167,6 +172,15 @@ fn get_text_after_edit(node: SyntaxNodeRef, edit: &AtomEdit) -> String {
)
}
fn is_contextual_kw(text: &str) -> bool {
match text {
| "auto"
| "default"
| "union" => true,
_ => false,
}
}
fn find_reparsable_node(node: SyntaxNodeRef, range: TextRange) -> Option<(SyntaxNodeRef, fn(&mut Parser))> {
let node = algo::find_covering_node(node, range);
return algo::ancestors(node)