r220280 - clang-format: [Java] Support extending inner classes.

Daniel Jasper djasper at google.com
Tue Oct 21 02:31:31 PDT 2014


Author: djasper
Date: Tue Oct 21 04:31:29 2014
New Revision: 220280

URL: http://llvm.org/viewvc/llvm-project?rev=220280&view=rev
Log:
clang-format: [Java] Support extending inner classes.

Before:
  class A extends B
  .C {}

After:
  class A extends B.C {}

Modified:
    cfe/trunk/lib/Format/UnwrappedLineParser.cpp
    cfe/trunk/unittests/Format/FormatTestJava.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=220280&r1=220279&r2=220280&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Oct 21 04:31:29 2014
@@ -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

Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=220280&r1=220279&r2=220280&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Tue Oct 21 04:31:29 2014
@@ -57,6 +57,7 @@ TEST_F(FormatTestJava, ClassDeclarations
                "    int j;\n"
                "  }\n"
                "}");
+  verifyFormat("public class A extends B.C {}");
 }
 
 TEST_F(FormatTestJava, ThrowsDeclarations) {





More information about the cfe-commits mailing list