[PATCH] D79008: [clang-format] insert space after C# keyword var in var (key, value)

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 28 09:39:45 PDT 2020


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 <jbcoe at 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))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79008.260671.patch
Type: text/x-patch
Size: 1085 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200428/5e9f61a6/attachment.bin>


More information about the cfe-commits mailing list