summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-11-14 10:15:56 +0000
committerDaniel Jasper <djasper@google.com>2014-11-14 10:15:56 +0000
commit734d52b58bf3056a91e16c866da00f5b49e40098 (patch)
treedf4251073573bc5a6b3599a9386a1c49cc946e4d /clang/lib/Format/TokenAnnotator.cpp
parent5109a7938de1ed135f0c1a64ee81a341cf612efe (diff)
downloadbcm5719-llvm-734d52b58bf3056a91e16c866da00f5b49e40098.tar.gz
bcm5719-llvm-734d52b58bf3056a91e16c866da00f5b49e40098.zip
clang-format: [Java] Fix line break behavior of class declarations.
Change breaking preferences: 1. Break before "extends" 2. Break before "implements" 3. Break within the implements list. llvm-svn: 221981
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index bce1d64166f..48ce19e1323 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1439,6 +1439,18 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
if (Left.is(tok::semi))
return 0;
+
+ if (Style.Language == FormatStyle::LK_Java) {
+ if (Left.Type == TT_LeadingJavaAnnotation)
+ return 1;
+ if (Right.is(Keywords.kw_extends))
+ return 1;
+ if (Right.is(Keywords.kw_implements))
+ return 2;
+ if (Left.is(tok::comma) && Left.NestingLevel == 0)
+ return 3;
+ }
+
if (Left.is(tok::comma) || (Right.is(tok::identifier) && Right.Next &&
Right.Next->Type == TT_DictLiteral))
return 1;
@@ -1448,6 +1460,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
if (Right.Type != TT_ObjCMethodExpr && Right.Type != TT_LambdaLSquare)
return 500;
}
+
if (Right.Type == TT_StartOfName ||
Right.Type == TT_FunctionDeclarationName || Right.is(tok::kw_operator)) {
if (Line.First->is(tok::kw_for) && Right.PartOfMultiVariableDeclStmt)
@@ -1472,12 +1485,6 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
Left.Type == TT_InheritanceColon)
return 2;
- if (Left.Type == TT_LeadingJavaAnnotation)
- return 1;
- if (Style.Language == FormatStyle::LK_Java &&
- Right.is(Keywords.kw_implements))
- return 2;
-
if (Right.isMemberAccess()) {
if (Left.is(tok::r_paren) && Left.MatchingParen &&
Left.MatchingParen->ParameterCount > 0)
OpenPOWER on IntegriCloud