[PATCH] D66736: clang-format: [JS] handle `as const`.
Martin Probst via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 26 08:39:34 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5836472ac488: clang-format: [JS] handle `as const`. (authored by mprobst).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66736/new/
https://reviews.llvm.org/D66736
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
@@ -1479,6 +1479,9 @@
" .someFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
verifyFormat("const xIsALongIdent:\n"" YJustBarelyFitsLinex[];",
getGoogleJSStyleWithColumns(20));
+ verifyFormat("const x = {\n"
+ " y: 1\n"
+ "} as const;");
}
TEST_F(FormatTestJS, UnionIntersectionTypes) {
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2746,6 +2746,10 @@
tok::kw_void))
return true;
}
+ // `foo as const;` casts into a const type.
+ if (Left.endsSequence(tok::kw_const, Keywords.kw_as)) {
+ return false;
+ }
if ((Left.isOneOf(Keywords.kw_let, Keywords.kw_var, Keywords.kw_in,
tok::kw_const) ||
// "of" is only a keyword if it appears after another identifier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66736.217166.patch
Type: text/x-patch
Size: 1168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190826/3f8e3aa5/attachment.bin>
More information about the cfe-commits
mailing list