Skip to content

Commit

Permalink
[WIP] init ra-fmt2 for issue rust-lang#1665
Browse files Browse the repository at this point in the history
  • Loading branch information
DevinR528 committed Jan 10, 2020
1 parent 871c266 commit cf6e6c6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 47 deletions.
31 changes: 0 additions & 31 deletions crates/ra_fmt2/src/fmt_diff.rs

This file was deleted.

19 changes: 4 additions & 15 deletions crates/ra_fmt2/src/fmt_model.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion crates/ra_fmt2/src/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ from_array!(0, 1, 2, 3, 4, 5, 6, 7, 8);
///
/// This is generic over `P: AsRef<Pattern>`, so it works with any type which
/// contains a pattern.
#[derive(Debug)]
pub(crate) struct PatternSet<P> {
by_kind: HashMap<SyntaxKind, Vec<P>>,
unconstrained: Vec<P>,
Expand Down Expand Up @@ -147,7 +148,7 @@ impl<'a, P: AsRef<Pattern>> 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)
Expand Down

0 comments on commit cf6e6c6

Please sign in to comment.