Commit graph

86 commits

Author SHA1 Message Date
Srinivas Reddy Thatiparthy
58b022c56a Change stdout to stderr (#925) 2016-04-13 21:22:45 +02:00
Aleksey Kladov
dc1fc4be0f unify format_string and format_file 2016-04-11 22:56:54 +03:00
Srinivas Reddy Thatiparthy
901c5b1a5d use std::error instead std::out 2016-04-06 23:23:02 +05:30
Aleksey Kladov
c29ee66b94 make naming more consistent 2016-04-05 01:20:14 +03:00
Aleksey Kladov
63887ed413 make format_string and fmt_lines private 2016-04-03 00:45:04 +03:00
Aleksey Kladov
ac4532e161 use format_input function in tests 2016-04-03 00:32:24 +03: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
f2b5931c6d deps: Update syntex_syntax to 0.30.0
This bump includes ability to parse inclusive ranges (`a...b`) and the
question mark operator.

Refs #867, #890
2016-03-29 00:04:44 -04:00
Kamal Marhubi
589dabda2f deps: Update syntex_syntax to 0.29.1 2016-03-02 13:08:21 -05: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
Kamal Marhubi
70c9b55ecb cleanup: Remove documentation of deleted parameter
The `args` parameter was removed in 579fb34.
2016-02-02 12:37:38 -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
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
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
Gaëtan Cassiers
598fcdddc3 Fix issue with windows line endings (#717).
The '\r' character wasn't counted in the line length.
2016-01-10 16:25:31 +01:00
Aleksey Kladov
a70b621607 add option to ignore out of line modules 2015-12-23 17:25:49 +03:00
Nick Cameron
ecf12778fb Use replace rather than overwrite for cargo fmt 2015-12-16 18:07:59 +13:00
Marcus Klaas
97e4e7e5ba Fixed named arguments in bare function types 2015-12-06 01:11:26 +01:00
Seo Sanghyeon
2b11d84119 Apply Clippy 2015-11-25 15:39:15 +09:00
Nick Cameron
2661592d59 Handle multiply-referenced files
Fixes #645
2015-11-23 15:22:00 +13:00
Marcus Klaas
6e1f77664d Unwrap match arms that are simple blocks 2015-11-20 21:05:18 +01:00
Seo Sanghyeon
faff4bc9e8 Add verbose mode 2015-11-15 15:41:41 +09:00
Mika Attila
5b06ed6817 Don't print an unnecessary newline after printing format report
The Display implementation for FormatReport already prints
a newline after every error.

However, if the format report does not contain errors, we
don't want to print an empty newline.

This behavior clutters up the console output with
empty lines when rustfmt is invoked multiple times
(from .e.g a script or cargo-fmt).

So instead of using println! to print the report, we just
use print!.
2015-11-14 19:01:28 +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
Eli Friedman
1c235de97d Fix crash speculatively parsing macro arguments as expressions.
The problem is essentially that if we try to parse a token tree using a
CodeMap different from the one the tree was originally parsed with,
spans become nonsense. Since CodeMaps can't be cloned, we're basically
forced to use the original ParseSess for additional parsing.

Ideally, rustfmt would be a bit more clever and figure out how to parse
macro arguments based on the definition of the macro itself, rather than
just guessing that a particular token sequence looks like an expression,
but this is good enough for now.

Fixes #538.
2015-10-27 23:41:32 -07:00
Marcus Klaas
d122ad5adc Address some issues with multiline patterns in let statements 2015-10-24 13:13:15 +02:00
Ravi Shankar
d135217db2 show rustfmt coverage! 2015-10-24 15:22:37 +05:30
Alex Crichton
579fb34417 Remove dependence on rustc/rustc_driver, use syntex
Instead just parse manually with the `syntex_syntax` crate which is a clone of
libsyntax on crates.io which builds on stable Rust.
2015-10-23 13:46:14 -07:00
Alex Crichton
36abfe5dc2 Remove usage of many unstable features
This removes usage of:

* PathExt
* split_last
* split_last_mut
* catch_panic

The catch_panic one was a little tricky as the ident interner needed to be
cloned across threads (a little unsafely), but it should otherwise be good to
go.
2015-10-23 13:46:14 -07:00
Marcus Klaas
ca023ba9b7 Format some patterns 2015-10-19 20:15:36 +02:00
Marcus Klaas
199d40fa55 Increase default function call width limit 2015-10-06 22:27:11 +02:00
Marcus Klaas
965ea09664 Split ListTactic decision logic from write_list 2015-10-04 20:40:14 +02:00
Tim Kuehn
6c6e7194c2 Fix 1-tuple regression.
Add test to prevent future regressions.
2015-10-01 11:06:49 -07:00
Marcus Klaas de Vries
afee62e476 Merge pull request #370 from marcusklaas/match-arm-delining
Improve heuristics for match arm body placement
2015-09-27 12:00:57 +02:00
Marcus Klaas
2d4a0cbe3b Fix match arm indentation bug 2015-09-26 23:18:57 +02:00
Nick Cameron
617eed353c Changes to rustfmt source 2015-09-26 18:29:48 +12:00
Nick Cameron
99d71a164a Changes to source formatting 2015-09-26 13:58:12 +12:00
Pavel Sountsov
03e1b27826 Add Indent::none(), remove make_indent. 2015-09-19 10:36:45 -07:00
Pavel Sountsov
d4108a3029 Initial implementation of hard tab indentation. 2015-09-19 10:36:45 -07: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
Marcus Klaas
110f7206e6 Split formatting function from side effects
This makes rustfmt more usable as a library.
2015-09-18 22:31:33 +02:00
Marcus Klaas
f751356910 Format macro invocations 2015-09-16 20:26:14 +02:00
Nick Cameron
a29023a191 Remove a few unnecessary rustfmt_skips 2015-09-15 11:46:27 +12:00
Marcus Klaas
03c660633f Refine chain breaking heuristics
Don't make a single line chain when it is was multi line in the source; allow overflow of the last chain element onto the next lines without breaking the chain.
2015-09-11 00:53:01 +02:00
Marcus Klaas
c680bb4030 Implement basic chain formatting 2015-09-11 00:52:16 +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
8750399ef4 Merge pull request #248 from sinhpham/unicode_string_lit
Unicode string lit
2015-09-07 08:01:06 +12:00
Andre Bogus
d6c652e33c code improvements suggested by clippy 2015-09-04 23:39:33 +02:00
Sinh Pham
61f642f6f8 Support unicode in string literals. 2015-09-03 23:41:25 -04:00