async Task IVsTypeScriptTodoCommentService.ReportTodoCommentsAsync(
            Document document, ImmutableArray <TodoComment> todoComments, CancellationToken cancellationToken)
        {
            using var _ = ArrayBuilder <TodoCommentData> .GetInstance(out var converted);

            var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);

            await TodoComment.ConvertAsync(document, todoComments, converted, cancellationToken).ConfigureAwait(false);

            await ReportTodoCommentDataAsync(
                document.Id, converted.ToImmutable(), cancellationToken).ConfigureAwait(false);
        }
Exemplo n.º 2
0
        protected async Task TestAsync(string codeWithMarker)
        {
            using var workspace = CreateWorkspace(codeWithMarker);

            var hostDocument        = workspace.Documents.First();
            var initialTextSnapshot = hostDocument.GetTextBuffer().CurrentSnapshot;
            var documentId          = hostDocument.Id;

            var document     = workspace.CurrentSolution.GetDocument(documentId);
            var service      = document.GetLanguageService <ITodoCommentService>();
            var todoComments = await service.GetTodoCommentsAsync(
                document,
                TodoCommentDescriptor.Parse(
                    workspace.Options.GetOption(TodoCommentOptions.TokenList)
                    ),
                CancellationToken.None
                );

            using var _ = ArrayBuilder <TodoCommentData> .GetInstance(out var converted);

            await TodoComment.ConvertAsync(
                document,
                todoComments,
                converted,
                CancellationToken.None
                );

            var expectedLists = hostDocument.SelectedSpans;

            Assert.Equal(converted.Count, expectedLists.Count);

            var sourceText = await document.GetTextAsync();

            var tree = await document.GetSyntaxTreeAsync();

            for (var i = 0; i < converted.Count; i++)
            {
                var todo = converted[i];
                var span = expectedLists[i];

                var line = initialTextSnapshot.GetLineFromPosition(span.Start);
                var text = initialTextSnapshot.GetText(span.ToSpan());

                Assert.Equal(todo.MappedLine, line.LineNumber);
                Assert.Equal(todo.MappedColumn, span.Start - line.Start);
                Assert.Equal(todo.Message, text);
            }
        }