This revision was automatically updated to reflect the committed changes. Closed by commit rG7443f86eabba: [clang-format] insert space after C# keyword var in var (key, value) (authored by Jonathan Coe <jb...@google.com>).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79008/new/ https://reviews.llvm.org/D79008 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 @@ -698,6 +698,7 @@ verifyFormat(R"(Result this[Index x] => Foo(x);)", Style); verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style); + verifyFormat(R"(var (key, value))", Style); // Not seen as a C-style cast. verifyFormat(R"(// Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3053,6 +3053,10 @@ if (Left.is(TT_CSharpNullConditionalLSquare)) return Style.SpacesInSquareBrackets; + // space after var in `var (key, value)` + if (Left.is(Keywords.kw_var) && Right.is(tok::l_paren)) + return true; + // space between keywords and paren e.g. "using (" if (Right.is(tok::l_paren)) if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))
Index: clang/unittests/Format/FormatTestCSharp.cpp =================================================================== --- clang/unittests/Format/FormatTestCSharp.cpp +++ clang/unittests/Format/FormatTestCSharp.cpp @@ -698,6 +698,7 @@ verifyFormat(R"(Result this[Index x] => Foo(x);)", Style); verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style); + verifyFormat(R"(var (key, value))", Style); // Not seen as a C-style cast. verifyFormat(R"(// Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3053,6 +3053,10 @@ if (Left.is(TT_CSharpNullConditionalLSquare)) return Style.SpacesInSquareBrackets; + // space after var in `var (key, value)` + if (Left.is(Keywords.kw_var) && Right.is(tok::l_paren)) + return true; + // space between keywords and paren e.g. "using (" if (Right.is(tok::l_paren)) if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits