diff --git a/crates/ra_fmt2/src/fmt_diff.rs b/crates/ra_fmt2/src/fmt_diff.rs deleted file mode 100644 index 703732b43031..000000000000 --- a/crates/ra_fmt2/src/fmt_diff.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::trav_util::walk_tokens; - -use ra_syntax::{SyntaxNode, TextRange, SmolStr}; - -/// The result of formatting. -/// -/// From this Diff, you can get either the resulting `String`, or the -/// reformatted syntax node. -#[derive(Debug)] -pub struct FmtDiff { - original_node: SyntaxNode, - edits: Vec, -} - -#[derive(Debug, Clone, PartialEq, Eq)] -struct AtomEdit { - delete: TextRange, - insert: SmolStr, -} - -impl FmtDiff { - - pub fn reformat_node(node: &SyntaxNode) -> Self { - let spacing = rules::spacing(); - engine::format_pass(space_rules: &SpacingDsl, root: &SyntaxNode) - } - - fn replace(&mut self, range: TextRange, text: SmolStr) { - self.edits.push(AtomEdit { delete: range, insert: text }) - } -} diff --git a/crates/ra_fmt2/src/fmt_model.rs b/crates/ra_fmt2/src/fmt_model.rs index e357e282d853..14c0ec539a2d 100644 --- a/crates/ra_fmt2/src/fmt_model.rs +++ b/crates/ra_fmt2/src/fmt_model.rs @@ -1,25 +1,14 @@ +use crate::edit_tree::EditTree; + use ra_syntax::{ NodeOrToken, SmolStr, SyntaxElement, TextUnit, - SyntaxKind::*, + SyntaxKind::{self, *}, SyntaxNode, SyntaxToken, T, WalkEvent, TextRange, }; -use std::collections::HashMap; - -// TODO make more like intellij's fmt model -// Model holds immutable tree and mutable intermediate model to produce diff -// the model will probably have to create its own tree to add the extra -// info to each token/node: -// -// [1,2,3]; -// can be Brace token, ident, comma all of which knows their own rules and apply -// them accordingly to produce [1, 2, 3]; ??? -#[derive(Debug)] -struct EditTree { - -} +use std::collections::HashMap; #[derive(Debug)] pub(super) struct FmtModel { diff --git a/crates/ra_fmt2/src/pattern.rs b/crates/ra_fmt2/src/pattern.rs index e80af858c7b6..8829c3a9cf52 100644 --- a/crates/ra_fmt2/src/pattern.rs +++ b/crates/ra_fmt2/src/pattern.rs @@ -117,6 +117,7 @@ from_array!(0, 1, 2, 3, 4, 5, 6, 7, 8); /// /// This is generic over `P: AsRef`, so it works with any type which /// contains a pattern. +#[derive(Debug)] pub(crate) struct PatternSet

{ by_kind: HashMap>, unconstrained: Vec

, @@ -147,7 +148,7 @@ impl<'a, P: AsRef> PatternSet<&'a P> { self.by_kind .get(&element.kind()) .into_iter() - //.inspect(|n| println!("{:?}", n)) //TODO LOOK AT PATTERN AND KIND + //.inspect(|n| println!("{:?}", n)) // TODO LOOK AT PATTERN AND KIND .flat_map(|vec| vec.iter()) .chain(self.unconstrained.iter()) .map(|&p| p)