krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.
This gooks great! Thanks for the contribution!
If you don't have commit access to Clang I can commit this for you.
Repository:
rC Clang
https://reviews.llvm.org/D52800
__
SamMaier added inline comments.
Comment at: lib/Format/Format.cpp:1932
+bool IsStatic = false;
+if (Static.contains("static")) {
+ IsStatic = true;
krasimir wrote:
> Hm, this would also pick up the `static` in `import a.*; // static`, rig
SamMaier updated this revision to Diff 168304.
SamMaier marked 11 inline comments as done.
SamMaier added a comment.
Addressing comments
Repository:
rC Clang
https://reviews.llvm.org/D52800
Files:
include/clang/Format/Format.h
lib/Format/Format.cpp
unittests/Format/CMakeLists.txt
uni
krasimir added inline comments.
Comment at: lib/Format/Format.cpp:1823
+ unsigned LongestMatchLength = 0;
+ for (unsigned i = 0; i < Style.JavaImportGroups.size(); i++) {
+std::string GroupPrefix = Style.JavaImportGroups[i];
nit: LLVM Style uses CamelCase f
krasimir added a comment.
Another example: we have to be careful with something like this as we don't
want to break correct code:
import x;
import a.loong.
c;
import y;
Comment at: unittests/Format/SortImportsTestJava.cpp:130
+ "// that do\n"
+
krasimir added inline comments.
Comment at: lib/Format/Format.cpp:848
ChromiumStyle.IndentWidth = 4;
+ChromiumStyle.JavaImportGroups = {
+"android",
It would be helpful to link to a style guide reference for this.
Comment at: l
SamMaier updated this revision to Diff 168111.
SamMaier set the repository for this revision to rC Clang.
SamMaier added a comment.
Changed std::sort to llvm::sort
Repository:
rC Clang
https://reviews.llvm.org/D52800
Files:
include/clang/Format/Format.h
lib/Format/Format.cpp
unittests/
mgrang added inline comments.
Comment at: lib/Format/Format.cpp:1856
+ }
+ std::sort(Indices.begin(), Indices.end(), [&](unsigned LHSI, unsigned RHSI) {
+// Negating IsStatic to push static imports above non-static imports.
Please use llvm::sort instead
SamMaier created this revision.
Herald added subscribers: cfe-commits, mgrang, mgorny, srhines.
This is for https://bugs.chromium.org/p/chromium/issues/detail?id=768983 -
however it will be useful for anyone using clang-format for Java, not just
Chromium.
Repository:
rC Clang
https://review