This revision was automatically updated to reflect the committed changes. Closed by commit rC357345: [clang-format] [PR41187] moves Java import statements to the wrong location if… (authored by paulhoad, committed by ). Herald added a project: clang.
Changed prior to commit: https://reviews.llvm.org/D59684?vs=191833&id=192973#toc Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D59684/new/ https://reviews.llvm.org/D59684 Files: lib/Format/Format.cpp unittests/Format/SortImportsTestJava.cpp Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1983,7 +1983,7 @@ namespace { const char JavaImportRegexPattern[] = - "^[\t ]*import[\t ]*(static[\t ]*)?([^\t ]*)[\t ]*;"; + "^[\t ]*import[\t ]+(static[\t ]*)?([^\t ]*)[\t ]*;"; } // anonymous namespace Index: unittests/Format/SortImportsTestJava.cpp =================================================================== --- unittests/Format/SortImportsTestJava.cpp +++ unittests/Format/SortImportsTestJava.cpp @@ -262,6 +262,21 @@ "import org.a;")); } +TEST_F(SortImportsTestJava, ImportNamedFunction) { + EXPECT_EQ("import X;\n" + "class C {\n" + " void m() {\n" + " importFile();\n" + " }\n" + "}\n", + sort("import X;\n" + "class C {\n" + " void m() {\n" + " importFile();\n" + " }\n" + "}\n")); +} + TEST_F(SortImportsTestJava, NoReplacementsForValidImports) { // Identical #includes have led to a failure with an unstable sort. std::string Code = "import org.a;\n"
Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1983,7 +1983,7 @@ namespace { const char JavaImportRegexPattern[] = - "^[\t ]*import[\t ]*(static[\t ]*)?([^\t ]*)[\t ]*;"; + "^[\t ]*import[\t ]+(static[\t ]*)?([^\t ]*)[\t ]*;"; } // anonymous namespace Index: unittests/Format/SortImportsTestJava.cpp =================================================================== --- unittests/Format/SortImportsTestJava.cpp +++ unittests/Format/SortImportsTestJava.cpp @@ -262,6 +262,21 @@ "import org.a;")); } +TEST_F(SortImportsTestJava, ImportNamedFunction) { + EXPECT_EQ("import X;\n" + "class C {\n" + " void m() {\n" + " importFile();\n" + " }\n" + "}\n", + sort("import X;\n" + "class C {\n" + " void m() {\n" + " importFile();\n" + " }\n" + "}\n")); +} + TEST_F(SortImportsTestJava, NoReplacementsForValidImports) { // Identical #includes have led to a failure with an unstable sort. std::string Code = "import org.a;\n"
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits