From 2b6012a79cb092e5d88c050cb494057efef28fc2 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 20 Nov 2021 18:56:26 +0530 Subject: introduce --config flag --- bin/src/fix.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'bin/src/fix.rs') 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 @@ use std::borrow::Cow; +use crate::LintMap; + use rnix::TextRange; mod all; -use all::all; +use all::all_with; mod single; use single::single; type Source<'a> = Cow<'a, str>; -#[derive(Debug)] pub struct FixResult<'a> { pub src: Source<'a>, pub fixed: Vec, + pub lints: &'a LintMap, } #[derive(Debug, Clone)] @@ -23,10 +25,11 @@ pub struct Fixed { } impl<'a> FixResult<'a> { - fn empty(src: Source<'a>) -> Self { + fn empty(src: Source<'a>, lints: &'a LintMap) -> Self { Self { src, fixed: Vec::new(), + lints, } } } @@ -43,8 +46,9 @@ pub mod main { pub fn all(fix_config: FixConfig) -> Result<(), StatixErr> { let vfs = fix_config.vfs()?; + let lints = fix_config.lints()?; for entry in vfs.iter() { - match (fix_config.out(), super::all(entry.contents)) { + match (fix_config.out(), super::all_with(entry.contents, &lints)) { (FixOut::Diff, fix_result) => { let src = fix_result .map(|r| r.src) -- cgit v1.2.3