aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-09-04 14:58:30 +0000
committerDaniel Jasper <djasper@google.com>2014-09-04 14:58:30 +0000
commit94e11d02d88ea33c3212d3dab3dc0245509c8fe5 (patch)
treeb41bc26c86f7ac34aef529a9145f90ec5d255fb8 /clang/lib
parent2132b704ff72ba0f55793a2faea8323900cb619a (diff)
downloadllvm-94e11d02d88ea33c3212d3dab3dc0245509c8fe5.zip
llvm-94e11d02d88ea33c3212d3dab3dc0245509c8fe5.tar.gz
llvm-94e11d02d88ea33c3212d3dab3dc0245509c8fe5.tar.bz2
clang-format: [JS] Support comments in dict literals.
Before: var stuff = { // comment for update update : false, // comment for update modules : false, // comment for update tasks : false }; After: var stuff = { // comment for update update : false, // comment for update modules : false, // comment for update tasks : false }; llvm-svn: 217157
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 3b92c10..6142e7d 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1100,7 +1100,7 @@ public:
++OperatorIndex;
}
- next();
+ next(/*SkipPastLeadingComments=*/false);
}
}
}
@@ -1113,7 +1113,9 @@ private:
if (Current->Type == TT_ConditionalExpr)
return prec::Conditional;
else if (Current->is(tok::semi) || Current->Type == TT_InlineASMColon ||
- Current->Type == TT_SelectorName)
+ Current->Type == TT_SelectorName ||
+ (Current->is(tok::comment) && Current->getNextNonComment() &&
+ Current->getNextNonComment()->Type == TT_SelectorName))
return 0;
else if (Current->Type == TT_RangeBasedForLoopColon)
return prec::Comma;
@@ -1166,10 +1168,12 @@ private:
addFakeParenthesis(Start, prec::Conditional);
}
- void next() {
+ void next(bool SkipPastLeadingComments = true) {
if (Current)
Current = Current->Next;
- while (Current && Current->isTrailingComment())
+ while (Current &&
+ (Current->NewlinesBefore == 0 || SkipPastLeadingComments) &&
+ Current->isTrailingComment())
Current = Current->Next;
}