コード例 #1
0
        public void LargeNumberOfSpans()
        {
            using (var workspace = CSharpWorkspaceFactory.CreateWorkspaceFromFile(@"class Program
{
    void M()
    {
        int z = 0;
        z = z + z + z + z + z + z + z + z + z + z +
            z + z + z + z + z + z + z + z + z + z +
            z + z + z + z + z + z + z + z + z + z +
            z + z + z + z + z + z + z + z + z + z +
            z + z + z + z + z + z + z + z + z + z +
            z + z + z + z + z + z + z + z + z + z +
            z + z + z + z + z + z + z + z + z + z +
            z + z + z + z + z + z + z + z + z + z +
            z + z + z + z + z + z + z + z + z + z +
            z + z + z + z + z + z + z + z + z + z;
    }
}"))
            {
                var tagProducer = new TestTagProducer(
                    (span, cancellationToken) =>
                {
                    return(new List <ITagSpan <TestTag> >()
                    {
                        new TagSpan <TestTag>(span, new TestTag())
                    });
                });
                var asyncListener = new TaggerOperationListener();

                var notificationService = workspace.GetService <IForegroundNotificationService>();

                var eventSource    = CreateEventSource();
                var taggerProvider = new TestTaggerProvider(
                    tagProducer,
                    eventSource,
                    workspace,
                    asyncListener,
                    notificationService);

                var document   = workspace.Documents.First();
                var textBuffer = document.TextBuffer;
                var snapshot   = textBuffer.CurrentSnapshot;
                var tagger     = taggerProvider.CreateTagger <TestTag>(textBuffer);

                using (IDisposable disposable = (IDisposable)tagger)
                {
                    var spans         = Enumerable.Range(0, 101).Select(i => new Span(i * 4, 1));
                    var snapshotSpans = new NormalizedSnapshotSpanCollection(snapshot, spans);

                    eventSource.SendUpdateEvent();

                    asyncListener.CreateWaitTask().PumpingWait();

                    var tags = tagger.GetTags(snapshotSpans);

                    Assert.Equal(1, tags.Count());
                }
            }
        }
コード例 #2
0
 public TestTaggerProvider(
     TestTagProducer tagProducer,
     ITaggerEventSource eventSource,
     Workspace workspace,
     IAsynchronousOperationListener asyncListener,
     IForegroundNotificationService notificationService,
     bool disableCancellation = false)
     : base(asyncListener, notificationService)
 {
     _tagProducer         = tagProducer;
     _eventSource         = eventSource;
     _workspace           = workspace;
     _disableCancellation = disableCancellation;
 }