summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-04-13 15:03:30 +0000
committerDaniel Jasper <djasper@google.com>2015-04-13 15:03:30 +0000
commitd9309774a63e18667fde8e31fab39fdb375d8c6f (patch)
tree4af73211df298a399cbafa1d29ada6fa9ddb4bf7 /clang
parenta74f5072e1733e41256a652737bc17798687a8a0 (diff)
downloadbcm5719-llvm-d9309774a63e18667fde8e31fab39fdb375d8c6f.tar.gz
bcm5719-llvm-d9309774a63e18667fde8e31fab39fdb375d8c6f.zip
clang-format: [JS] Support index signature types.
Patch by Martin Probst. llvm-svn: 234754
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp4
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 0ea67b288d0..0c11c88221f 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -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;
}
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index eb587f27694..3c8c14d2ba8 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -670,5 +670,9 @@ TEST_F(FormatTestJS, OptionalTypes) {
"}");
}
+TEST_F(FormatTestJS, IndexSignature) {
+ verifyFormat("var x: {[k: string]: v};");
+}
+
} // end namespace tooling
} // end namespace clang
OpenPOWER on IntegriCloud