aboutsummaryrefslogtreecommitdiff
path: root/bin/src/fix.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/src/fix.rs')
-rw-r--r--bin/src/fix.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/bin/src/fix.rs b/bin/src/fix.rs
index e4ea94d..4268567 100644
--- a/bin/src/fix.rs
+++ b/bin/src/fix.rs
@@ -1,19 +1,21 @@
1use std::borrow::Cow; 1use std::borrow::Cow;
2 2
3use crate::LintMap;
4
3use rnix::TextRange; 5use rnix::TextRange;
4 6
5mod all; 7mod all;
6use all::all; 8use all::all_with;
7 9
8mod single; 10mod single;
9use single::single; 11use single::single;
10 12
11type Source<'a> = Cow<'a, str>; 13type Source<'a> = Cow<'a, str>;
12 14
13#[derive(Debug)]
14pub struct FixResult<'a> { 15pub struct FixResult<'a> {
15 pub src: Source<'a>, 16 pub src: Source<'a>,
16 pub fixed: Vec<Fixed>, 17 pub fixed: Vec<Fixed>,
18 pub lints: &'a LintMap,
17} 19}
18 20
19#[derive(Debug, Clone)] 21#[derive(Debug, Clone)]
@@ -23,10 +25,11 @@ pub struct Fixed {
23} 25}
24 26
25impl<'a> FixResult<'a> { 27impl<'a> FixResult<'a> {
26 fn empty(src: Source<'a>) -> Self { 28 fn empty(src: Source<'a>, lints: &'a LintMap) -> Self {
27 Self { 29 Self {
28 src, 30 src,
29 fixed: Vec::new(), 31 fixed: Vec::new(),
32 lints,
30 } 33 }
31 } 34 }
32} 35}
@@ -43,8 +46,9 @@ pub mod main {
43 46
44 pub fn all(fix_config: FixConfig) -> Result<(), StatixErr> { 47 pub fn all(fix_config: FixConfig) -> Result<(), StatixErr> {
45 let vfs = fix_config.vfs()?; 48 let vfs = fix_config.vfs()?;
49 let lints = fix_config.lints()?;
46 for entry in vfs.iter() { 50 for entry in vfs.iter() {
47 match (fix_config.out(), super::all(entry.contents)) { 51 match (fix_config.out(), super::all_with(entry.contents, &lints)) {
48 (FixOut::Diff, fix_result) => { 52 (FixOut::Diff, fix_result) => {
49 let src = fix_result 53 let src = fix_result
50 .map(|r| r.src) 54 .map(|r| r.src)