forked from OSchip/llvm-project
clang-format: [Java] Don't break immediately after "throws".
Before: public void doSooooooooooooooooooooooooooomething() throws LooooooooooooooooooooooooooooongException {} After: public void doSooooooooooooooooooooooooooomething() throws LooooooooooooooooooooooooooooongException {} llvm-svn: 220041
This commit is contained in:
parent
9758bc473b
commit
f26c755d42
|
@ -1791,6 +1791,12 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
|
|||
bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
|
||||
const FormatToken &Right) {
|
||||
const FormatToken &Left = *Right.Previous;
|
||||
|
||||
if (Style.Language == FormatStyle::LK_Java) {
|
||||
if (Left.is(tok::identifier) && Left.TokenText == "throws")
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Left.is(tok::at))
|
||||
return false;
|
||||
if (Left.Tok.getObjCKeywordID() == tok::objc_interface)
|
||||
|
|
|
@ -37,12 +37,6 @@ protected:
|
|||
return format(Code, 0, Code.size(), Style);
|
||||
}
|
||||
|
||||
static FormatStyle getGoogleJSStyleWithColumns(unsigned ColumnLimit) {
|
||||
FormatStyle Style = getGoogleStyle(FormatStyle::LK_Java);
|
||||
Style.ColumnLimit = ColumnLimit;
|
||||
return Style;
|
||||
}
|
||||
|
||||
static void verifyFormat(
|
||||
llvm::StringRef Code,
|
||||
const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_Java)) {
|
||||
|
@ -65,5 +59,10 @@ TEST_F(FormatTestJava, ClassDeclarations) {
|
|||
"}");
|
||||
}
|
||||
|
||||
TEST_F(FormatTestJava, ThrowsDeclarations) {
|
||||
verifyFormat("public void doSooooooooooooooooooooooooooomething()\n"
|
||||
" throws LooooooooooooooooooooooooooooongException {}");
|
||||
}
|
||||
|
||||
} // end namespace tooling
|
||||
} // end namespace clang
|
||||
|
|
Loading…
Reference in New Issue