mprobst updated this revision to Diff 68844. mprobst added a comment. - drop accidentally included template string patch from this diff.
https://reviews.llvm.org/D23761 Files: lib/Format/TokenAnnotator.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp =================================================================== --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1219,6 +1219,9 @@ " 2\n" "];"); verifyFormat("var x = [{x: 1} as type];"); + verifyFormat("x = x as [a, b];"); + verifyFormat("x = x as {a: string};"); + verifyFormat("x = x as (string);"); } TEST_F(FormatTestJS, TypeArguments) { Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2121,6 +2121,9 @@ Keywords.kw_of, tok::kw_const) && (!Left.Previous || !Left.Previous->is(tok::period))) return true; + if (Left.is(Keywords.kw_as) && + Right.isOneOf(tok::l_square, tok::l_brace, tok::l_paren)) + return true; if (Left.is(tok::kw_default) && Left.Previous && Left.Previous->is(tok::kw_export)) return true;
Index: unittests/Format/FormatTestJS.cpp =================================================================== --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1219,6 +1219,9 @@ " 2\n" "];"); verifyFormat("var x = [{x: 1} as type];"); + verifyFormat("x = x as [a, b];"); + verifyFormat("x = x as {a: string};"); + verifyFormat("x = x as (string);"); } TEST_F(FormatTestJS, TypeArguments) { Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2121,6 +2121,9 @@ Keywords.kw_of, tok::kw_const) && (!Left.Previous || !Left.Previous->is(tok::period))) return true; + if (Left.is(Keywords.kw_as) && + Right.isOneOf(tok::l_square, tok::l_brace, tok::l_paren)) + return true; if (Left.is(tok::kw_default) && Left.Previous && Left.Previous->is(tok::kw_export)) return true;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits