Commit graph

32 commits

Author SHA1 Message Date
Nick Cameron
77ceba2bc0 Write to the supplied buffer if one is supplied to format_input 2016-09-27 17:25:54 +13:00
juicejitsu
a0de408198 Don't emit filename in diff mode, add filename to diff metadata 2016-08-09 18:21:04 -07:00
Johann Hofmann
8260d277c8
Return failure exit code on found diffs (fix #906)
This changes rustfmt to return exit code 4
when run with write mode diff and differences between
the formatted code and the original code are found.

Useful for CI to make sure your contributors actually ran rustfmt.
2016-06-21 23:01:15 +02:00
Nick Cameron
9b05461666 Write each file as it is formatted (#991)
The old behaviour stored everything in memory until we were finished. Now we write as soon as we can.

This gives better behaviour when formatting large programs, since there is some progress indication. It also opens the door to optimising memory use by not storing everything in memory unless it is required (which it still might be). That is left as future work though.
2016-05-15 11:41:05 +02:00
Daniel Campbell
4a2db3ec6c Changed modules & visitor mods to public, set filemap::write_file public 2016-05-06 12:44:18 +12:00
Aleksey Kladov
84fb2f402e refactor: unify run and run_from_stdin 2016-04-02 22:24:38 +03:00
Aleksey Kladov
294b463b5d minor: use &mut ref instead of by value argument
This also unifies `write_all_files` and `write_file` functions
2016-04-02 19:36:56 +03:00
Kamal Marhubi
14dbac5fd7 config: Use write_mode from config
This commit tidies up handling of `write_mode` by setting it in the
config at the start, and removing the `write_mode` parameter threaded
throughout the formatting process.
2016-02-08 22:52:44 -05:00
Mark Story
d8c6f5954a Update checkstyle write mode to take Write arguments.
By accepting Write traits we can write tests using StringBuffer.
2016-01-19 00:23:38 -05:00
Mark Story
5632831bd1 Clean up function names for checkstyle output. 2016-01-14 22:04:24 -05:00
Mark Story
add80569ff Use PartialEq/Eq implementation instead of match.
Also cleanup from rebasing onto master.
2016-01-13 21:07:38 -05:00
Mark Story
58410ddd93 Extract checkstyle output into a separate module.
Rename functions a bit now that they are specific to checkstyle output.
2016-01-13 21:03:25 -05:00
Mark Story
3c968e1e38 Update based on pull request feedback.
* Extract duplicated logic.
* Make checkstyle errors into warnings.
2016-01-13 21:02:50 -05:00
Mark Story
de10545906 Encode XML entities. 2016-01-13 21:02:50 -05:00
Mark Story
c3632befb5 Remove unused argument. 2016-01-13 21:02:05 -05:00
Mark Story
309f284dfb Fix formatting errors. 2016-01-13 21:01:27 -05:00
Mark Story
d188854e13 Hack together checkstyle output that compiles.
I'm not sure it does something useful yet though.
2016-01-13 21:01:26 -05:00
Mark Story
0c9f27fe5e Start hacking checkstyle output in.
checkstyle now shows up on the option parser, and the code still
compiles/passes tests. Next up will be outputing the XML to stdout.
2016-01-13 20:59:18 -05:00
Victor M. Suarez
4f8938c616 Allow for setting of write-mode via config file. FIxes #215
Also from @marcusklaas:
 Refactor code output functions

 Specifically, `write_all_files` no longer returns a HashMap. It would sometimes
 contain items, and sometimes be empty. When "fixed" newlines are required, this
 must now be done with a separate call. The tests use this strategy and should now pass!
2016-01-12 18:12:48 -05:00
Victor M. Suarez
56a3aac2b5 stop creating bk files if there are no changes. Fixes #733 2016-01-10 16:37:13 -05:00
Johan Sköld
add37b9c49 Adds a "Native" option to newline_style.
By using it one will get \r\n line endings on Windows, and \n line endings
on other platforms.
2015-11-15 04:16:34 -08:00
Johann
154e20a04f Address review concerns 2015-11-03 09:16:33 +01:00
Johann
fcc62cbbe0 Stdin support
Adds support for receiving input from stdin in case no file was
specified. This is useful for editor/IDE integrations and other tooling.

To achieve clean output a new write-mode option called plain was added,
this option is mandatory when using stdin.
2015-11-02 20:45:45 +01:00
Ravi Shankar
d135217db2 show rustfmt coverage! 2015-10-24 15:22:37 +05:30
Marcus Klaas
199d40fa55 Increase default function call width limit 2015-10-06 22:27:11 +02:00
Nick Cameron
99d71a164a Changes to source formatting 2015-09-26 13:58:12 +12:00
Marcus Klaas
e72d488281 Refactor test code
No longer use callbacks or thread::catch_panic; reduce stdout spew; guard against rustfmt breaking the column limit.
2015-09-18 22:34:46 +02:00
Sinh Pham
e7a5f9327e Add diff write mode https://github.com/nrc/rustfmt/issues/261 2015-09-10 18:30:07 -04:00
Nick Cameron
a43e2b5ae8 Formatting 2015-08-20 08:11:14 +12:00
Marcus Klaas
10a80bb8be Add an option to forgo backups 2015-08-19 21:31:27 +02:00
Gaëtan Cassiers
5a29d2f081 Fix nits for filemap 2015-08-02 14:49:35 +02:00
Gaëtan Cassiers
5b5927996f Kill ChangeSet and replace remaining part by FileMap
Also fix style issues
Cargo update to get fixes of strings.rs (was cause of a misformatted
function call).
2015-08-02 13:33:01 +02:00