Implement Initializer expression wrappers#39878
Merged
CyrusNajmabadi merged 58 commits intodotnet:mainfrom Feb 11, 2022
Merged
Conversation
The basic class is in place for visual basic to have the appropriate wrapping refactoring. The wrapping is mostly correct and just needs a small tweak for the closing brace to be on a line by itself.
The closing brace is calculated based on what kind of syntax we are dealing with. If it is a DeclarationKind then we can just align it based on the span start. If it is a return statement we need to add an extra tab for spacing because there is no declarationkind for returns and we passed our starting point.
- After wrapping if you tried to get refactorings again it was throwing
an exception. Calculating the distance between first node before the {
fixed the issue.
- The unwrap refactoring wasn't moving the opening { to the previous line
These tests confirm that one when one of the refactoring offerings has been choosen if the user asks for more refactorings they are offered the other two options to rewrite the initializer.
Also, remove the old comments that were copied over from the other wrapping code computer implementations
Resolve the conflicts in FeatureResources.resx
src/EditorFeatures/CSharpTest/Wrapping/InitializerExpressionWrappingTests.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/CSharpTest/Wrapping/InitializerExpressionWrappingTests.cs
Show resolved
Hide resolved
src/EditorFeatures/VisualBasicTest/Wrapping/InitializerExpressionWrappingTests.vb
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/Wrapping/CSharpWrappingCodeRefactoringProvider.cs
Show resolved
Hide resolved
...CSharp/Portable/Wrapping/InitializerExpression/AbstractCSharpInitializerExpressionWrapper.cs
Outdated
Show resolved
Hide resolved
| where TListSyntax : SyntaxNode | ||
| where TListItemSyntax : SyntaxNode | ||
| { | ||
| protected override string Indent_all_items => FeaturesResources.Indent_all_arguments; |
Contributor
Author
There was a problem hiding this comment.
Whoops, I thought I changed that. I was going to look at removing these sub labels too unless you think they would be better left in. But, as of now each refactoring only has one option and that seems pointless.
|
|
||
| namespace Microsoft.CodeAnalysis.CSharp.Wrapping.InitializerExpression | ||
| { | ||
| internal partial class CSharpInitializerExpression : AbstractCSharpInitializerExpressionWrapper<InitializerExpressionSyntax, ExpressionSyntax> |
Contributor
There was a problem hiding this comment.
CSharpInitializerExpressionWrapper
src/Features/CSharp/Portable/Wrapping/InitializerExpression/CSharpInitializerExpression.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/Wrapping/InitializerExpression/CSharpInitializerExpression.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/Wrapping/InitializerExpression/CSharpInitializerExpression.cs
Outdated
Show resolved
Hide resolved
src/Features/Core/Portable/Wrapping/InitializerExpression/AbstractInitializerExpression.cs
Outdated
Show resolved
Hide resolved
Contributor
|
@jasonmalinowski i believe this community PR is ready for team review. thanks! |
Member
|
@CyrusNajmabadi, yep, it's on my list along with seemingly everybody else's. Should get to it in a day or two. |
…omputer.cs Co-Authored-By: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
Co-Authored-By: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
Co-Authored-By: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
Contributor
|
Thanks @jasonmalinowski ! |
Contributor
Contributor
|
I'm working on resolving the merge conflicts... |
sharwell
approved these changes
Feb 8, 2022
...Core/Portable/Wrapping/AbstractSeparatedListWrapper`2+AbstractSeparatedListCodeComputer`1.cs
Show resolved
Hide resolved
425c27b to
cb26d8f
Compare
| // MethodName( | ||
| // int a, int b, int c, int d, int e, int f, int g, int h, int i, int j) | ||
| unwrapActions.Add(await GetUnwrapAllCodeActionAsync(parentTitle, WrappingStyle.WrapFirst_IndentRest).ConfigureAwait(false)); | ||
| if (this.Wrapper.Supports_UnwrapGroup_WrapFirst_IndentRest) |
Contributor
There was a problem hiding this comment.
i recommend reviewing with whitespace off.
e4f5b2c to
425c27b
Compare
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Users will now be offered refactoring options for collection initializers. The implementation was modelled after the AbstractSeparatedSyntaxList implementation. This applies to visual basic and c#.
There are 3 choices for users:
Resolves #37428