Пример #1
0
        private void Format(ICommentUncommentService service, ITextSnapshot snapshot, IEnumerable <ITrackingSpan> changes, CancellationToken cancellationToken)
        {
            var document = snapshot.GetOpenDocumentInCurrentContextWithChanges();

            if (document == null)
            {
                return;
            }

            var textSpans   = changes.Select(s => s.GetSpan(snapshot)).Select(s => s.Span.ToTextSpan()).ToList();
            var newDocument = service.Format(document, textSpans, cancellationToken);

            newDocument.Project.Solution.Workspace.ApplyDocumentChanges(newDocument, cancellationToken);
        }
Пример #2
0
 public Task <Document> FormatAsync(Document document, ImmutableArray <TextSpan> changes, CancellationToken cancellationToken)
 => Task.FromResult(_commentUncommentService.Format(document, changes, cancellationToken));