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.
Details
Diff Detail
- Repository
- rC Clang
Event Timeline
lib/Format/Format.cpp | ||
---|---|---|
1859 | Please use llvm::sort instead of std::sort. See https://llvm.org/docs/CodingStandards.html#beware-of-non-deterministic-sorting-order-of-equal-elements. |
lib/Format/Format.cpp | ||
---|---|---|
848 | It would be helpful to link to a style guide reference for this. | |
1840–1841 | It would be helpful to spell out the sort order and add tests with respect to . and *. ASCII ordering has * < . < A < a which seems reasonable. | |
1925 | Please add a test for this. | |
1935 | Hm, this would also pick up the static in import a.*; // static, right? IMO not a big problem, just add a note about it. | |
unittests/Format/SortImportsTestJava.cpp | ||
131 | I wonder what happens if there are comments between import statements and comment lines after import statements. Consider adding some tests for that. |
Another example: we have to be careful with something like this as we don't want to break correct code:
import x; import a.loooooong. c; import y;
unittests/Format/SortImportsTestJava.cpp | ||
---|---|---|
131 | Specifically, as discussed, we wanna keep comments about imports together with them when we reorder stuff around. |
lib/Format/Format.cpp | ||
---|---|---|
1826 | nit: LLVM Style uses CamelCase for variables, please use I. | |
1837 | nit: Sorts and deduplicates | |
1839 | nit: Import declarations... | |
unittests/Format/SortImportsTestJava.cpp | ||
100 | Add a test where there are existing blocks of import statements separated by empty lines. I'd expect that a newly added import gets added to the right already existing block, right? | |
137 | interested does the newline get taken into account? e.g. what happens with sort("import org.a;\n" "import org.b;"); |
This gooks great! Thanks for the contribution!
If you don't have commit access to Clang I can commit this for you.
It would be helpful to link to a style guide reference for this.