diff options
| author | Daniel Jasper <djasper@google.com> | 2014-10-21 08:24:18 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-10-21 08:24:18 +0000 |
| commit | fab69ff095db6cc222281d266b66d3b8083ad3ed (patch) | |
| tree | df882251bddf46eca7641ac436e3f60946f3d6ce /clang/lib/Format | |
| parent | b0852e54100c442f8b73f2e4238fe701eea2b3ce (diff) | |
| download | bcm5719-llvm-fab69ff095db6cc222281d266b66d3b8083ad3ed.tar.gz bcm5719-llvm-fab69ff095db6cc222281d266b66d3b8083ad3ed.zip | |
clang-format: [Java] Wrap after each function annotation.
Before:
@Override public String toString() { .. }
After:
@Override
public String toString() { .. }
llvm-svn: 220274
Diffstat (limited to 'clang/lib/Format')
| -rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Format/FormatToken.h | 1 | ||||
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 6 |
3 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index ead1da99c2d..4c93c7f548c 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -458,6 +458,7 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, !PreviousNonComment->isOneOf(tok::comma, tok::semi) && PreviousNonComment->Type != TT_TemplateCloser && PreviousNonComment->Type != TT_BinaryOperator && + PreviousNonComment->Type != TT_JavaAnnotation && Current.Type != TT_BinaryOperator && !PreviousNonComment->opensScope()) State.Stack.back().BreakBeforeParameter = true; @@ -533,7 +534,8 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) { if (Previous.is(tok::comma) && State.Stack.back().VariablePos != 0) return State.Stack.back().VariablePos; if ((PreviousNonComment && (PreviousNonComment->ClosesTemplateDeclaration || - PreviousNonComment->Type == TT_AttributeParen)) || + PreviousNonComment->Type == TT_AttributeParen || + PreviousNonComment->Type == TT_JavaAnnotation)) || (!Style.IndentWrappedFunctionNames && (NextNonComment->is(tok::kw_operator) || NextNonComment->Type == TT_FunctionDeclarationName))) diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index dc2c8a466ef..425a7c83648 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -46,6 +46,7 @@ enum TokenType { TT_ImplicitStringLiteral, TT_InheritanceColon, TT_InlineASMColon, + TT_JavaAnnotation, TT_LambdaLSquare, TT_LineComment, TT_ObjCBlockLBrace, diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 7fbd2f29d5f..ce3d8999007 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -826,6 +826,9 @@ private: // Line.MightBeFunctionDecl can only be true after the parentheses of a // function declaration have been found. Current.Type = TT_TrailingAnnotation; + } else if (Style.Language == FormatStyle::LK_Java && Current.Previous && + Current.Previous->is(tok::at)) { + Current.Type = TT_JavaAnnotation; } } } @@ -1787,6 +1790,9 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, if (Right.is(tok::char_constant) && Left.is(tok::plus) && Left.Previous && Left.Previous->is(tok::char_constant)) return true; + } else if (Style.Language == FormatStyle::LK_Java) { + if (Left.Type == TT_JavaAnnotation && Line.MightBeFunctionDecl) + return true; } return false; |

