r220285 - clang-format: [Java] Fix space in generic method calls.

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


Author: djasper
Date: Tue Oct 21 06:13:31 2014
New Revision: 220285

URL: http://llvm.org/viewvc/llvm-project?rev=220285&view=rev
Log:
clang-format: [Java] Fix space in generic method calls.

Before:
  A.<B>doSomething();

After:
  A.<B>doSomething();

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=220285&r1=220284&r2=220285&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Oct 21 06:13:31 2014
@@ -1628,6 +1628,11 @@ bool TokenAnnotator::spaceRequiredBetwee
     return false;
   if (Right.is(tok::hash) && Left.is(tok::identifier) && Left.TokenText == "L")
     return false;
+  if (Left.Type == TT_TemplateCloser && Left.MatchingParen &&
+      Left.MatchingParen->Previous &&
+      Left.MatchingParen->Previous->is(tok::period))
+    // A.<B>DoSomething();
+    return false;
   return true;
 }
 

Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=220285&r1=220284&r2=220285&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Tue Oct 21 06:13:31 2014
@@ -90,6 +90,8 @@ TEST_F(FormatTestJava, Generics) {
   verifyFormat("Iterable<?> a;");
   verifyFormat("Iterable<?> a;");
   verifyFormat("Iterable<? extends SomeObject> a;");
+
+  verifyFormat("A.<B>doSomething();");
 }
 
 } // end namespace tooling





More information about the cfe-commits mailing list