Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarTawfik committed Sep 29, 2017
1 parent 605886a commit 48f180d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 19 deletions.
6 changes: 1 addition & 5 deletions src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5895,11 +5895,6 @@ private ScanTypeFlags ScanNonArrayType(ParseTypeMode mode, out SyntaxToken lastT
this.EatToken();
}
}
else if (this.CurrentToken.Kind == SyntaxKind.InKeyword)
{
// Start of a lambda parameter
this.EatToken();
}

if (this.CurrentToken.Kind == SyntaxKind.IdentifierToken)
{
Expand Down Expand Up @@ -9815,6 +9810,7 @@ private bool ScanExplicitlyTypedLambda(Precedence precedence)
}
break;
case SyntaxKind.OutKeyword:
case SyntaxKind.InKeyword:
case SyntaxKind.ParamsKeyword:
this.EatToken();
foundParameterModifier = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,5 +422,14 @@ class Program
public $$ int Test { get; set; }
}");
}

[Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.ReadOnlyReferences)]
[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
public async Task TestNotAfterThis()
{
await VerifyAbsenceAsync(
@"static class C {
static void Goo(this $$");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ await VerifyAbsenceAsync(
void Goo(ref $$");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
public async Task TestNotAfterIn()
{
await VerifyAbsenceAsync(
@"class C {
void Goo(in $$");
}

[Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)]
public async Task TestNotAfterThis_InBogusMethod()
{
Expand Down Expand Up @@ -647,7 +655,22 @@ public static class Extensions
public static void Extension(ref $$ object obj, int x) { }
}");
}


[Fact]
public async Task TestExtensionMethods_FirstParameter_AfterInKeyword_InClass()
{
await VerifyKeywordAsync(@"
public static class Extensions
{
public static void Extension(in $$");

await VerifyKeywordAsync(@"
public static class Extensions
{
public static void Extension(in $$ object obj, int x) { }
}");
}

[Fact]
public async Task TestExtensionMethods_SecondParameter_AfterRefKeyword_InClass()
{
Expand All @@ -664,17 +687,17 @@ public static void Extension(int x, ref $$ object obj) { }
}

[Fact]
public async Task TestExtensionMethods_SecondParameter_AfterRefReadonlyKeywords_InClass()
public async Task TestExtensionMethods_SecondParameter_AfterInKeywords_InClass()
{
await VerifyAbsenceAsync(@"
public static class Extensions
{
public static void Extension(int x, ref readonly $$");
public static void Extension(int x, in $$");

await VerifyAbsenceAsync(@"
public static class Extensions
{
public static void Extension(int x, ref readonly $$ object obj) { }
public static void Extension(int x, in $$ object obj) { }
}");
}

Expand All @@ -687,11 +710,11 @@ public async Task TestExtensionMethods_FirstParameter_AfterRefKeyword_OutsideCla
}

[Fact]
public async Task TestExtensionMethods_FirstParameter_AfterRefReadOnlyKeywords_OutsideClass()
public async Task TestExtensionMethods_FirstParameter_AfterInKeywords_OutsideClass()
{
await VerifyAbsenceAsync("public static void Extension(ref readonly $$");
await VerifyAbsenceAsync("public static void Extension(in $$");

await VerifyAbsenceAsync("public static void Extension(ref readonly $$ object obj, int x) { }");
await VerifyAbsenceAsync("public static void Extension(in $$ object obj, int x) { }");
}

[Fact]
Expand All @@ -710,17 +733,17 @@ public static void Extension(ref $$ object obj, int x) { }
}

[Fact]
public async Task TestExtensionMethods_FirstParameter_AfterRefReadOnlyKeywords_NonStaticClass()
public async Task TestExtensionMethods_FirstParameter_AfterInKeywords_NonStaticClass()
{
await VerifyAbsenceAsync(@"
public class Extensions
{
public static void Extension(ref readonly $$");
public static void Extension(in $$");

await VerifyAbsenceAsync(@"
public class Extensions
{
public static void Extension(ref readonly $$ object obj, int x) { }
public static void Extension(in $$ object obj, int x) { }
}");
}

Expand All @@ -740,17 +763,17 @@ public void Extension(ref $$ object obj, int x) { }
}

[Fact]
public async Task TestExtensionMethods_FirstParameter_AfterRefReadOnlyKeywords_NonStaticMethod()
public async Task TestExtensionMethods_FirstParameter_AfterInKeywords_NonStaticMethod()
{
await VerifyAbsenceAsync(@"
public static class Extensions
{
public void Extension(ref readonly $$");
public void Extension(in $$");

await VerifyAbsenceAsync(@"
public static class Extensions
{
public void Extension(ref readonly $$ object obj, int x) { }
public void Extension(in $$ object obj, int x) { }
}");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ public static bool IsParameterModifierContext(
}

if (isThisKeyword &&
token.IsKind(SyntaxKind.RefKeyword) &&
(token.IsKind(SyntaxKind.RefKeyword) || token.IsKind(SyntaxKind.InKeyword)) &&
token.Parent.GetParent().IsDelegateOrConstructorOrLocalFunctionOrMethodParameterList())
{
var parameter = token.GetAncestor<ParameterSyntax>();
Expand Down

0 comments on commit 48f180d

Please sign in to comment.