diff options
author | Daniel Jasper <djasper@google.com> | 2016-02-01 11:20:47 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2016-02-01 11:20:47 +0000 |
commit | 1ce41112a43005b3ac2ee24119f2e633d86a27f5 (patch) | |
tree | 08294210b03bfba01865923e0a104cd435c25b00 /clang/lib | |
parent | a5b8ea0d66c2316275e51a50a5a4341c1a990868 (diff) | |
download | bcm5719-llvm-1ce41112a43005b3ac2ee24119f2e633d86a27f5.tar.gz bcm5719-llvm-1ce41112a43005b3ac2ee24119f2e633d86a27f5.zip |
clang-format: [JS] Treat "in" as a proper operator.
llvm-svn: 259350
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 9435ea9704a..6d02557dd9c 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1035,6 +1035,9 @@ private: if (Tok.Previous->isOneOf(TT_LeadingJavaAnnotation, Keywords.kw_instanceof)) return false; + if (Style.Language == FormatStyle::LK_JavaScript && + Tok.Previous->is(Keywords.kw_in)) + return false; // Skip "const" as it does not have an influence on whether this is a name. FormatToken *PreviousNotConst = Tok.Previous; @@ -1390,6 +1393,9 @@ private: Style.Language == FormatStyle::LK_JavaScript) && Current->is(Keywords.kw_instanceof)) return prec::Relational; + if (Style.Language == FormatStyle::LK_JavaScript && + Current->is(Keywords.kw_in)) + return prec::Relational; if (Current->is(TT_BinaryOperator) || Current->is(tok::comma)) return Current->getPrecedence(); if (Current->isOneOf(tok::period, tok::arrow)) @@ -2277,6 +2283,10 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, return true; if (Right.NestingLevel == 0 && Right.is(Keywords.kw_is)) return false; + if (Left.is(Keywords.kw_in)) + return Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None; + if (Right.is(Keywords.kw_in)) + return Style.BreakBeforeBinaryOperators != FormatStyle::BOS_None; } if (Left.is(tok::at)) |