This is an archive of the discontinued LLVM Phabricator instance.

clang-format: Don't insert spaces in front of :: for Java 8 Method References.
ClosedPublic

Authored by thakis on Oct 3 2018, 12:40 PM.

Details

Summary

The existing code kept the space if it was there for identifiers, and it didn't handle this. After this patch, for java this is handled in addition to identifiers, and existing space is always stripped between identifier and ::.

Also accept :: in addition to . in front of < in foo::<T>bar generic calls.

Diff Detail

Event Timeline

thakis created this revision.Oct 3 2018, 12:40 PM
thakis updated this revision to Diff 168161.Oct 3 2018, 1:03 PM
thakis edited the summary of this revision. (Show Details)

krasimir, do you do clang-format reviews these days? If not, do you know who does?

I'll take a look. I'm a bit worried that this might potentially affect C++ files too: I'll run an experiment over some random files to confirm that we're not missing something.

krasimir added inline comments.Oct 5 2018, 10:52 AM
lib/Format/TokenAnnotator.cpp
2559

nit: please add a comment that this example comes from Java.

Looks good!
I didn't find any instances where this messes-up C++ code (and it looks fine to me for Java code).

Thanks! Will land with tweaked comment.

lib/Format/TokenAnnotator.cpp
2559

Will do. I believe the existing example is Java too.

This revision was not accepted when it landed; it landed in state Needs Review.Oct 5 2018, 11:24 AM
This revision was automatically updated to reflect the committed changes.