This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Support text proto messages
ClosedPublic

Authored by krasimir on Jun 21 2017, 4:35 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

krasimir created this revision.Jun 21 2017, 4:35 AM
krasimir added a subscriber: cfe-commits.
krasimir updated this revision to Diff 103352.Jun 21 2017, 4:41 AM
  • Remove newline

Tests for <>-style message fields are missing because I discovered that they don't really work in a multiline setting in proto options anyways. I'll address this problem separately.

krasimir updated this revision to Diff 104645.Jun 29 2017, 7:28 AM
  • Add initial support for <>-style message fields
  • Added single-line tests
  • Added multiline message proto tests
krasimir updated this revision to Diff 104646.Jun 29 2017, 7:32 AM
  • Wrap-up this patch

@djasper: I think this is ready for review.

djasper added inline comments.Jun 30 2017, 7:22 AM
lib/Format/ContinuationIndenter.cpp
71 ↗(On Diff #104646)

Maybe rename to opensProtoMessageField() and add:

if (!LessTok.is(tok::less))
  return false;
107 ↗(On Diff #104646)

Do we need to set this explicitly here? Is it not enough to set FormatStyle.BinPackParameters to false?

lib/Format/TokenAnnotator.cpp
657 ↗(On Diff #104646)

Missing space...

lib/Format/UnwrappedLineParser.cpp
1360 ↗(On Diff #104646)

Why not just call nextToken before calling this function instead of adding the "StartInside" parameter?

krasimir updated this revision to Diff 105044.Jul 3 2017, 2:53 AM
krasimir marked 3 inline comments as done.
  • Address review comments
lib/Format/ContinuationIndenter.cpp
107 ↗(On Diff #104646)

BinPackParameters doesn't work at global scope. We set these explicitly to deal with the message formatting at global scope.

lib/Format/TokenAnnotator.cpp
657 ↗(On Diff #104646)

I don't understand? This has been formatted with clang-format.

djasper accepted this revision.Jul 3 2017, 7:56 AM
This revision is now accepted and ready to land.Jul 3 2017, 7:56 AM
This revision was automatically updated to reflect the committed changes.