taymonbeal updated this revision to Diff 498692. taymonbeal added a comment.
Merge unit test into existing test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144317/new/ https://reviews.llvm.org/D144317 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTestJS.cpp Index: clang/unittests/Format/FormatTestJS.cpp =================================================================== --- clang/unittests/Format/FormatTestJS.cpp +++ clang/unittests/Format/FormatTestJS.cpp @@ -2221,6 +2221,7 @@ " aaaaaaaaaaaaaaa?: boolean,\n" " aaaaaa?: List<string>\n" "}) {}"); + verifyFormat("type X = [y?];"); } TEST_F(FormatTestJS, IndexSignature) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1248,7 +1248,7 @@ case tok::question: if (Style.isJavaScript() && Tok->Next && Tok->Next->isOneOf(tok::semi, tok::comma, tok::colon, tok::r_paren, - tok::r_brace)) { + tok::r_brace, tok::r_square)) { // Question marks before semicolons, colons, etc. indicate optional // types (fields, parameters), e.g. // function(x?: string, y?) {...}
Index: clang/unittests/Format/FormatTestJS.cpp =================================================================== --- clang/unittests/Format/FormatTestJS.cpp +++ clang/unittests/Format/FormatTestJS.cpp @@ -2221,6 +2221,7 @@ " aaaaaaaaaaaaaaa?: boolean,\n" " aaaaaa?: List<string>\n" "}) {}"); + verifyFormat("type X = [y?];"); } TEST_F(FormatTestJS, IndexSignature) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1248,7 +1248,7 @@ case tok::question: if (Style.isJavaScript() && Tok->Next && Tok->Next->isOneOf(tok::semi, tok::comma, tok::colon, tok::r_paren, - tok::r_brace)) { + tok::r_brace, tok::r_square)) { // Question marks before semicolons, colons, etc. indicate optional // types (fields, parameters), e.g. // function(x?: string, y?) {...}
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits