[clang-format] [PR43338] C# clang format has space issues betweern C# only keywords
authorPaul Hoad <mydeveloperday@gmail.com>
Fri, 4 Oct 2019 08:10:22 +0000 (08:10 +0000)
committerPaul Hoad <mydeveloperday@gmail.com>
Fri, 4 Oct 2019 08:10:22 +0000 (08:10 +0000)
commit4c056583548ab59e2ad24deb2ca30790a290a8e3
tree93a0c382c17489e0a62c0d47134c4d1850fac95a
parent7588cf09da479a66f8ceba4bd78eba83787b16ac
[clang-format] [PR43338] C# clang format has space issues betweern C# only keywords

Summary:
When formatting C# there can be issues with a lack of spaces between `using (` , `foreach (` and generic types

The C# code

```
public class Foo
{
    Dictionary<string,string> foo;
}

```
will be formatted as

```
public class Foo
{
    Dictionary<string, string>foo;
                           ^^^^^   missing a space
}
```

This revision also reverts some of {D66662} in order to make this cleaner and resolve an issues seen by @owenpan that the formatting didn't add a space when not in a code block

This also transforms C# foreach commands to be seen as tok::kw_for commands (to ensure foreach gets the same Brace Wrapping behavior as for without littering the code with `if(Style.isCSharp())`

Reviewers: owenpan, klimek, russellmcc, mitchell-stellar

Reviewed By: mitchell-stellar

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D67660

llvm-svn: 373709
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/FormatTokenLexer.h
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestCSharp.cpp