From 96458f852f91662d4de63f07a95dc9c4e47b2375 Mon Sep 17 00:00:00 2001 From: Daniel Jasper <djasper@google.com> Date: Tue, 21 Oct 2014 09:31:29 +0000 Subject: [PATCH] clang-format: [Java] Support extending inner classes. Before: class A extends B .C {} After: class A extends B.C {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220280 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineParser.cpp | 7 ++++--- unittests/Format/FormatTestJava.cpp | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 2b215fd09f9..6d2b67c29c0 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -1375,9 +1375,10 @@ void UnwrappedLineParser::parseRecord() { } // The actual identifier can be a nested name specifier, and in macros // it is often token-pasted. - while (FormatTok->Tok.is(tok::identifier) || - FormatTok->Tok.is(tok::coloncolon) || - FormatTok->Tok.is(tok::hashhash)) + while ( + FormatTok->is(tok::identifier) || FormatTok->is(tok::coloncolon) || + FormatTok->is(tok::hashhash) || + (Style.Language == FormatStyle::LK_Java && FormatTok->is(tok::period))) nextToken(); // Note that parsing away template declarations here leads to incorrectly diff --git a/unittests/Format/FormatTestJava.cpp b/unittests/Format/FormatTestJava.cpp index cf48a7a11d1..a4e9396b0d8 100644 --- a/unittests/Format/FormatTestJava.cpp +++ b/unittests/Format/FormatTestJava.cpp @@ -57,6 +57,7 @@ TEST_F(FormatTestJava, ClassDeclarations) { " int j;\n" " }\n" "}"); + verifyFormat("public class A extends B.C {}"); } TEST_F(FormatTestJava, ThrowsDeclarations) { -- GitLab