Page MenuHomePhabricator

Fixes for spaces around C# object initializers
ClosedPublic

Authored by jbcoe on Jan 8 2020, 8:48 AM.

Details

Summary

Fix spaces around typename and [] in C# object initializers.

Diff Detail

Event Timeline

jbcoe created this revision.Jan 8 2020, 8:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 8 2020, 8:48 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jbcoe edited the summary of this revision. (Show Details)Jan 8 2020, 9:10 AM
MyDeveloperDay accepted this revision.Jan 9 2020, 12:12 AM

LGTM, thanks once again for the C# patch!

This revision is now accepted and ready to land.Jan 9 2020, 12:12 AM
krasimir requested changes to this revision.Jan 11 2020, 2:40 AM
krasimir added inline comments.
clang/lib/Format/TokenAnnotator.cpp
2879

This test feels a bit too rigid: you might additionally want to consider new Type<Param> { and new Type /*comment*/ { and new [] /* comment */ {.
For these you might find the MatchingParen and getPreviousNonComment useful. And example for this is below, at line 2880-2885 in javascript handling.

2880

The TT_Unknown is a bit confusing -- why is it needed? If this is a workaround for something, please add it as a comment. We might need to improve the token detection later to allow for more complicated pattern matching.

This revision now requires changes to proceed.Jan 11 2020, 2:40 AM
krasimir added inline comments.Jan 11 2020, 2:41 AM
clang/unittests/Format/FormatTestCSharp.cpp
405

Is this needed for the formatting below? I find it surprising if this controls the spacing before braces.

krasimir added inline comments.Jan 13 2020, 12:04 AM
clang/lib/Format/TokenAnnotator.cpp
2879

Sorry, disregard the patterns with /* comment */ above. I guess the spaces around the comment there are enforced at another place.

MyDeveloperDay added inline comments.Jan 15 2020, 4:22 AM
clang/lib/Format/TokenAnnotator.cpp
2880

+1 that comment what was Left I think we need to be more specific

jbcoe updated this revision to Diff 241694.Fri, Jan 31, 4:45 AM

Minor changes to address review comments.

jbcoe marked 5 inline comments as done.Fri, Jan 31, 4:46 AM
krasimir accepted this revision.Fri, Jan 31, 5:47 AM

Thank you!

This revision is now accepted and ready to land.Fri, Jan 31, 5:47 AM
This revision was automatically updated to reflect the committed changes.