Skip to content

Commit

Permalink
Start hacking checkstyle output in.
Browse files Browse the repository at this point in the history
checkstyle now shows up on the option parser, and the code still
compiles/passes tests. Next up will be outputing the XML to stdout.
  • Loading branch information
markstory committed Jan 14, 2016
1 parent 3f7741b commit 0c9f27f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bin/rustfmt.rs
Expand Up @@ -90,7 +90,7 @@ fn execute() -> i32 {
opts.optopt("",
"write-mode",
"mode to write in (not usable when piping from stdin)",
"[replace|overwrite|display|diff|coverage]");
"[replace|overwrite|display|diff|coverage|checkstyle]");
opts.optflag("", "skip-children", "don't reformat child modules");

opts.optflag("",
Expand Down
2 changes: 2 additions & 0 deletions src/config.rs
Expand Up @@ -136,6 +136,8 @@ configuration_option_enum! { WriteMode:
Coverage,
// Unfancy stdout
Plain,
// Output a checkstyle XML file.
Checkstyle,
}

// This trait and the following impl blocks are there so that we an use
Expand Down
14 changes: 14 additions & 0 deletions src/filemap.rs
Expand Up @@ -38,6 +38,7 @@ pub fn write_all_files(file_map: &FileMap,
try!(write_file(&file_map[filename], filename, mode, config));
}

// Output trailers for write mode.
Ok(())
}

Expand Down Expand Up @@ -142,6 +143,19 @@ pub fn write_file(text: &StringBuffer,
WriteMode::Default => {
unreachable!("The WriteMode should NEVER Be default at this point!");
}
WriteMode::Checkstyle => {
// Generate the diff for the current file.
// Output the XML tags for the lines that are different.
// Use the new text as 'should be X'.
}
WriteMode::Return => {
// io::Write is not implemented for String, working around with
// Vec<u8>
let mut v = Vec::new();
try!(write_system_newlines(&mut v, text, config));
// won't panic, we are writing correct utf8
return Ok(Some(String::from_utf8(v).unwrap()));
}
}

Ok(None)
Expand Down

0 comments on commit 0c9f27f

Please sign in to comment.