mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
correctly handle IDENTs when changed to contextual keywords
This commit is contained in:
parent
c300135322
commit
bc94bf95ce
1 changed files with 15 additions and 1 deletions
|
@ -100,7 +100,12 @@ impl File {
|
||||||
| RAW_STRING => {
|
| RAW_STRING => {
|
||||||
let text = get_text_after_edit(node, &edit);
|
let text = get_text_after_edit(node, &edit);
|
||||||
let tokens = tokenize(&text);
|
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;
|
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))> {
|
fn find_reparsable_node(node: SyntaxNodeRef, range: TextRange) -> Option<(SyntaxNodeRef, fn(&mut Parser))> {
|
||||||
let node = algo::find_covering_node(node, range);
|
let node = algo::find_covering_node(node, range);
|
||||||
return algo::ancestors(node)
|
return algo::ancestors(node)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue