Disable merging of Type? into a single token.
Merge ?? ?. and ?[ into a single token.
Paths
| Differential D75368
[clang-format] Handle NullCoalescing and NullConditional operators in C# ClosedPublic Authored by jbcoe on Feb 28 2020, 10:19 AM.
Details Summary Disable merging of Type? into a single token. Merge ?? ?. and ?[ into a single token.
Diff Detail
Unit TestsFailed Event TimelineComment Actions There's a weird test failure I'm unable to reproduce outside of the tests with real source code where public static void Main(string[] args) { string dirPath = args?[0]; } is (mis)-formatted as public static void Main(string[] args) { string dirPath = args?[0]; }
jbcoe retitled this revision from [clang-format] Handle ?. ?? and ?[ as C# tokens to [clang-format] Handle NullCoalescing and NullConditional operators in C#.Mar 2 2020, 5:19 AM krasimir added inline comments. This revision is now accepted and ready to land.Mar 2 2020, 5:26 AM Closed by commit rGc3af063c2bbf: [clang-format] Handle NullCoalescing and NullConditional operators in C# (authored by Jonathan Coe <jbcoe@google.com>). · Explain WhyMar 2 2020, 6:17 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 247304 clang/include/clang/Basic/TokenKinds.def
clang/lib/Format/FormatToken.h
clang/lib/Format/FormatTokenLexer.h
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestCSharp.cpp
|
I think this is not a good place to add these.
I think these definitions are generally for languages clang itself supports (compiling)
This could have unexpected ripple effects in unrelated parts of the clang.
Could you try to handle these somehow in lib/Format/FormatTokenLexer?
That's where the clang-format has some glue / heuristics for handling other languages syntax.