This is an archive of the discontinued LLVM Phabricator instance.

clang-format: [JS] Option for top-level dict literals on a single line
AbandonedPublic

Authored by ono on Jan 27 2015, 8:52 AM.

Details

Reviewers
djasper
Summary

Previously r223367 introduced stylistic change, where all top-level dict
literals will never be compacted to single line. Since this changes formatting,
some who want previous formatting now can bring it back setting
AllowTopLevelDictLiteralsOnASingleLine: true.

Diff Detail

Event Timeline

ono updated this revision to Diff 18819.Jan 27 2015, 8:52 AM
ono retitled this revision from to clang-format: [JS] Option for top-level dict literals on a single line.
ono updated this object.
ono edited the test plan for this revision. (Show Details)
ono added a reviewer: djasper.
ono added subscribers: klimek, ono, Unknown Object (MLST).
djasper edited edge metadata.Jan 27 2015, 8:54 AM

This needs tests.

Also, I am wondering whether we should straight away introduce this as "AllowDictLiteralsOnASingleLine" with an enum value of (None, All, TopLevel). What do you think?

ono added a comment.Jan 28 2015, 4:42 AM

Yeah, but I think this should be rather None, All, SubLevel, since SubLevel will represent current behavior and All will represent previous behavior.

Preparing updated patch.

Right. SubLevel or Nested.

ono updated this revision to Diff 18888.Jan 28 2015, 5:44 AM
ono edited edge metadata.
  • Introduced SingleLineStyle enum of None, Nested, All
  • Replaced previous setting with AllowDictLiteralsOnASingleLine with value of enum above
  • Added unit tests for this setting
djasper accepted this revision.Apr 16 2015, 1:49 AM
djasper edited edge metadata.

Looks good. Do you have commit access?

This revision is now accepted and ready to land.Apr 16 2015, 1:49 AM
ono added a comment.Apr 16 2015, 7:33 AM

Looks good. Do you have commit access?

Okie, need to rebase or merged okay with latest HEAD? And nope - no commit access.

Unfortunately, this interacts non-trivially with http://reviews.llvm.org/rL232320. I can fix the merge, but I am not sure what the proposed behavior is. Could you outline what you would want the flag to do in these cases? Or does the other commit possibly fix your use case?

unittests/Format/FormatTestJS.cpp
161–162

We probably should be testing 'nested' here, too.

ono added a comment.Apr 17 2015, 1:02 PM

(...) Or does the other commit possibly fix your use case?

I think the mentioned commit obsoletes this change. So I am marking this to be abandoned.

ono abandoned this revision.Apr 17 2015, 1:02 PM