diff options
| author | Daniel Jasper <djasper@google.com> | 2014-09-05 08:29:31 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-09-05 08:29:31 +0000 |
| commit | 97bfb7b1ba5dfc5c0d71e8e9bea3e23e9666ba17 (patch) | |
| tree | 7deec385daf09507549ced5cacce63ff3f17208d /clang | |
| parent | 634c355e35b0d04034a7023dbd674785f6fccb5a (diff) | |
| download | bcm5719-llvm-97bfb7b1ba5dfc5c0d71e8e9bea3e23e9666ba17.tar.gz bcm5719-llvm-97bfb7b1ba5dfc5c0d71e8e9bea3e23e9666ba17.zip | |
clang-format: [JS] Fix indentation in dict literals.
Before:
return {
'finish':
//
a
};
After:
return {
'finish':
//
a
};
llvm-svn: 217235
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 8 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 5 |
2 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 00c486a3add..13613287789 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1110,12 +1110,16 @@ private: /// and other tokens that we treat like binary operators. int getCurrentPrecedence() { if (Current) { + const FormatToken *NextNonComment = Current->getNextNonComment(); if (Current->Type == TT_ConditionalExpr) return prec::Conditional; + else if (NextNonComment && NextNonComment->is(tok::colon) && + NextNonComment->Type == TT_DictLiteral) + return prec::Comma; else if (Current->is(tok::semi) || Current->Type == TT_InlineASMColon || Current->Type == TT_SelectorName || - (Current->is(tok::comment) && Current->getNextNonComment() && - Current->getNextNonComment()->Type == TT_SelectorName)) + (Current->is(tok::comment) && NextNonComment && + NextNonComment->Type == TT_SelectorName)) return 0; else if (Current->Type == TT_RangeBasedForLoopColon) return prec::Comma; diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index fcddba72a8b..55e7cc6fe19 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -123,6 +123,11 @@ TEST_F(FormatTestJS, ContainerLiterals) { " // comment for tasks\n" " tasks: false\n" "};"); + verifyFormat("return {\n" + " 'finish':\n" + " //\n" + " a\n" + "};"); } TEST_F(FormatTestJS, SpacesInContainerLiterals) { |

