[PATCH] D52800: Java import sorting in clang-format

Sam Maier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 4 08:58:23 PDT 2018


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`, right? IMO not a big problem, just add a note about it.
It does not, since `Static` is the first group of the regex. Test has been added for this


================
Comment at: unittests/Format/SortImportsTestJava.cpp:136
+  EXPECT_EQ("import org.a;\n", sort("import org.a;\n"
+                                    "import org.a;\n"));
+}
----------------
krasimir wrote:
> interested does the newline get taken into account? e.g. what happens with
> ```
> sort("import org.a;\n"
>      "import org.b;");
> ```
Added test, it works.


Repository:
  rC Clang

https://reviews.llvm.org/D52800





More information about the cfe-commits mailing list