mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
extract AtomEdit and Edit into new ra_text_edit crate
This commit is contained in:
parent
f655f993fe
commit
7344d28768
19 changed files with 81 additions and 40 deletions
|
@ -6,29 +6,7 @@ use crate::parser_impl;
|
|||
use crate::text_utils::replace_range;
|
||||
use crate::yellow::{self, GreenNode, SyntaxError, SyntaxNodeRef};
|
||||
use crate::{SyntaxKind::*, TextRange, TextUnit};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AtomEdit {
|
||||
pub delete: TextRange,
|
||||
pub insert: String,
|
||||
}
|
||||
|
||||
impl AtomEdit {
|
||||
pub fn replace(range: TextRange, replace_with: String) -> AtomEdit {
|
||||
AtomEdit {
|
||||
delete: range,
|
||||
insert: replace_with,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn delete(range: TextRange) -> AtomEdit {
|
||||
AtomEdit::replace(range, String::new())
|
||||
}
|
||||
|
||||
pub fn insert(offset: TextUnit, text: String) -> AtomEdit {
|
||||
AtomEdit::replace(TextRange::offset_len(offset, 0.into()), text)
|
||||
}
|
||||
}
|
||||
use ra_text_edit::AtomEdit;
|
||||
|
||||
pub(crate) fn incremental_reparse(
|
||||
node: SyntaxNodeRef,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue