mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
correctly handle IDENTs when changed to contextual keywords
This commit is contained in:
parent
c300135322
commit
bc94bf95ce
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user