コード例 #1
0
            private string GetSingleIdentation()
            {
                // Insert a newline after the open token of the list.  Then ask the
                // ISynchronousIndentationService where it thinks that the next line should be
                // indented.
                var openToken = _listSyntax.GetFirstToken();

                var newSourceText = OriginalSourceText.WithChanges(new TextChange(new TextSpan(openToken.Span.End, 0), NewLine));

                newSourceText = newSourceText.WithChanges(
                    new TextChange(TextSpan.FromBounds(openToken.Span.End + NewLine.Length, newSourceText.Length), ""));
                var newDocument = OriginalDocument.WithText(newSourceText);

                var originalLineNumber = newSourceText.Lines.GetLineFromPosition(openToken.Span.Start).LineNumber;
                var desiredIndentation = _indentationService.GetBlankLineIndentation(
                    newDocument, originalLineNumber + 1,
                    FormattingOptions.IndentStyle.Smart,
                    CancellationToken);

                var baseLine         = newSourceText.Lines.GetLineFromPosition(desiredIndentation.BasePosition);
                var baseOffsetInLine = desiredIndentation.BasePosition - baseLine.Start;

                var indent = baseOffsetInLine + desiredIndentation.Offset;

                var indentString = indent.CreateIndentationString(UseTabs, TabSize);

                return(indentString);
            }
コード例 #2
0
            protected override async Task <IEnumerable <CodeActionOperation> > ComputeOperationsAsync(
                CancellationToken cancellationToken)
            {
                var updatedDocument = await GetUpdatedDocumentAsync(cancellationToken).ConfigureAwait(false);

                var oldText = await OriginalDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);

                var newText = await updatedDocument.GetTextAsync(cancellationToken).ConfigureAwait(false);

                return(ImmutableArray.Create <CodeActionOperation>(
                           new InstallPackageAndAddImportOperation(
                               OriginalDocument.Id, oldText, newText, _installOperation)));
            }
コード例 #3
0
ファイル: PatchResult.cs プロジェクト: ikvm/ravendb
 public override void Dispose()
 {
     base.Dispose();
     OriginalDocument?.Dispose();
 }
コード例 #4
0
ファイル: PatchResult.cs プロジェクト: yitaom2/ravendb
 public void Dispose()
 {
     ModifiedDocument?.Dispose();
     OriginalDocument?.Dispose();
 }