[PATCH] D59684: [clang-format] [PR41187] moves Java import statements to the wrong location if code contains statements that start with the word import
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 30 06:05:36 PDT 2019
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"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59684.192973.patch
Type: text/x-patch
Size: 1224 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190330/218e7de2/attachment.bin>
More information about the cfe-commits
mailing list