Some Java style guides and IDEs group Java static imports after
non-static imports. This patch allows clang-format to control
the location of static imports.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for the patch, You need to generate a fill context diff (see Contributing to LLVM)
ensure the diff is clang-formatted itself (can't quite tell if it is or not)
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
2027 | The ClangFormatStyleOptions.rst is generated using doc/tools/dump_format_style.py which reads Format.h and generates this, If this code block in not in the Format.h it will get removed the next time the script is run, please don't change ClangFormatStyleOption.rst by hand use the script, so add the code block to the Format.h file (see others options for now to do this) |
clang/include/clang/Format/Format.h | ||
---|---|---|
1705 | 3 things here:
|
Some comments have been corrected and a unittest has been added in FormatTest.ParsesConfigurationBools
clang/include/clang/Format/Format.h | ||
---|---|---|
1705 | New phrasing makes it clear, but true and false are still inverted. |
clang/docs/ClangFormatStyleOptions.rst | ||
---|---|---|
1973 | Can you add a test that shows if the sorting is still in the groups, i.e. I can't tell if import com.test.a; import static org.a; import com.test.b; import static org.b; becomes import static org.a; import static org.b; import com.test.a; import com.test.b; or import static org.a; import static org.b; import com.test.a; import com.test.b; or import static org.a; import com.test.a; import static org.b; import com.test.b; | |
clang/include/clang/Format/Format.h | ||
1706 | Can we consider changing the name or the option to make it clearer what its for? SortJavaStaticImport and make it an enumeration rather than true/false Before,After,Never There need to be a "don't touch it option (.e.g. Never)" that does what it does today (and that should be the default, otherwise we end up causing clang-format to change ALL java code" which could be 100's of millions of lines+ | |
clang/lib/Format/Format.cpp | ||
906 | We can't have a default that does will cause a change | |
clang/unittests/Format/SortImportsTestJava.cpp | ||
253 | please test all options You are also missing a test for checking the PARSING of the options |
clang/include/clang/Format/Format.h | ||
---|---|---|
1706 | I'm confused, there is not currently a never option... Right now the behavior is always 'before', there is no 'after' or 'never'. Making it an enum would probably be more ergonomic though, even there is no never option. | |
clang/lib/Format/Format.cpp | ||
906 | Not a default change, see previous comment for discussion. | |
clang/unittests/Format/SortImportsTestJava.cpp | ||
253 | Parsing test was already noted and done (unless this changes to an enum of course). But testing the 'false' case here makes sense. |
LGTM, I'm happy if @JakeMerdichAMD is
clang/include/clang/Format/Format.h | ||
---|---|---|
1706 | true.. it will sort it I assume one way or the other |
Sorry on the delay, LGTM too.
It looks like you're a first time contributor and probably don't have write access to the repo, do you want one of us to push this on your behalf? If you intend to have more commits in the future, write access to github isn't hard to get (just request it once you have a few changes in).
It's okay for some reviewers to make this change on my behalf. Thanks for reviewing this!
Can you add a test that shows if the sorting is still in the groups, i.e. I can't tell if
becomes
or
or