Summary:
Import sorting of java file, incorrectly move import statement to after a function beginning with the word import.
Make 1 character change to regular expression to ensure there is always at least one space/tab after the word import
Previously clang-format --style="LLVM" would format
```
import X;
class C {
void m() {
importFile();
}
}
```
as
```
class C {
void m() {
importFile();
import X;
}
}
```
Reviewers: djasper, klimek, reuk, JonasToth
Reviewed By: klimek
Subscribers: cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D59684
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@357345
91177308-0d34-0410-b5e6-
96231b3b80d8
namespace {
const char JavaImportRegexPattern[] =
- "^[\t ]*import[\t ]*(static[\t ]*)?([^\t ]*)[\t ]*;";
+ "^[\t ]*import[\t ]+(static[\t ]*)?([^\t ]*)[\t ]*;";
} // anonymous namespace
"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"