Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable recommender for scoped keyword #70290

Merged
merged 4 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11994,5 +11994,22 @@ public class C() : Base($$)
Await state.AssertCompletionItemsContain("x", ":")
End Using
End Function

<WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/66305")>
Public Async Function TestScopedKeywordRecommender() As Task
Using state = TestStateFactory.CreateCSharpTestState(
<Document><![CDATA[
void M()
{
$$
}
]]>
</Document>,
languageVersion:=LanguageVersion.CSharp11)

state.SendInvokeCompletionList()
Await state.AssertCompletionItemsContain("scoped", "")
End Using
End Function
End Class
End Namespace
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public KeywordCompletionProvider()
new RestoreKeywordRecommender(),
new ReturnKeywordRecommender(),
new SByteKeywordRecommender(),
new ScopedKeywordRecommender(),
new SealedKeywordRecommender(),
new SelectKeywordRecommender(),
new SetKeywordRecommender(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,12 @@

using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.CSharp.Utilities;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace Microsoft.CodeAnalysis.CSharp.Completion.KeywordRecommenders
{
internal class ScopedKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
internal sealed class ScopedKeywordRecommender() : AbstractSyntacticSingleKeywordRecommender(SyntaxKind.ScopedKeyword)
{
public ScopedKeywordRecommender()
: base(SyntaxKind.ScopedKeyword)
{
}

protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
{
var syntaxTree = context.SyntaxTree;
Expand Down