Commit Graph

332 Commits

Author SHA1 Message Date
Igor Matuszewski b3c28dba83 Expose ModifiedLines and implement parsing data from the string output
This moves `Modified{Chunks,Lines}` from `src/formatting.rs` to
`src/rustfmt_diff.rs` and reexports it in `src/lib.rs`.

With this, a conversion from `Vec<Mismatch>` to `ModifiedLines` was implemented
and now this implements complementary `Display` and `FromStr`, which
simplified the previously used `output_modified` function and which allows to
parse the raw data emitted with `EmitMode::ModifiedLines`.
2019-03-04 18:19:30 +01:00
Igor Matuszewski 0437bf7a7d Allow for stdin input in EmitMode::ModifiedLines 2019-03-04 18:19:30 +01:00
Alexander Regueiro 7a3b7c9275 Various cosmetic improvements (#3403) 2019-02-19 11:56:42 +09:00
Seiichi Uchida ce682bdabc Merge pull request #3335 from h-michael/rust-2018
Rust 2018 idioms
2019-02-11 01:12:38 +09:00
Stéphane Campinas b86dd161df remove unneeded Version import 2019-02-09 14:23:54 +01:00
Hirokazu Hata 4bb90f5cc8 Fix rust_2018_idioms warnings 2019-02-09 16:14:30 +09:00
Hirokazu Hata e70e6eb273 deny rust_2018_idioms 2019-02-09 15:55:17 +09:00
Hirokazu Hata c0f93a6ea3 cargo +nightly fix --edition-idioms 2019-02-09 15:53:12 +09:00
Stéphane Campinas 813aa79567 fix formatting of strings within a macro 2019-02-07 00:05:05 +01:00
Evgenii ece629b1cc transition to Rust 2018 2019-02-04 13:30:43 +03:00
Mara Bos 24daa174ca Look for a global rustfmt.toml.
If no rustfmt.toml is found in the usual way, the directory 'rustfmt' in
the user's config directory is checked.

 - $XDG_CONFIG_HOME/rustfmt/ (or $HOME/.config/rustfmt/), or
 - $HOME/Library/Preferences/rustfmt/ on Mac, or
 - %AppData%\rustfmt\ on Windows.
2019-01-27 13:22:25 +01:00
wada314 a01990c4d0 Use Unicode-standard char width to wrap comments or strings. (#3275) 2019-01-15 08:41:09 +09:00
Nick Cameron 6739dbe77d Merge pull request #3129 from otavio/issue-3104
cargo-fmt: detect Rust edition in use
2018-10-25 13:39:40 +13:00
Stéphane Campinas 2f5d864c08 keep track of lines which formatting was disabled in order to prevent indentation which would cause code right-shifting 2018-10-24 12:11:11 +02:00
Otavio Salvador 2eab9714e4 lib: export config::Edition so it can be used externally
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2018-10-23 02:33:36 -03:00
Matthias Krüger b25f974c0d fix a few typos found via codespell. 2018-10-19 12:28:00 +02:00
Nick Cameron 4bb84f6002 Remove NLL feature
And do some refactoring in comments.rs

Closes #3107
2018-10-18 15:39:11 +13:00
Nick Cameron 613dfcc521 Remove various feature flags 2018-10-18 15:38:57 +13:00
Seiichi Uchida 8c4e92a14e Catch parser panic in format_snippet (#3103) 2018-10-17 14:21:04 +09:00
Otavio Salvador e203057db0 utils: rewrite count_newlines using bytecount::count
This uses a optimized byte count and also makes use of SIMD
instructions to optimize the processing of the byte arrays.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2018-10-14 18:27:35 -03:00
Stéphane Campinas 7003276b73 fixed display message for the LineOverflow error 2018-10-11 09:05:33 +02:00
Otavio Salvador 0279b7d02c Replace isatty crate with atty
The `isatty` crate has been deprecated and a replacement has been
released for it called `atty`. It offers a nicer API and the code
change to adapt is trivial.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
2018-10-08 14:39:16 -03:00
Seiichi Uchida 6e901c8f37 Format and update test 2018-09-30 08:05:45 +09:00
Nick Cameron 88f3b32e43 Remove unnecessary feature flag 2018-09-25 18:23:17 +12:00
Seiichi Uchida 6aae9d870f Remove an unnecessary attribute 2018-08-26 13:20:07 +09:00
cad97 fc1909d311 Reformat 2018-08-23 17:14:19 -04:00
cad97 04d804c365 Rename CodeMap/FileMap to SourceMap/SourceFile
#2946
2018-08-23 17:10:46 -04:00
Nick Cameron 43f178bd58 Remove Summary 2018-07-24 21:45:15 +12:00
Nick Cameron d3288841ea Refactoring: factor format_lines and format_project into smaller chunks 2018-07-24 15:17:47 +12:00
Nick Cameron 2af1ed109c Refactoring: factor out format_file and FormatHandler
This effectively separates out formatting from other handling.
2018-07-24 14:05:04 +12:00
Nick Cameron b9c6754d8c Refactoring: move format_project and Timer out of Session 2018-07-24 10:08:41 +12:00
Nick Cameron 069c4fc508 Refactoring: summary
Move the timer from Summary to Session.

Move Summary from config to formatting.
2018-07-24 08:43:30 +12:00
Nick Cameron 09a8c6d22b Refactoring: move code around in formatting
To try and make cleaner abstractions and to start to separate formatting from
other tasks.
2018-07-24 08:26:33 +12:00
Nick Cameron 71d3d04270 factor out a Session object 2018-07-23 15:37:34 +12:00
Nick Cameron 4153e66e42 Move non-public API from lib.rs to its own module 2018-07-23 12:45:41 +12:00
Nick Cameron b085113cbe Trigger an internal error if we skip formatting due to a lost comment 2018-07-20 16:05:19 +12:00
Nick Cameron b27d544478 replace_with_system_newlines doesn't need to be public 2018-07-18 09:16:51 +12:00
Nick Cameron d911b640d1 Merge pull request #2823 from fwalch/default-newline-style
Change default newline style to "Native"
2018-07-17 11:18:10 +12:00
Nick Cameron b68fd9e6bf Move pair handling to its own module 2018-07-12 21:37:28 +12:00
Seiichi Uchida 60ce411b53 Format async closure 2018-07-09 23:20:53 +09:00
Florian Walch 363363d066 test: Assert CRLF line endings on Windows 2018-07-02 23:43:59 +02:00
Shohei Wada 036244cdce Fix #2728. 2018-06-19 20:51:49 +09:00
Seiichi Uchida 0ec1533054 Merge pull request #2779 from thibaultdelor/stableApi
Improve end lines handling
2018-06-11 11:38:26 +09:00
Tibo Delor 2e90c4314c Stop delaying Trailing whitespace error reporting 2018-06-10 14:19:09 +10:00
Tibo Delor 42efae5944 Clean Up code where last whitspace tracking isn't used 2018-06-10 14:07:33 +10:00
Tibo Delor 6b00b8b302 Move newline logic inside the formatting process.
Why?:
 - Conceptually it sounds right
 - Absolutely all write modes where doing it anyway
 - It was done several times in some in case
 - It greatly simplify the code
2018-06-10 00:25:47 +10:00
Tibo Delor 8c32a9d909 Parse Error return an Error instead of a successful empty response 2018-06-10 00:25:06 +10:00
Seiichi Uchida c95fa8cbe2 Return None when the formatting of macro failed in format_snippet 2018-06-07 12:33:33 +09:00
Seiichi Uchida d1477ca1de Add a field in Summary for notiyfing about formatting failure of macro 2018-06-07 12:32:58 +09:00
Nick Cameron 173ae0d7b9 0.8.2 2018-05-28 11:47:21 +12:00