Skip to content

Commit

Permalink
Add more test scenarios for symbol completion after scoped (#65747)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi authored Jan 2, 2025
2 parents 9c189e7 + cb13605 commit 1c74b2e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.

Expand Down Expand Up @@ -13398,15 +13398,16 @@ class C
await VerifyAnyItemExistsAsync(source);
}

[Fact]
public async Task AfterScopedInsideMethod()
[Theory, CombinatorialData]
public async Task AfterScopedInsideMethod(bool useRef)
{
var source = """
var refKeyword = useRef ? "ref " : "";
var source = $$"""
class C
{
void M()
{
scoped $$
scoped {{refKeyword}}$$
}
}
Expand All @@ -13415,24 +13416,54 @@ ref struct MyRefStruct { }
await VerifyItemExistsAsync(MakeMarkup(source), "MyRefStruct");
}

[Fact]
public async Task AfterScopedGlobalStatement_FollowedByType()
[Theory, CombinatorialData]
public async Task AfterScopedGlobalStatement_FollowedByRefStruct(bool useRef)
{
var source = """
scoped $$
var refKeyword = useRef ? "ref " : "";
var source = $$"""
scoped {{refKeyword}}$$
ref struct MyRefStruct { }
""";
await VerifyItemExistsAsync(MakeMarkup(source), "MyRefStruct");
}

[Fact]
public async Task AfterScopedGlobalStatement_NotFollowedByType()
[Theory, CombinatorialData]
public async Task AfterScopedGlobalStatement_FollowedByStruct(bool useRef)
{
var source = """
var refKeyword = useRef ? "ref " : "";
var source = $$"""
using System;
scoped {{refKeyword}}$$
struct S { }
""";
await VerifyItemExistsAsync(MakeMarkup(source), "ReadOnlySpan", displayTextSuffix: "<>");
}

[Theory, CombinatorialData]
public async Task AfterScopedGlobalStatement_FollowedByPartialStruct(bool useRef)
{
var refKeyword = useRef ? "ref " : "";
var source = $$"""
using System;
scoped {{refKeyword}}$$
partial struct S { }
""";
await VerifyItemExistsAsync(MakeMarkup(source), "ReadOnlySpan", displayTextSuffix: "<>");
}

[Theory, CombinatorialData]
public async Task AfterScopedGlobalStatement_NotFollowedByType(bool useRef)
{
var refKeyword = useRef ? "ref " : "";
var source = $"""
using System;
scoped $$
scoped {refKeyword}$$
""";

await VerifyItemExistsAsync(MakeMarkup(source), "ReadOnlySpan", displayTextSuffix: "<>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ token.Parent is ArgumentSyntax argument &&
}

// scoped v|
if (token.IsKind(SyntaxKind.ScopedKeyword) && token.Parent is IncompleteMemberSyntax)
if (token.IsKind(SyntaxKind.ScopedKeyword) && token.Parent is IncompleteMemberSyntax or ScopedTypeSyntax)
{
return true;
}
Expand Down

0 comments on commit 1c74b2e

Please sign in to comment.