]> granicus.if.org Git - clang/commitdiff
clang-format: [Java] Support extending inner classes.
authorDaniel Jasper <djasper@google.com>
Tue, 21 Oct 2014 09:31:29 +0000 (09:31 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 21 Oct 2014 09:31:29 +0000 (09:31 +0000)
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
unittests/Format/FormatTestJava.cpp

index 2b215fd09f9f72edc073e7e28506167f9c65586e..6d2b67c29c0938aed89750ca522b93295b28c8b1 100644 (file)
@@ -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
index cf48a7a11d123e1348d5c18b2416053c66cfc638..a4e9396b0d8ef6ff24580b072fd9180dbeca4076 100644 (file)
@@ -57,6 +57,7 @@ TEST_F(FormatTestJava, ClassDeclarations) {
                "    int j;\n"
                "  }\n"
                "}");
+  verifyFormat("public class A extends B.C {}");
 }
 
 TEST_F(FormatTestJava, ThrowsDeclarations) {