r234754 - clang-format: [JS] Support index signature types.
Daniel Jasper
djasper at google.com
Mon Apr 13 08:03:30 PDT 2015
Author: djasper
Date: Mon Apr 13 10:03:30 2015
New Revision: 234754
URL: http://llvm.org/viewvc/llvm-project?rev=234754&view=rev
Log:
clang-format: [JS] Support index signature types.
Patch by Martin Probst.
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=234754&r1=234753&r2=234754&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Apr 13 10:03:30 2015
@@ -413,7 +413,8 @@ private:
if (Contexts.back().ColonIsForRangeExpr ||
(Contexts.size() == 1 &&
!Line.First->isOneOf(tok::kw_enum, tok::kw_case)) ||
- Contexts.back().ContextKind == tok::l_paren) {
+ Contexts.back().ContextKind == tok::l_paren ||
+ Contexts.back().ContextKind == tok::l_square) {
Tok->Type = TT_JsTypeColon;
break;
}
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=234754&r1=234753&r2=234754&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Apr 13 10:03:30 2015
@@ -670,5 +670,9 @@ TEST_F(FormatTestJS, OptionalTypes) {
"}");
}
+TEST_F(FormatTestJS, IndexSignature) {
+ verifyFormat("var x: {[k: string]: v};");
+}
+
} // end namespace tooling
} // end namespace clang
More information about the cfe-commits
mailing list