summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-11-21 12:14:12 +0000
committerDaniel Jasper <djasper@google.com>2014-11-21 12:14:12 +0000
commit8354ea84dd5497d2af230b258cb9657b69c82f87 (patch)
treeb599b68c53379de4745300e00315c0a094a179e8 /clang/lib/Format/TokenAnnotator.cpp
parentee9af45b1985720f876f8ea14960ed62c9d5e236 (diff)
downloadbcm5719-llvm-8354ea84dd5497d2af230b258cb9657b69c82f87.tar.gz
bcm5719-llvm-8354ea84dd5497d2af230b258cb9657b69c82f87.zip
clang-format: [Java] Basic lambda support.
llvm-svn: 222524
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 1afdb19b29d..6d9006be30b 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -786,6 +786,9 @@ private:
Current.Type = TT_StartOfName;
} else if (Current.is(tok::kw_auto)) {
AutoFound = true;
+ } else if (Current.is(tok::arrow) &&
+ Style.Language == FormatStyle::LK_Java) {
+ Current.Type = TT_LambdaArrow;
} else if (Current.is(tok::arrow) && AutoFound &&
Line.MustBeDeclaration && Current.NestingLevel == 0) {
Current.Type = TT_TrailingReturnArrow;
@@ -1167,6 +1170,8 @@ private:
else if (NextNonComment && NextNonComment->is(tok::colon) &&
NextNonComment->Type == TT_DictLiteral)
return prec::Comma;
+ else if (Current->is(TT_LambdaArrow))
+ return prec::Comma;
else if (Current->is(tok::semi) || Current->Type == TT_InlineASMColon ||
Current->Type == TT_SelectorName ||
(Current->is(tok::comment) && NextNonComment &&
@@ -1701,6 +1706,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
if (Left.is(Keywords.kw_var))
return true;
} else if (Style.Language == FormatStyle::LK_Java) {
+ if (Left.is(TT_LambdaArrow) || Right.is(TT_LambdaArrow))
+ return true;
if (Left.is(Keywords.kw_synchronized) && Right.is(tok::l_paren))
return Style.SpaceBeforeParens != FormatStyle::SBPO_Never;
if (Left.isOneOf(tok::kw_static, tok::kw_public, tok::kw_private,
OpenPOWER on IntegriCloud