if (Tok.isNot(tok::identifier) || !Tok.Previous)
return false;
- if (Tok.Previous->is(TT_LeadingJavaAnnotation))
+ if (Tok.Previous->isOneOf(TT_LeadingJavaAnnotation, Keywords.kw_instanceof))
return false;
// Skip "const" as it does not have an influence on whether this is a name.
return 0;
if (Current->is(TT_RangeBasedForLoopColon))
return prec::Comma;
+ if ((Style.Language == FormatStyle::LK_Java ||
+ Style.Language == FormatStyle::LK_JavaScript) &&
+ Current->is(Keywords.kw_instanceof))
+ return prec::Relational;
if (Current->is(TT_BinaryOperator) || Current->is(tok::comma))
return Current->getPrecedence();
if (Current->isOneOf(tok::period, tok::arrow))
return true;
if (Right.is(tok::kw_typename) && Left.isNot(tok::kw_const))
return true;
- if (Left.isBinaryOperator() && !Left.isOneOf(tok::arrowstar, tok::lessless) &&
+ if ((Left.isBinaryOperator() || Left.is(TT_BinaryOperator)) &&
+ !Left.isOneOf(tok::arrowstar, tok::lessless) &&
Style.BreakBeforeBinaryOperators != FormatStyle::BOS_All &&
(Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None ||
Left.getPrecedence() == prec::Assignment))
verifyFormat("return aaaaaaaaaaaaaaaaaaaaaaaaaaaaa instanceof\n"
" bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;",
Style);
+ verifyFormat("return aaaaaaaaaaaaaaaaaaa instanceof bbbbbbbbbbbbbbbbbbbbbbb\n"
+ " && ccccccccccccccccccc instanceof dddddddddddddddddddddd;");
}
TEST_F(FormatTestJava, Chromium) {