From 29ade3b218f62bc68f337917e366e37b8fdca7cd Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Sat, 2 May 2015 07:54:58 +0000 Subject: [PATCH] clang-format: [JS] Fix templated parameter default values. Parameters can have templated types and default values (= ...), which is another location in which a template closer should be followed by whitespace. Patch by Martin Probst, thank you. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236382 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 2 +- unittests/Format/FormatTestJS.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index e52650be07..00348a2c9f 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1804,7 +1804,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, Line.First->isOneOf(Keywords.kw_import, tok::kw_export)) return false; if (Left.is(TT_TemplateCloser) && - !Right.isOneOf(tok::l_brace, tok::comma, tok::l_square, + !Right.isOneOf(tok::equal, tok::l_brace, tok::comma, tok::l_square, Keywords.kw_implements, Keywords.kw_extends)) // Type assertions ('expr') are not followed by whitespace. Other // locations that should have whitespace following are identified by the diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 695bad5553..e0719ee4fc 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -687,6 +687,8 @@ TEST_F(FormatTestJS, TypeArguments) { verifyFormat("foo(a);"); verifyFormat("var x: X[];"); verifyFormat("class C extends D implements F, H {}"); + verifyFormat("function f(a: List = null) {\n}"); + verifyFormat("function f(): List {\n}"); } TEST_F(FormatTestJS, OptionalTypes) { -- 2.50.1