Skip to content

Commit

Permalink
Merge pull request #70383 from jhinder/interface-completion-after-gen…
Browse files Browse the repository at this point in the history
…eric-type

Suggest interfaces after generic type name
  • Loading branch information
CyrusNajmabadi authored Oct 14, 2023
2 parents e637e05 + d029355 commit a6c2f67
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -322,5 +322,41 @@ async Task $$
await VerifyAnyItemExistsAsync(markup, hasSuggestionModeItem: true);
await VerifyItemExistsAsync(markup, "IGoo");
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/70382")]
public async Task TestAfterGenericType()
{
var markup = """
interface I<T>
{
I<T> M();
}
class C<T> : I<T>
{
I<T> $$
}
""";

await VerifyItemExistsAsync(markup, "I", displayTextSuffix: "<>");
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/70382")]
public async Task TestAfterNestedGenericType()
{
var markup = """
interface I<T>
{
I<T> M();
}
class C<T> : I<T>
{
I<I<T>> $$
}
""";

await VerifyItemExistsAsync(markup, "I", displayTextSuffix: "<>");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ protected override Task<ImmutableArray<SymbolAndSelectionInfo>> GetSymbolsAsync(
if (SyntaxFacts.GetContextualKeywordKind(targetToken.ValueText) == SyntaxKind.AsyncKeyword)
return SpecializedTasks.EmptyImmutableArray<SymbolAndSelectionInfo>();

var typeNode = targetToken.Parent as TypeSyntax;
var potentialTypeNode = targetToken.Parent;
if (targetToken.IsKind(SyntaxKind.GreaterThanToken) && potentialTypeNode is TypeArgumentListSyntax typeArgumentList)
potentialTypeNode = typeArgumentList.Parent;

var typeNode = potentialTypeNode as TypeSyntax;

while (typeNode != null)
{
Expand Down

0 comments on commit a6c2f67

Please sign in to comment.