﻿// 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 StarkPlatform. Compiler. Stark. Extensions. ContextQuery;
using StarkPlatform. Compiler. Stark. Utilities;

namespace StarkPlatform. Compiler. Stark. Completion. KeywordRecommenders
{
    internal class OverrideKeywordRecommender : AbstractSyntacticSingleKeywordRecommender
    {
        private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts. EqualityComparer)
        {
            SyntaxKind. ExternKeyword,
            SyntaxKind. InternalKeyword,
            SyntaxKind. PublicKeyword,
            SyntaxKind. ProtectedKeyword,
            SyntaxKind. UnsafeKeyword,
            SyntaxKind. SealedKeyword,
            SyntaxKind. AbstractKeyword,
        };

        public OverrideKeywordRecommender()
            : base(SyntaxKind. OverrideKeyword)
        {
        }

        protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
        {
            return context. IsMemberDeclarationContext(
                validModifiers: s_validMemberModifiers,
                validTypeDeclarations: SyntaxKindSet. ClassStructTypeDeclarations,
                canBePartial: false,
                cancellationToken: cancellationToken);
        }
    }
}
