aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Format/FormatTestJava.cpp
diff options
context:
space:
mode:
authorDanil Sidoruk <patriotrossii2019@mail.ru>2022-08-15 20:26:56 -0700
committerowenca <owenpiano@gmail.com>2022-08-15 20:27:15 -0700
commitd8d331bc97103b6e191b96189166fefc6be54148 (patch)
tree24eae96b40ce31cbe1c4a28e6c49506498498f5e /clang/unittests/Format/FormatTestJava.cpp
parentfbc4c26e9a7a315881b695e872682b84b7e2bcc4 (diff)
downloadllvm-d8d331bc97103b6e191b96189166fefc6be54148.zip
llvm-d8d331bc97103b6e191b96189166fefc6be54148.tar.gz
llvm-d8d331bc97103b6e191b96189166fefc6be54148.tar.bz2
[clang-format] Fix aligning of java-style declarations
- Modify TokenAnnotator to work fine with java-style array declarations. - Add test for aligning of java declarations. Fixes #55931. Differential Revision: https://reviews.llvm.org/D129628
Diffstat (limited to 'clang/unittests/Format/FormatTestJava.cpp')
-rw-r--r--clang/unittests/Format/FormatTestJava.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp
index 03e16ae..7b25a0b 100644
--- a/clang/unittests/Format/FormatTestJava.cpp
+++ b/clang/unittests/Format/FormatTestJava.cpp
@@ -584,6 +584,17 @@ TEST_F(FormatTestJava, AlignsBlockComments) {
" void f() {}"));
}
+TEST_F(FormatTestJava, AlignDeclarations) {
+ FormatStyle Style = getLLVMStyle(FormatStyle::LK_Java);
+ Style.AlignConsecutiveDeclarations.Enabled = true;
+ verifyFormat("private final String[] args;\n"
+ "private final A_ParserHelper parserHelper;\n"
+ "private final int numOfCmdArgs;\n"
+ "private int numOfCmdArgs;\n"
+ "private String[] args;",
+ Style);
+}
+
TEST_F(FormatTestJava, KeepsDelimitersOnOwnLineInJavaDocComments) {
EXPECT_EQ("/**\n"
" * javadoc line 1\n"