Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EnumKeywordRecommender.cs')
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EnumKeywordRecommender.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EnumKeywordRecommender.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EnumKeywordRecommender.cs
new file mode 100644
index 0000000000..69d31fad97
--- /dev/null
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/KeywordRecommender/EnumKeywordRecommender.cs
@@ -0,0 +1,37 @@
+// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System.Collections.Generic;
+using System.Threading;
+using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery;
+using Microsoft.CodeAnalysis.CSharp.Utilities;
+using Microsoft.CodeAnalysis.CSharp;
+
+namespace ICSharpCode.NRefactory6.CSharp.Completion.KeywordRecommenders
+{
+ internal class EnumKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
+ {
+ private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
+ {
+ SyntaxKind.InternalKeyword,
+ SyntaxKind.PublicKeyword,
+ SyntaxKind.PrivateKeyword,
+ SyntaxKind.ProtectedKeyword,
+ };
+
+ public EnumKeywordRecommender()
+ : base(SyntaxKind.EnumKeyword)
+ {
+ }
+
+ protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
+ {
+ return
+ context.IsGlobalStatementContext ||
+ context.IsTypeDeclarationContext(
+ validModifiers: s_validModifiers,
+ validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
+ canBePartial: false,
+ cancellationToken: cancellationToken);
+ }
+ }
+}