Move the handling of brace wrapping after => from unwrapped line parser to token annotator and clean up the parser.
Details
Diff Detail
Unit Tests
Time | Test | |
---|---|---|
40 ms | x64 debian > LLVM.Bindings/Go::go.test |
Event Timeline
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
1640–1641 | Should we add the isCSharp check? |
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
1640–1641 | No. It was not there before, and adding it would fail several JavaScript test cases. |
Additional cleanups:
- Restrict parsing => to JavaScript and C#.
- Rename tryToParseCSharpLambda to tryToParseChildBlock.
- Remove redundant caret case.
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
1640–1641 |
Added checking for either JavaScript or C#. |
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
2005 | Is this case not covered by this? I presume not as you didn't remove any unit tests https://github.com/llvm/llvm-project/commit/516e054c05fcf92b89fbac3e22048f2c00cf218f void f() { int i = {[operation setCompletionBlock : ^{ [self onOperationDone]; }] }; } |
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
2005 | I had checked the commit you mentioned above before I decided to remove this case. Apparently it's redundant to the caret case in parseStructuralElement(). |
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
1955–1957 | It seems that this block could be removed altogether, because this is already done on lines 1964-165, and it's done regardless if it the language is C# or not. |
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
1955–1957 | Lines 1964-1965 only apply to JavaScript because of line 1958, so lines 1955-1957 cannot be removed. |
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
1964–1965 | Removing these two lines doesn't fail FormatTests. |
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
1955–1957 | Oh yes, sorry I missed the Javascript block. I wonder if in that case wouldn't be more consistent to add Javascript check on the line 1955 to be consistent with how the same block of logic is handled on the lines 1641-1645. |
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
1955–1957 | I don't think so because here we must parse the optional async function part first for JavaScript only. |
Should we add the isCSharp check?