Add always disabled gen parse support

This commit is contained in:
Lukas Wirth 2024-07-17 10:49:12 +02:00
parent 983c9c122e
commit 7011094685
32 changed files with 376 additions and 55 deletions

View file

@ -6,7 +6,7 @@
//! - otherwise, we search for the nearest `{}` block which contains the edit
//! and try to parse only this block.
use parser::Reparser;
use parser::{Edition, Reparser};
use text_edit::Indel;
use crate::{
@ -51,7 +51,8 @@ fn reparse_token(
}
let mut new_text = get_text_after_edit(prev_token.clone().into(), edit);
let (new_token_kind, new_err) = parser::LexedStr::single_token(&new_text)?;
let (new_token_kind, new_err) =
parser::LexedStr::single_token(Edition::CURRENT, &new_text)?;
if new_token_kind != prev_token_kind
|| (new_token_kind == IDENT && is_contextual_kw(&new_text))
@ -64,7 +65,8 @@ fn reparse_token(
// `b` no longer remains an identifier, but becomes a part of byte string literal
if let Some(next_char) = root.text().char_at(prev_token.text_range().end()) {
new_text.push(next_char);
let token_with_next_char = parser::LexedStr::single_token(&new_text);
let token_with_next_char =
parser::LexedStr::single_token(Edition::CURRENT, &new_text);
if let Some((_kind, _error)) = token_with_next_char {
return None;
}
@ -91,7 +93,7 @@ fn reparse_block(
let (node, reparser) = find_reparsable_node(root, edit.delete)?;
let text = get_text_after_edit(node.clone().into(), edit);
let lexed = parser::LexedStr::new(text.as_str());
let lexed = parser::LexedStr::new(Edition::CURRENT, text.as_str());
let parser_input = lexed.to_input();
if !is_balanced(&lexed) {
return None;