From 9a6e49f6940c66bfa04e86cd2226d1f43834d2be Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 14 Jun 2016 11:28:02 +0000 Subject: [PATCH] clang-format: [JS] Support annotated classes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272654 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 3 ++- unittests/Format/FormatTestJS.cpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index cd8f28b081..7df3bdd781 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1461,7 +1461,8 @@ private: return Current->getPrecedence(); if (Current->isOneOf(tok::period, tok::arrow)) return PrecedenceArrowAndPeriod; - if (Style.Language == FormatStyle::LK_Java && + if ((Style.Language == FormatStyle::LK_Java || + Style.Language == FormatStyle::LK_JavaScript) && Current->isOneOf(Keywords.kw_extends, Keywords.kw_implements, Keywords.kw_throws)) return 0; diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 75b53a5787..8410a0c996 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -948,6 +948,11 @@ TEST_F(FormatTestJS, ClassDeclarations) { " },\n" " };\n" "}"); + verifyFormat("@Component({\n" + " moduleId: module.id,\n" + "})\n" + "class SessionListComponent implements OnDestroy, OnInit {\n" + "}"); } TEST_F(FormatTestJS, InterfaceDeclarations) { -- 2.50.1