using System.Globalization;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Completion;

namespace RoslynPad.Roslyn.Completion
{
    public sealed class CompletionHelper
    {
        private readonly Microsoft.CodeAnalysis.Completion.CompletionHelper _inner;

        private CompletionHelper(Microsoft.CodeAnalysis.Completion.CompletionHelper inner) => _inner = inner;

        public static CompletionHelper GetHelper(Document document, CompletionService service) =>
            new(Microsoft.CodeAnalysis.Completion.CompletionHelper.GetHelper(document));

        public bool MatchesFilterText(CompletionItem item, string filterText) =>
            _inner.MatchesPattern(item.FilterText, filterText, CultureInfo.InvariantCulture);
    }
}
