提交 badf87ac 编写于 作者: C Cyrus Najmabadi

Simplify.

上级 c3b0e58d
......@@ -505,6 +505,44 @@ public async Task TestAdditionBeginning()
+ ""the""
+ ""time"";
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsWrapping)]
public async Task TestUnderscoreName_End()
{
await TestEndOfLine(
@"class C {
void Bar() {
if ([||]i is var _ && _ != null) {
}
}
}",
@"class C {
void Bar() {
if (i is var _ &&
_ != null) {
}
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsWrapping)]
public async Task TestUnderscoreName_Beginning()
{
await TestBeginningOfLine(
@"class C {
void Bar() {
if ([||]i is var _ && _ != null) {
}
}
}",
@"class C {
void Bar() {
if (i is var _
&& _ != null) {
}
}
}");
}
}
......
......@@ -48,33 +48,20 @@ private class BinaryExpressionCodeActionComputer :
protected override async Task<ImmutableArray<WrappingGroup>> ComputeWrappingGroupsAsync()
{
var actions = ArrayBuilder<WrapItemsAction>.GetInstance();
if (_preference == OperatorPlacementWhenWrappingPreference.EndOfLine)
{
actions.Add(await GetWrapCodeActionAsync(includeOperators: false).ConfigureAwait(false));
}
else
{
actions.Add(await GetWrapCodeActionAsync(includeOperators: true).ConfigureAwait(false));
}
actions.Add(await GetWrapCodeActionAsync().ConfigureAwait(false));
actions.Add(await GetUnwrapCodeActionAsync().ConfigureAwait(false));
return ImmutableArray.Create(new WrappingGroup(
isInlinable: true, actions.ToImmutableAndFree()));
}
private Task<WrapItemsAction> GetWrapCodeActionAsync(bool includeOperators)
private Task<WrapItemsAction> GetWrapCodeActionAsync()
=> TryCreateCodeActionAsync(
GetWrapEdits(includeOperators),
GetWrapEdits(),
FeaturesResources.Wrapping,
includeOperators
? FeaturesResources.Wrap_expression_including_operators
: FeaturesResources.Wrap_expression);
FeaturesResources.Wrap_expression);
/// <param name="includeOperators">Whether or not the operator should be wrapped
/// to the next line as well, or if it should stay on the same line it started on.</param>
private ImmutableArray<Edit> GetWrapEdits(bool includeOperators)
private ImmutableArray<Edit> GetWrapEdits()
{
var result = ArrayBuilder<Edit>.GetInstance();
......@@ -84,7 +71,7 @@ private ImmutableArray<Edit> GetWrapEdits(bool includeOperators)
var opToken = _exprsAndOperators[i].AsToken();
var right = _exprsAndOperators[i + 1].AsNode();
if (includeOperators)
if (_preference == OperatorPlacementWhenWrappingPreference.BeginningOfLine)
{
// convert:
// (a == b) && (c == d) to
......
......@@ -4475,15 +4475,6 @@ internal class FeaturesResources {
}
}
/// <summary>
/// Looks up a localized string similar to Wrap expression (including operators).
/// </summary>
internal static string Wrap_expression_including_operators {
get {
return ResourceManager.GetString("Wrap_expression_including_operators", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Wrap long argument list.
/// </summary>
......
......@@ -1472,9 +1472,6 @@ This version used in: {2}</value>
<data name="Replace_0_with_1" xml:space="preserve">
<value>Replace '{0}' with '{1}' </value>
</data>
<!--
protected override string Unwrap_list => FeaturesResources.Unwrap_parameter_list;
-->
<data name="Align_wrapped_parameters" xml:space="preserve">
<value>Align wrapped parameters</value>
</data>
......@@ -1583,9 +1580,6 @@ This version used in: {2}</value>
<data name="Wrap_expression" xml:space="preserve">
<value>Wrap expression</value>
</data>
<data name="Wrap_expression_including_operators" xml:space="preserve">
<value>Wrap expression (including operators)</value>
</data>
<data name="Wrapping" xml:space="preserve">
<value>Wrapping</value>
</data>
......
......@@ -357,11 +357,6 @@
<target state="new">Wrap expression</target>
<note />
</trans-unit>
<trans-unit id="Wrap_expression_including_operators">
<source>Wrap expression (including operators)</source>
<target state="new">Wrap expression (including operators)</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_argument_list">
<source>Wrap long argument list</source>
<target state="new">Wrap long argument list</target>
......
......@@ -357,11 +357,6 @@
<target state="new">Wrap expression</target>
<note />
</trans-unit>
<trans-unit id="Wrap_expression_including_operators">
<source>Wrap expression (including operators)</source>
<target state="new">Wrap expression (including operators)</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_argument_list">
<source>Wrap long argument list</source>
<target state="new">Wrap long argument list</target>
......
......@@ -357,11 +357,6 @@
<target state="new">Wrap expression</target>
<note />
</trans-unit>
<trans-unit id="Wrap_expression_including_operators">
<source>Wrap expression (including operators)</source>
<target state="new">Wrap expression (including operators)</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_argument_list">
<source>Wrap long argument list</source>
<target state="new">Wrap long argument list</target>
......
......@@ -357,11 +357,6 @@
<target state="new">Wrap expression</target>
<note />
</trans-unit>
<trans-unit id="Wrap_expression_including_operators">
<source>Wrap expression (including operators)</source>
<target state="new">Wrap expression (including operators)</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_argument_list">
<source>Wrap long argument list</source>
<target state="new">Wrap long argument list</target>
......
......@@ -357,11 +357,6 @@
<target state="new">Wrap expression</target>
<note />
</trans-unit>
<trans-unit id="Wrap_expression_including_operators">
<source>Wrap expression (including operators)</source>
<target state="new">Wrap expression (including operators)</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_argument_list">
<source>Wrap long argument list</source>
<target state="new">Wrap long argument list</target>
......
......@@ -357,11 +357,6 @@
<target state="new">Wrap expression</target>
<note />
</trans-unit>
<trans-unit id="Wrap_expression_including_operators">
<source>Wrap expression (including operators)</source>
<target state="new">Wrap expression (including operators)</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_argument_list">
<source>Wrap long argument list</source>
<target state="new">Wrap long argument list</target>
......
......@@ -357,11 +357,6 @@
<target state="new">Wrap expression</target>
<note />
</trans-unit>
<trans-unit id="Wrap_expression_including_operators">
<source>Wrap expression (including operators)</source>
<target state="new">Wrap expression (including operators)</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_argument_list">
<source>Wrap long argument list</source>
<target state="new">Wrap long argument list</target>
......
......@@ -357,11 +357,6 @@
<target state="new">Wrap expression</target>
<note />
</trans-unit>
<trans-unit id="Wrap_expression_including_operators">
<source>Wrap expression (including operators)</source>
<target state="new">Wrap expression (including operators)</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_argument_list">
<source>Wrap long argument list</source>
<target state="new">Wrap long argument list</target>
......
......@@ -357,11 +357,6 @@
<target state="new">Wrap expression</target>
<note />
</trans-unit>
<trans-unit id="Wrap_expression_including_operators">
<source>Wrap expression (including operators)</source>
<target state="new">Wrap expression (including operators)</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_argument_list">
<source>Wrap long argument list</source>
<target state="new">Wrap long argument list</target>
......
......@@ -357,11 +357,6 @@
<target state="new">Wrap expression</target>
<note />
</trans-unit>
<trans-unit id="Wrap_expression_including_operators">
<source>Wrap expression (including operators)</source>
<target state="new">Wrap expression (including operators)</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_argument_list">
<source>Wrap long argument list</source>
<target state="new">Wrap long argument list</target>
......
......@@ -357,11 +357,6 @@
<target state="new">Wrap expression</target>
<note />
</trans-unit>
<trans-unit id="Wrap_expression_including_operators">
<source>Wrap expression (including operators)</source>
<target state="new">Wrap expression (including operators)</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_argument_list">
<source>Wrap long argument list</source>
<target state="new">Wrap long argument list</target>
......
......@@ -357,11 +357,6 @@
<target state="new">Wrap expression</target>
<note />
</trans-unit>
<trans-unit id="Wrap_expression_including_operators">
<source>Wrap expression (including operators)</source>
<target state="new">Wrap expression (including operators)</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_argument_list">
<source>Wrap long argument list</source>
<target state="new">Wrap long argument list</target>
......
......@@ -357,11 +357,6 @@
<target state="new">Wrap expression</target>
<note />
</trans-unit>
<trans-unit id="Wrap_expression_including_operators">
<source>Wrap expression (including operators)</source>
<target state="new">Wrap expression (including operators)</target>
<note />
</trans-unit>
<trans-unit id="Wrap_long_argument_list">
<source>Wrap long argument list</source>
<target state="new">Wrap long argument list</target>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册