aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Format/FormatTestJava.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2018-10-05 18:22:21 +0000
committerNico Weber <nicolasweber@gmx.de>2018-10-05 18:22:21 +0000
commit208661b206be29c02f1e39ef00263f5efcd05a49 (patch)
tree1b46a218bf61f11c23b11252544554b05f747cfb /clang/unittests/Format/FormatTestJava.cpp
parent0ed892da707883908c8240087bed1e6286fe72aa (diff)
downloadllvm-208661b206be29c02f1e39ef00263f5efcd05a49.zip
llvm-208661b206be29c02f1e39ef00263f5efcd05a49.tar.gz
llvm-208661b206be29c02f1e39ef00263f5efcd05a49.tar.bz2
clang-format: Don't insert spaces in front of :: for Java 8 Method References.
The existing code kept the space if it was there for identifiers, and it didn't handle `this`. After this patch, for Java `this` is handled in addition to identifiers, and existing space is always stripped between identifier and `::`. Also accept `::` in addition to `.` in front of `<` in `foo::<T>bar` generic calls. Differential Revision: https://reviews.llvm.org/D52842 llvm-svn: 343872
Diffstat (limited to 'clang/unittests/Format/FormatTestJava.cpp')
-rw-r--r--clang/unittests/Format/FormatTestJava.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp
index 76e8261..aee8a99 100644
--- a/clang/unittests/Format/FormatTestJava.cpp
+++ b/clang/unittests/Format/FormatTestJava.cpp
@@ -443,6 +443,22 @@ TEST_F(FormatTestJava, MethodDeclarations) {
getStyleWithColumns(40));
}
+TEST_F(FormatTestJava, MethodReference) {
+ EXPECT_EQ(
+ "private void foo() {\n"
+ " f(this::methodReference);\n"
+ " f(C.super::methodReference);\n"
+ " Consumer<String> c = System.out::println;\n"
+ " Iface<Integer> mRef = Ty::<Integer>meth;\n"
+ "}",
+ format("private void foo() {\n"
+ " f(this ::methodReference);\n"
+ " f(C.super ::methodReference);\n"
+ " Consumer<String> c = System.out ::println;\n"
+ " Iface<Integer> mRef = Ty :: <Integer> meth;\n"
+ "}"));
+}
+
TEST_F(FormatTestJava, CppKeywords) {
verifyFormat("public void union(Type a, Type b);");
verifyFormat("public void struct(Object o);");