clang-format: [Java] Add space between "synchronized" and "(".

Before:
  synchronized(mData) {
    // ...
  }

After:
  synchronized (mData) {
    // ...
  }

This fixes llvm.org/PR21455.

llvm-svn: 221110
This commit is contained in:
Daniel Jasper 2014-11-02 22:00:57 +00:00
parent 7bd618f5aa
commit b9d3db6b1b
2 changed files with 9 additions and 0 deletions

View File

@ -1680,6 +1680,9 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
} 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.

View File

@ -157,5 +157,11 @@ TEST_F(FormatTestJava, TryCatchFinally) {
"}");
}
TEST_F(FormatTestJava, SynchronizedKeyword) {
verifyFormat("synchronized (mData) {\n"
" // ...\n"
"}");
}
} // end namespace tooling
} // end namespace clang