-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59397 from CyrusNajmabadi/simplifyWrapping
Simplify the wrapping code for initializer-expression wrapping
- Loading branch information
Showing
20 changed files
with
477 additions
and
651 deletions.
There are no files selected for viewing
This file contains 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
28 changes: 0 additions & 28 deletions
28
...ures/CSharp/Portable/Wrapping/InitializerExpression/CSharpInitializerExpressionWrapper.cs
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
51 changes: 51 additions & 0 deletions
51
...atures/CSharp/Portable/Wrapping/SeparatedSyntaxList/CSharpInitializerExpressionWrapper.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.CodeAnalysis.CSharp.Formatting; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using Microsoft.CodeAnalysis.Options; | ||
using Roslyn.Utilities; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp.Wrapping.SeparatedSyntaxList | ||
{ | ||
internal sealed partial class CSharpInitializerExpressionWrapper | ||
: AbstractCSharpSeparatedSyntaxListWrapper<InitializerExpressionSyntax, ExpressionSyntax> | ||
{ | ||
protected override string Indent_all_items => FeaturesResources.Indent_all_elements; | ||
protected override string Unwrap_all_items => FeaturesResources.Unwrap_all_elements; | ||
protected override string Unwrap_list => FeaturesResources.Unwrap_initializer; | ||
protected override string Wrap_every_item => FeaturesResources.Wrap_initializer; | ||
protected override string Wrap_long_list => FeaturesResources.Wrap_long_initializer; | ||
|
||
public override bool Supports_UnwrapGroup_WrapFirst_IndentRest => false; | ||
public override bool Supports_WrapEveryGroup_UnwrapFirst => false; | ||
public override bool Supports_WrapLongGroup_UnwrapFirst => false; | ||
|
||
// unreachable as we explicitly declare that we don't support these scenarios. | ||
|
||
protected override string Align_wrapped_items => throw ExceptionUtilities.Unreachable; | ||
protected override string Indent_wrapped_items => throw ExceptionUtilities.Unreachable; | ||
protected override string Unwrap_and_indent_all_items => throw ExceptionUtilities.Unreachable; | ||
|
||
protected override bool ShouldMoveOpenBraceToNewLine(OptionSet options) | ||
=> options.GetOption(CSharpFormattingOptions.NewLinesForBracesInObjectCollectionArrayInitializers); | ||
|
||
protected override bool ShouldMoveCloseBraceToNewLine | ||
=> true; | ||
|
||
protected override SeparatedSyntaxList<ExpressionSyntax> GetListItems(InitializerExpressionSyntax listSyntax) | ||
=> listSyntax.Expressions; | ||
|
||
protected override InitializerExpressionSyntax? TryGetApplicableList(SyntaxNode node) | ||
=> node as InitializerExpressionSyntax; | ||
|
||
protected override bool PositionIsApplicable(SyntaxNode root, int position, SyntaxNode declaration, bool containsSyntaxError, InitializerExpressionSyntax listSyntax) | ||
{ | ||
if (containsSyntaxError) | ||
return false; | ||
|
||
return listSyntax.Span.Contains(position); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
176 changes: 0 additions & 176 deletions
176
...e/Portable/Wrapping/AbstractSeparatedListWrapper`2+AbstractSeparatedListCodeComputer`1.cs
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
src/Features/Core/Portable/Wrapping/AbstractSeparatedListWrapper`2.cs
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Oops, something went wrong.