topecongiro
d7b6f1199f
Format source codes
2017-05-16 23:24:38 +09:00
topecongiro
feff6248c4
Allow last child in chain to go multiline
2017-05-16 23:24:00 +09:00
Michael Killough
c0bdbfa531
Switch to accessing config items via method.
...
Preparation for #865 , which proposes adding a flag which outputs which
config options are used during formatting.
This PR should not make any difference to functionality. A lot of this
was search-and-replace.
Some areas worthy of review/discussion:
- The method for each config item returns a clone of the underlying
value. We can't simply return an immutable reference, as lots of
places in the code expect to be able to pass the returned value as
`bool` (not `&bool). It would be nice if the `bool` items could
return a copy, but the more complex types a borrowed reference... but
unfortunately, I couldn't get the macro to do this.
- A few places (mostly tests and `src/bin/rustfmt.rs`) were overriding
config items by modifying the fields of the `Config` struct directly.
They now use the existing `override_value()` method, which has been
modified to return a `Result` for use by `src/bin/rustfmt.rs`. This
benefits of this are that the complex `file_lines` and `write_mode`
strings are now parsed in one place (`Config.override_value`) instead
of multiple. The disadvantages are that it moves the compile-time
checks for config names to become run-time checks.
2017-05-16 15:47:09 +07:00
Seiichi Uchida
7ec78711f2
Prevent rewriting closure block to expr inside macro
2017-05-13 18:32:25 +09:00
topecongiro
e91d498b8f
Keep a chain with length chain_one_line_max in a single line
2017-05-03 11:24:08 +09:00
topecongiro
2c1d896f60
Split a long chain with a single child
2017-05-03 11:22:36 +09:00
Nick Cameron
c546f1b396
Merge pull request #1454 from topecongiro/match
...
Format nested mathces properly.
2017-05-02 10:40:31 +12:00
topecongiro
af3f4c7f29
Remove duplicates
2017-05-01 15:57:02 +09:00
topecongiro
3d2cd681ae
Use 'first_line_width'
2017-05-01 15:36:40 +09:00
topecongiro
02cf515be6
Format source codes
2017-04-24 16:50:11 +09:00
topecongiro
cbd33e1983
Remove '+ 1' when counting the length of chains
2017-04-24 16:48:05 +09:00
topecongiro
8dc53d3750
Check the length of the first line of the last method in the chain
2017-04-15 16:23:38 +09:00
Nick Cameron
bdcb8d663e
Merge pull request #1438 from topecongiro/poor-formatting/method-chains
...
Lookup the last element of 'subexpr_list' instead of the first one
2017-04-06 21:26:13 +12:00
topecongiro
8d22e85e48
Lookup the last element of 'subexpr_list' instead of the first one
...
Closes #1217 , #1236 , #1389 and #1434 .
2017-04-06 09:26:25 +09:00
Ryan1729
4c4f70957b
fix bug by adding boolean argument
...
Signed-off-by: Ryan1729 <Ryan1729@gmail.com>
2017-04-03 17:39:14 -06:00
Nick Cameron
5305bc8436
test fallout
2017-03-28 11:25:59 +13:00
Nick Cameron
5fb1140688
fallout - source reformatting
2017-03-28 11:14:47 +13:00
Nick Cameron
a079b87e7c
Use a char len heuristic rather than item count for chain_one_line_max
2017-03-28 11:12:15 +13:00
Nick Cameron
e4efa22983
Source formatting fallout
2017-03-28 10:58:41 +13:00
Nick Cameron
038436919d
Put the second element of a chain on its own line when block formatting.
2017-03-28 10:56:46 +13:00
Nick Cameron
488c0b9546
Test and source fallout
2017-03-22 09:25:26 +13:00
Nick Cameron
21ff1d43ba
Unify a bunch of option types into IndentStyle
2017-03-20 11:46:39 +13:00
Nick Cameron
ce7b0aacd0
Remove BlockIndentStyle::Inherit
2017-03-20 11:23:44 +13:00
Nick Cameron
33b83ae7df
Formatting fallout
...
Also fixes a minor bug when we break a line after `if` and used to leave a trailing space
2017-03-07 09:50:41 +13:00
Nick Cameron
c7a33062e2
Add a heuristic for maximum number of elements in a single-line chain
...
And turn the source hints option to false by default. This should make formatting more deterministic.
2017-03-07 09:34:28 +13:00
Nick Cameron
a7612cc773
more fallout
2017-02-23 13:15:48 +13:00
Nick Cameron
d9d2423764
Tweak chain rules
2017-02-23 13:15:48 +13:00
Nick Cameron
9eb78a3333
Fallout
2017-02-23 13:15:48 +13:00
Nick Cameron
ba1202f6b3
test fallout
2017-02-23 13:15:48 +13:00
Nick Cameron
3bbdb0355e
remove some chain options
2017-02-23 13:15:48 +13:00
Nick Cameron
b35906dbce
WIP
2017-02-21 16:35:05 +13:00
Nick Cameron
428339fdc3
Refactor indent and width into Shape struct
2017-01-31 08:35:23 +13:00
Mikko Rantanen
636a828772
Add support for spaces_within_angle_brackets
...
Enabling the config adds spaces within type arguments: <>
2016-10-13 19:28:18 +03:00
sinkuu
a3c63fdef9
Run clippy
2016-08-29 08:57:27 +09:00
Nick Cameron
0087306761
Merge pull request #1016 from rust-lang-nursery/try-double-indent
...
Treat chains with just expr? specially.
2016-06-01 12:28:36 +01:00
Marcus Klaas
98c0570a28
Format non-statement if-else expressions on a single line
2016-05-29 17:58:38 +02:00
Nick Cameron
bbb6038b92
Treat chains with just expr? specially.
...
Fixes #1004
2016-05-29 09:32:48 +01:00
Nick Cameron
d6bcfceb7e
Don't put a newline before ?
when it is the second sub-expression in a chain ( #1012 )
...
Fixes #1003
2016-05-27 10:33:19 +02:00
Marcus Klaas
cd158cecc8
Add try macro to try shorthand conversion tests
2016-05-12 21:15:06 +02:00
Marcus Klaas
ee7b5805fc
Format try shorthand
2016-05-09 20:07:59 +02:00
Nick Cameron
f2105d382f
Fix for stable
2016-04-26 14:27:13 +12:00
Nick Cameron
19fa5c9ebb
Update docs (and a function name)
2016-04-22 19:26:42 +12:00
Nick Cameron
a9c3108c9c
Change defaults and update tests and source
...
New defaults are `Tabbed` for `chain_indent` and `chain_base_indent`, and `5` for `closure_block_indent_threshold`.
2016-04-22 19:18:48 +12:00
Nick Cameron
9761cf71d8
Tests
2016-04-22 18:53:39 +12:00
Nick Cameron
95ff52f06f
Tabbed/Inherit indent for chains works even without a newline after first item.
2016-04-22 18:41:38 +12:00
Nick Cameron
3d46532e72
refactor and document the chain reformatting code
2016-04-22 14:47:00 +12:00
Nick Cameron
9d8ce54428
Don't apply the function args heuristic to tuple lits.
...
Closes #450
Closes #510
2016-03-14 20:51:06 +13:00
Kamal Marhubi
589dabda2f
deps: Update syntex_syntax to 0.29.1
2016-03-02 13:08:21 -05:00
Marcus Klaas
2069abcca4
Reduce dependency on pprust
2015-12-25 20:59:46 +01:00
Seo Sanghyeon
2b11d84119
Apply Clippy
2015-11-25 15:39:15 +09:00