From 880ddddfe6937c11059e9673050ea8c4ed40ff5b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 8 May 2021 19:54:03 +0300 Subject: dead code --- crates/syntax/src/algo.rs | 122 +--------------------------------------------- 1 file changed, 1 insertion(+), 121 deletions(-) (limited to 'crates') diff --git a/crates/syntax/src/algo.rs b/crates/syntax/src/algo.rs index ba263be0d..3f9b84ab9 100644 --- a/crates/syntax/src/algo.rs +++ b/crates/syntax/src/algo.rs @@ -1,10 +1,6 @@ //! FIXME: write short doc here -use std::{ - fmt, - hash::BuildHasherDefault, - ops::{self, RangeInclusive}, -}; +use std::{fmt, hash::BuildHasherDefault, ops::RangeInclusive}; use indexmap::IndexMap; use itertools::Itertools; @@ -358,107 +354,11 @@ impl fmt::Debug for SyntaxRewriter<'_> { } impl SyntaxRewriter<'_> { - pub fn delete>(&mut self, what: &T) { - let what = what.clone().into(); - let replacement = Replacement::Delete; - self.replacements.insert(what, replacement); - } - pub fn insert_before, U: Clone + Into>( - &mut self, - before: &T, - what: &U, - ) { - let before = before.clone().into(); - let pos = match before.prev_sibling_or_token() { - Some(sibling) => InsertPos::After(sibling), - None => match before.parent() { - Some(parent) => InsertPos::FirstChildOf(parent), - None => return, - }, - }; - self.insertions.entry(pos).or_insert_with(Vec::new).push(what.clone().into()); - } - pub fn insert_after, U: Clone + Into>( - &mut self, - after: &T, - what: &U, - ) { - self.insertions - .entry(InsertPos::After(after.clone().into())) - .or_insert_with(Vec::new) - .push(what.clone().into()); - } - pub fn insert_as_first_child, U: Clone + Into>( - &mut self, - parent: &T, - what: &U, - ) { - self.insertions - .entry(InsertPos::FirstChildOf(parent.clone().into())) - .or_insert_with(Vec::new) - .push(what.clone().into()); - } - pub fn insert_many_before< - T: Clone + Into, - U: IntoIterator, - >( - &mut self, - before: &T, - what: U, - ) { - let before = before.clone().into(); - let pos = match before.prev_sibling_or_token() { - Some(sibling) => InsertPos::After(sibling), - None => match before.parent() { - Some(parent) => InsertPos::FirstChildOf(parent), - None => return, - }, - }; - self.insertions.entry(pos).or_insert_with(Vec::new).extend(what); - } - pub fn insert_many_after< - T: Clone + Into, - U: IntoIterator, - >( - &mut self, - after: &T, - what: U, - ) { - self.insertions - .entry(InsertPos::After(after.clone().into())) - .or_insert_with(Vec::new) - .extend(what); - } - pub fn insert_many_as_first_children< - T: Clone + Into, - U: IntoIterator, - >( - &mut self, - parent: &T, - what: U, - ) { - self.insertions - .entry(InsertPos::FirstChildOf(parent.clone().into())) - .or_insert_with(Vec::new) - .extend(what) - } pub fn replace>(&mut self, what: &T, with: &T) { let what = what.clone().into(); let replacement = Replacement::Single(with.clone().into()); self.replacements.insert(what, replacement); } - pub fn replace_with_many>( - &mut self, - what: &T, - with: Vec, - ) { - let what = what.clone().into(); - let replacement = Replacement::Many(with); - self.replacements.insert(what, replacement); - } - pub fn replace_ast(&mut self, what: &T, with: &T) { - self.replace(what.syntax(), with.syntax()) - } pub fn rewrite(&self, node: &SyntaxNode) -> SyntaxNode { let _p = profile::span("rewrite"); @@ -534,10 +434,6 @@ impl SyntaxRewriter<'_> { if let Some(replacement) = self.replacement(&element) { match replacement { Replacement::Single(element) => acc.push(element_to_green(element)), - Replacement::Many(replacements) => { - acc.extend(replacements.into_iter().map(element_to_green)) - } - Replacement::Delete => (), }; } else { match element { @@ -560,25 +456,9 @@ fn element_to_green(element: SyntaxElement) -> NodeOrToken { - fn add_assign(&mut self, rhs: SyntaxRewriter) { - self.replacements.extend(rhs.replacements); - for (pos, insertions) in rhs.insertions.into_iter() { - match self.insertions.entry(pos) { - indexmap::map::Entry::Occupied(mut occupied) => { - occupied.get_mut().extend(insertions) - } - indexmap::map::Entry::Vacant(vacant) => drop(vacant.insert(insertions)), - } - } - } -} - #[derive(Clone, Debug)] enum Replacement { - Delete, Single(SyntaxElement), - Many(Vec), } fn with_children( -- cgit v1.2.3