[PATCH] D28764: [clang-format] Implement comment reflowing (v3)

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 24 08:35:25 PST 2017


krasimir marked an inline comment as done.
krasimir added inline comments.


================
Comment at: lib/Format/BreakableToken.h:42-48
+/// There is a pair of operations that are used to compress a long whitespace
+/// range with a single space if that will bring the line lenght under the
+/// column limit:
+/// - getLineLengthAfterCompress, for calculating the size in columns of the
+///   line after a whitespace range has been compressed, and
+/// - compressWhitespace, for executing the whitespace compression using a
+///   whitespace manager.
----------------
klimek wrote:
> I assume the reason to not fold this into the next getSplitBefore is that sometimes we need to do the trimming even if we're the last line? Would it otherwise make sense?
The reason why we can't fold is that the compressing and the reflow of the next might be independent and operate on totally different whitespace ranges.
Consider the following comments with line length 20:
```
// Column limit 20 |
// long           long
// long
```
Then after compressWhitespace(line 2) we get:
```
// Column limit 20 |
// long long
// long
```
And now replaceWhitespaceBefore(line 3) will reflow:
```
// Column limit 20 |
// long long long
```

Will add a note about this.



https://reviews.llvm.org/D28764





More information about the cfe-commits mailing list