From: Daniel Jasper Date: Tue, 1 Nov 2016 06:23:10 +0000 (+0000) Subject: clang-format: [JS] Fix incorrect space when "as" is used as identifier. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=11826f8d2caddebe447188541fe300a0c8051a8c;p=clang clang-format: [JS] Fix incorrect space when "as" is used as identifier. Before: aaaaa.as (); After: aaaaa.as(); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285672 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 129fe84490..1a3faad6e2 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -2160,7 +2160,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, Keywords.kw_of, tok::kw_const) && (!Left.Previous || !Left.Previous->is(tok::period))) return true; - if (Left.is(tok::kw_for) && Left.Previous && + if (Left.isOneOf(tok::kw_for, Keywords.kw_as) && Left.Previous && Left.Previous->is(tok::period) && Right.is(tok::l_paren)) return false; if (Left.is(Keywords.kw_as) && diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 846abaffeb..f4b50591aa 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -136,6 +136,7 @@ TEST_F(FormatTestJS, ReservedWords) { verifyFormat("x.let() = 1;"); verifyFormat("x.var() = 1;"); verifyFormat("x.for() = 1;"); + verifyFormat("x.as() = 1;"); verifyFormat("x = {\n" " a: 12,\n" " interface: 1,\n"