Skip to content

Commit

Permalink
Merge pull request #25034 from Neme12/conversionOperatorReturnableCon…
Browse files Browse the repository at this point in the history
…struct

Minor bug fix: adding missing case for ConversionOperatorDeclaration in IsReturnableConstruct
  • Loading branch information
jinujoseph committed Mar 14, 2018
2 parents 4166a28 + 631255a commit 644e1e0
Show file tree
Hide file tree
Showing 2 changed files with 230 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal override IHighlighter CreateHighlighter()
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestExample1_1()
public async Task TestInLambda()
{
await TestAsync(
@"static double CalculateArea(double radius)
Expand All @@ -35,7 +35,7 @@ public async Task TestExample1_1()
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestExample1_2()
public async Task TestInLambda_NotOnReturnValue()
{
await TestAsync(
@"class C
Expand All @@ -58,7 +58,7 @@ static double CalculateArea(double radius)
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestExample1_3()
public async Task TestInLambda_OnSemicolon()
{
await TestAsync(
@"class C
Expand All @@ -81,7 +81,7 @@ static double CalculateArea(double radius)
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestExample1_4()
public async Task TestInLambda_SecondOccurence()
{
await TestAsync(
@"class C
Expand All @@ -104,7 +104,7 @@ static double CalculateArea(double radius)
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestExample1_5()
public async Task TestInLambda_SecondOccurence_NotOnReturnValue()
{
await TestAsync(
@"class C
Expand All @@ -127,7 +127,7 @@ static double CalculateArea(double radius)
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestExample1_6()
public async Task TestInLambda_SecondOccurence_OnSemicolon()
{
await TestAsync(
@"class C
Expand All @@ -150,7 +150,7 @@ static double CalculateArea(double radius)
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestExample1_7()
public async Task TestInMethodWithLambda()
{
await TestAsync(
@"class C
Expand All @@ -173,7 +173,7 @@ static double CalculateArea(double radius)
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestExample1_8()
public async Task TestInMethodWithLambda_NotOnReturnValue()
{
await TestAsync(
@"class C
Expand All @@ -196,7 +196,7 @@ static double CalculateArea(double radius)
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestExample1_9()
public async Task TestInMethodWithLambda_OnSemicolon()
{
await TestAsync(
@"class C
Expand All @@ -215,6 +215,226 @@ static double CalculateArea(double radius)
};
[|return|] calcArea(radius);{|Cursor:|}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestInConstructor()
{
await TestAsync(
@"class C
{
C()
{
{|Cursor:[|return|]|};
[|return|];
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestInDestructor()
{
await TestAsync(
@"class C
{
~C()
{
{|Cursor:[|return|]|};
[|return|];
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestInOperator()
{
await TestAsync(
@"class C
{
public static string operator +(C a)
{
{|Cursor:[|return|]|} null;
[|return|] null;
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestInConversionOperator()
{
await TestAsync(
@"class C
{
public static explicit operator string(C a)
{
{|Cursor:[|return|]|} null;
[|return|] null;
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestInGetter()
{
await TestAsync(
@"class C
{
int P
{
get
{
{|Cursor:[|return|]|} 0;
[|return|] 0;
}
set
{
return;
return;
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestInSetter()
{
await TestAsync(
@"class C
{
int P
{
get
{
return 0;
return 0;
}
set
{
{|Cursor:[|return|]|};
[|return|];
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestInAdder()
{
await TestAsync(
@"class C
{
event EventHandler E
{
add
{
{|Cursor:[|return|]|};
[|return|];
}
remove
{
return;
return;
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestInRemover()
{
await TestAsync(
@"class C
{
event EventHandler E
{
add
{
return;
return;
}
remove
{
{|Cursor:[|return|]|};
[|return|];
}
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestInLocalFunction()
{
await TestAsync(
@"class C
{
void M()
{
void F()
{
{|Cursor:[|return|]|};
[|return|];
}
return;
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestInSimpleLambda()
{
await TestAsync(
@"class C
{
void M()
{
Action<string> f = s =>
{
{|Cursor:[|return|]|};
[|return|];
};
return;
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestInParenthesizedLambda()
{
await TestAsync(
@"class C
{
void M()
{
Action<string> f = (s) =>
{
{|Cursor:[|return|]|};
[|return|];
};
return;
}
}");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordHighlighting)]
public async Task TestInAnonymousMethod()
{
await TestAsync(
@"class C
{
void M()
{
Action<string> f = delegate
{
{|Cursor:[|return|]|};
[|return|];
};
return;
}
}");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public static bool IsReturnableConstruct(this SyntaxNode node)
case SyntaxKind.GetAccessorDeclaration:
case SyntaxKind.SetAccessorDeclaration:
case SyntaxKind.OperatorDeclaration:
case SyntaxKind.ConversionOperatorDeclaration:
case SyntaxKind.AddAccessorDeclaration:
case SyntaxKind.RemoveAccessorDeclaration:
return true;
Expand Down

0 comments on commit 644e1e0

Please sign in to comment.