IDocumentProvider.cs 1.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
// 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.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Text;

namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense
{
    internal interface IDocumentProvider
    {
13
        Document GetDocument(ITextSnapshot snapshot, CancellationToken cancellationToken);
14 15 16 17
    }

    internal class DocumentProvider : ForegroundThreadAffinitizedObject, IDocumentProvider
    {
18 19 20 21 22
        public DocumentProvider(IThreadingContext threadingContext)
            : base(threadingContext)
        {
        }

23
        public Document GetDocument(ITextSnapshot snapshot, CancellationToken cancellationToken)
24 25
        {
            AssertIsBackground();
26
            return snapshot.AsText().GetDocumentWithFrozenPartialSemantics(cancellationToken);
27 28 29
        }
    }
}