r221110 - clang-format: [Java] Add space between "synchronized" and "(".
Daniel Jasper
djasper at google.com
Sun Nov 2 14:00:58 PST 2014
Author: djasper
Date: Sun Nov 2 16:00:57 2014
New Revision: 221110
URL: http://llvm.org/viewvc/llvm-project?rev=221110&view=rev
Log:
clang-format: [Java] Add space between "synchronized" and "(".
Before:
synchronized(mData) {
// ...
}
After:
synchronized (mData) {
// ...
}
This fixes llvm.org/PR21455.
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=221110&r1=221109&r2=221110&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Sun Nov 2 16:00:57 2014
@@ -1680,6 +1680,9 @@ bool TokenAnnotator::spaceRequiredBefore
} else if (Style.Language == FormatStyle::LK_JavaScript) {
if (Left.TokenText == "var")
return true;
+ } else if (Style.Language == FormatStyle::LK_Java) {
+ if (Left.TokenText == "synchronized" && Right.is(tok::l_paren))
+ return Style.SpaceBeforeParens != FormatStyle::SBPO_Never;
}
if (Right.Tok.getIdentifierInfo() && Left.Tok.getIdentifierInfo())
return true; // Never ever merge two identifiers.
Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=221110&r1=221109&r2=221110&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Sun Nov 2 16:00:57 2014
@@ -157,5 +157,11 @@ TEST_F(FormatTestJava, TryCatchFinally)
"}");
}
+TEST_F(FormatTestJava, SynchronizedKeyword) {
+ verifyFormat("synchronized (mData) {\n"
+ " // ...\n"
+ "}");
+}
+
} // end namespace tooling
} // end namespace clang
More information about the cfe-commits
mailing list