[PATCH] D148472: [clang-format] CSharp don't allow there not to be a space between `is` and `[`
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 17 11:40:09 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
MyDeveloperDay marked an inline comment as done.
Closed by commit rG63395cb0b69d: [clang-format] CSharp don't allow there not to be a space between `is` and `[` (authored by MyDeveloperDay).
Changed prior to commit:
https://reviews.llvm.org/D148472?vs=514032&id=514338#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148472/new/
https://reviews.llvm.org/D148472
Files:
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestCSharp.cpp
Index: clang/unittests/Format/FormatTestCSharp.cpp
===================================================================
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -1176,6 +1176,14 @@
verifyFormat(R"(override (string name, int age) methodTuple() {})", Style);
verifyFormat(R"(async (string name, int age) methodTuple() {})", Style);
verifyFormat(R"(unsafe (string name, int age) methodTuple() {})", Style);
+
+ Style.SpacesInSquareBrackets = false;
+ Style.SpaceBeforeSquareBrackets = true;
+ verifyFormat("return a is [1, 2, 3];", Style);
+ verifyFormat("return a is [..];", Style);
+ Style.SpaceBeforeSquareBrackets = false;
+ verifyFormat("return a is [1, 2, 3];", Style);
+ verifyFormat("return a is [..];", Style);
}
TEST_F(FormatTestCSharp, CSharpNullableTypes) {
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3917,6 +3917,8 @@
}
}
}
+ if (Style.isCSharp() && Left.is(Keywords.kw_is) && Right.is(tok::l_square))
+ return true;
const auto SpaceRequiredForArrayInitializerLSquare =
[](const FormatToken &LSquareTok, const FormatStyle &Style) {
return Style.SpacesInContainerLiterals ||
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148472.514338.patch
Type: text/x-patch
Size: 1351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230417/1dfdcded/attachment.bin>
More information about the cfe-commits
mailing list