1 write to Span
Microsoft.CodeAnalysis (1)
Text\TextChange.cs (1)
45this.Span = span;
209 references to Span
Microsoft.CodeAnalysis (18)
InternalUtilities\TextChangeRangeExtensions.cs (1)
104return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
Text\SourceText.cs (10)
658if (change.Span.End > this.Length) 662if (change.Span.Start < position) 667if (change.Span.End <= changeRanges.Last().Span.Start) 670where !c.Span.IsEmpty || c.NewText?.Length > 0 671orderby c.Span 682if (change.Span.Length == 0 && newTextLength == 0) 686if (change.Span.Start > position) 688var subText = this.GetSubText(new TextSpan(position, change.Span.Start - position)); 698position = change.Span.End; 700changeRanges.Add(new TextChangeRange(change.Span, newTextLength));
Text\TextChange.cs (7)
54return string.Format("{0}: {{ {1}, \"{2}\" }}", this.GetType().Name, Span, NewText); 65EqualityComparer<TextSpan>.Default.Equals(this.Span, other.Span) && 71return Hash.Combine(this.Span.GetHashCode(), this.NewText?.GetHashCode() ?? 0); 91return new TextChangeRange(change.Span, change.NewText.Length); 107return $"new TextChange(new TextSpan({Span.Start}, {Span.Length}), {newTextDisplay})";
Microsoft.CodeAnalysis.CodeStyle (16)
AbstractAggregatedFormattingResult.cs (1)
77: changes.Where(s => _formattingSpans.HasIntervalThatIntersectsWith(s.Span)).ToList();
AbstractFormattingResult.cs (3)
83var oldText = (change.Span == span) ? originalString : originalString.Substring(change.Span.Start - span.Start, change.Span.Length);
AbstractTriviaFormatter.cs (2)
698changes[index].Span); 721if (change.Span.Contains(insertionPoint) && IsNullOrWhitespace(change.NewText))
FormattingAnalyzerHelper.cs (8)
33if (change.NewText.Length > 0 && !change.Span.IsEmpty) 38var offset = change.Span.Length - change.NewText.Length; 41if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 43change = new TextChange(new TextSpan(change.Span.Start, offset), ""); 50if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 52change = new TextChange(new TextSpan(change.Span.Start + change.NewText.Length, offset), ""); 58if (change.NewText.Length == 0 && change.Span.IsEmpty) 65var location = Location.Create(tree, change.Span);
FormattingExtensions.cs (1)
257var span = textChange.Span;
TextChangeRangeExtensions.cs (1)
104return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
ParsedDocument.cs (1)
84textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
Microsoft.CodeAnalysis.CSharp.EditorFeatures (2)
RawStringLiteral\RawStringLiteralCommandHandler_TypeChar.cs (1)
69edit.Insert(textChange.Span.Start, textChange.NewText);
StringCopyPaste\StringCopyPasteCommandHandler.cs (1)
191edit.Replace(change.Span.ToSpan(), change.NewText);
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (3)
Completion\CompletionProviders\OverrideCompletionProviderTests.cs (1)
3093Assert.Equal(change.Span, TextSpan.FromBounds(136, 145));
Formatting\Indentation\SmartTokenFormatterFormatRangeTests.cs (1)
3458edit.Replace(change.Span.ToSpan(), change.NewText);
Intents\IntentTestsBase.cs (1)
79edit.Replace(change.Span.ToSpan(), change.NewText);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (14)
Syntax\SyntaxDiffingTests.cs (14)
33Assert.Equal(new TextSpan(0, 0), changes[0].Span); 53Assert.Equal(new TextSpan(6, 1), changes[0].Span); 75Assert.Equal(new TextSpan(6, 1), changes[0].Span); 77Assert.Equal(new TextSpan(18, 1), changes[1].Span); 95Assert.Equal(new TextSpan(0, 0), changes[0].Span); 113Assert.Equal(new TextSpan(0, 0), changes[0].Span); 132Assert.Equal(new TextSpan(11, 0), changes[0].Span); 152Assert.Equal(new TextSpan(10, 0), changes[0].Span); 170Assert.Equal(new TextSpan(0, 0), changes[0].Span); 188Assert.Equal(new TextSpan(10, 0), changes[0].Span); 205Assert.Equal(new TextSpan(10, 7), changes[0].Span); 222Assert.Equal(new TextSpan(24, 7), changes[0].Span); 239Assert.Equal(new TextSpan(14, 1), changes[0].Span); 257Assert.Equal(new TextSpan(14, 5), changes[0].Span);
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
Formatting\CSharpSyntaxFormattingService.cs (1)
141return tokenEdits.Where(t => t.Span.Start >= token.FullSpan.Start).ToImmutableArray();
Microsoft.CodeAnalysis.EditorFeatures (13)
AutomaticCompletion\BraceCompletionSessionProvider.BraceCompletionSession.cs (1)
426edit.Replace(change.Span.ToSpan(), change.NewText);
InlineHints\InlineHintDataTag.cs (2)
64!_provider.SpanEquals(_snapshot, this.Hint.ReplacementTextChange.Value.Span, other._snapshot, other.Hint.ReplacementTextChange.Value.Span))
InlineRename\InlineRenameSession.OpenTextBufferManager.cs (4)
345edit.Replace(change.Span.Start, change.Span.Length, change.NewText); 568if (textChanges.Count != 1 || textChanges[0].Span != new TextSpan(0, oldText.Length)) 620buffer.Replace(change.Span.ToSpan(), change.NewText);
IntelliSense\AsyncCompletion\CommitManager.cs (1)
234var triggerSnapshotSpan = new SnapshotSpan(triggerSnapshot, textChange.Span.ToSpan());
Interactive\InteractiveWorkspace.cs (2)
67edit.Replace(change.Span.Start, change.Span.Length, change.NewText);
Remote\SolutionChecksumUpdater.cs (1)
209if (textChanges.Count == 1 && textChanges[0].Span.Length == oldText.Length)
Shared\Extensions\ITextBufferExtensions.cs (2)
73edit.Replace(change.Span.ToSpan(), change.NewText); 87edit.Replace(change.Span.ToSpan(), change.NewText);
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (4)
Completion\AbstractCompletionProviderTests.cs (1)
605textChange = new TextChange(textChange.Span, textChange.NewText.TrimEnd(commitChar) + commitChar);
Formatting\CoreFormatterTestsBase.cs (1)
169edit.Replace(change.Span.ToSpan(), change.NewText);
Workspaces\TestHostDocument.cs (2)
333edit.Replace(change.Span.Start, change.Span.Length, change.NewText);
Microsoft.CodeAnalysis.EditorFeatures.Text (1)
Extensions.SnapshotSourceText.cs (1)
215edit.Replace(change.Span.ToSpan(), change.NewText);
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (1)
CommentSelection\CommentUncommentSelectionCommandHandlerTests.cs (1)
764edits.TextChanges.Do(tc => edit.Replace(tc.Span.ToSpan(), tc.NewText));
Microsoft.CodeAnalysis.EditorFeatures.Wpf (1)
InlineHints\InlineHintsTag.cs (1)
288textChange.Span.ToSnapshotSpan(snapshot).TranslateTo(subjectBuffer.CurrentSnapshot, SpanTrackingMode.EdgeExclusive),
Microsoft.CodeAnalysis.ExternalAccess.Razor (1)
RazorSpanMappingServiceWrapper.cs (1)
41var mappedSpanResults = await MapSpansAsync(oldDocument, textChanges.Select(tc => tc.Span), cancellationToken).ConfigureAwait(false);
Microsoft.CodeAnalysis.Features (29)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaBatchFixHelpers.cs (5)
107var orderedChanges = startTokenChanges.Concat(endTokenChanges).OrderBy(change => change.Span).Distinct(); 133static bool IsPriorSpan(TextSpan span, TextChange textChange) => span.End <= textChange.Span.Start; 134static bool IsFollowingSpan(TextSpan span, TextChange textChange) => span.Start >= textChange.Span.End; 135static bool IsEnclosingSpan(TextSpan span, TextChange textChange) => span.Contains(textChange.Span); 155var delta = textChange.NewText.Length - textChange.Span.Length;
CodeRefactorings\AddMissingImports\AbstractAddMissingImportsFeatureService.cs (3)
127var orderedTextInserts = allTextChanges.Where(change => change.Span.IsEmpty) 133.GroupBy(change => change.Span) 183Debug.Assert(textChanges.Last().Span.IntersectsWith(insertSpan.End));
Completion\Providers\Snippets\AbstractSnippetCompletionProvider.cs (2)
54if (change.Span.Start > item.Span.Start) 56var textSpan = TextSpan.FromBounds(item.Span.Start, change.Span.End);
Completion\Utilities.cs (3)
31var totalOldSpan = TextSpan.FromBounds(changes.First().Span.Start, changes.Last().Span.End); 39var sumOfDeltas = changes.Sum(c => c.NewText!.Length - c.Span.Length);
EmbeddedLanguages\DateAndTime\DateAndTimeEmbeddedCompletionProvider.cs (2)
113properties.Add(StartKey, textChange.Span.Start.ToString()); 114properties.Add(LengthKey, textChange.Span.Length.ToString());
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexEmbeddedCompletionProvider.cs (2)
104properties.Add(StartKey, textChange.Span.Start.ToString()); 105properties.Add(LengthKey, textChange.Span.Length.ToString());
FormattingAnalyzerHelper.cs (8)
33if (change.NewText.Length > 0 && !change.Span.IsEmpty) 38var offset = change.Span.Length - change.NewText.Length; 41if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 43change = new TextChange(new TextSpan(change.Span.Start, offset), ""); 50if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 52change = new TextChange(new TextSpan(change.Span.Start + change.NewText.Length, offset), ""); 58if (change.NewText.Length == 0 && change.Span.IsEmpty) 65var location = Location.Create(tree, change.Span);
Snippets\RoslynLSPSnippetConverter.cs (4)
37var textChangeStart = textChange.Span.Start; 49for (var i = 0; i < textChange.Span.Length + 1;) 131var startPosition = textChange.Span.Start; 132var endPosition = textChange.Span.Start + textChangeText.Length;
Microsoft.CodeAnalysis.LanguageServer.Protocol (12)
Extensions\ProtocolConversions.cs (2)
216Range = TextSpanToRange(textChange.Span, oldText) 284var mappedResults = await GetMappedSpanResultAsync(oldDocument, textChanges.Select(tc => tc.Span).ToImmutableArray(), cancellationToken).ConfigureAwait(false);
Handler\Completion\CompletionHandler.cs (1)
112var defaultSpan = completionChange.TextChange.Span;
Handler\Completion\CompletionResolveHandler.cs (1)
146var completionChangeSpan = completionChange.TextChange.Span;
Handler\Completion\ILspCompletionResultCreationService.cs (1)
69var completionChangeSpan = completionChange.TextChange.Span;
Handler\InlineCompletions\InlineCompletionsHandler.cs (4)
143var snippetEndPosition = textChange.Span.Start + textChange.NewText!.Length; 148var spanToFormat = TextSpan.FromBounds(textChange.Span.Start, snippetEndPosition); 192var textChangesBefore = textChanges.Where(t => t.Span.End <= originalSpan.Start); 193var amountToAdjust = textChangesBefore.Sum(t => t.NewText!.Length - t.Span.Length);
Handler\OnAutoInsert\OnAutoInsertHandler.cs (3)
191Range = ProtocolConversions.TextSpanToRange(textChange.Span, sourceText) 222Debug.Assert(desiredCaretLocation >= textChange.Span.Start); 223var offsetInTextChange = desiredCaretLocation - textChange.Span.Start;
Microsoft.CodeAnalysis.UnitTests (18)
Text\TextChangeTests.cs (18)
250Assert.Equal(expected.Span, actual.Span); 663Assert.Equal(new TextSpan(6, 0), changes[0].Span); 719Assert.Equal(new TextSpan(2, 8), changes[0].Span); 733Assert.Equal(new TextSpan(4, 2), changes[0].Span); 747Assert.Equal(new TextSpan(6, 1), changes[0].Span); 853Assert.Equal(new TextSpan(4, 0), changes[0].Span); 867Assert.Equal(new TextSpan(4, 0), changes[0].Span); 869Assert.Equal(new TextSpan(5, 0), changes[1].Span); 883Assert.Equal(new TextSpan(4, 0), changes[0].Span); 885Assert.Equal(new TextSpan(8, 0), changes[1].Span); 900Assert.Equal(new TextSpan(4, 0), changes[0].Span); 918Assert.Equal(new TextSpan(4, 0), changes[0].Span); 980i = newChange.Span.End; 982editedLength = editedLength - newChange.Span.Length + newChange.NewText.Length; 1000i = newChange.Span.End; 1251Assert.True(position <= change.Span.Start); 1252position = change.Span.End;
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures.UnitTests (2)
Formatting\Indentation\SmartTokenFormatter_FormatTokenTests.vb (1)
210edit.Replace(change.Span.ToSpan(), change.NewText)
Formatting\VisualBasicFormatterTestBase.vb (1)
79edit.Replace(change.Span.ToSpan(), change.NewText)
Microsoft.CodeAnalysis.Workspaces (54)
AbstractAggregatedFormattingResult.cs (1)
77: changes.Where(s => _formattingSpans.HasIntervalThatIntersectsWith(s.Span)).ToList();
AbstractFormattingResult.cs (3)
83var oldText = (change.Span == span) ? originalString : originalString.Substring(change.Span.Start - span.Start, change.Span.Length);
AbstractTriviaFormatter.cs (2)
698changes[index].Span); 721if (change.Span.Contains(insertionPoint) && IsNullOrWhitespace(change.NewText))
CodeFixes\FixAllOccurrences\TextChangeMerger.cs (10)
23int IIntervalIntrospector<TextChange>.GetStart(TextChange value) => value.Span.Start; 24int IIntervalIntrospector<TextChange>.GetLength(TextChange value) => value.Span.Length; 72var changesToApply = _totalChangesIntervalTree.Distinct().OrderBy(tc => tc.Span.Start); 105change.Span.Start, change.Span.Length, ref overlappingSpans); 108change.Span.Start, change.Span.Length, ref intersectingSpans); 148=> change.Span.IsEmpty; 190otherChange.Span.End == change.Span.Start;
FormattingExtensions.cs (1)
257var span = textChange.Span;
LinkedFileDiffMerging\AbstractLinkedFileMergeConflictCommentAdditionService.cs (7)
40var currentPartitionEndLine = originalSourceText.Lines.GetLineFromPosition(changes.First().Span.End); 45var changeStartLine = originalSourceText.Lines.GetLineFromPosition(change.Span.Start); 53currentPartitionEndLine = originalSourceText.Lines.GetLineFromPosition(change.Span.End); 70var startPosition = changePartition.First().Span.Start; 71var endPosition = changePartition.Last().Span.End; 77var adjustedChanges = changePartition.Select(c => new TextChange(TextSpan.FromBounds(c.Span.Start - startLineStartPosition, c.Span.End - startLineStartPosition), c.NewText));
LinkedFileDiffMerging\LinkedFileDiffMergingSession.cs (27)
148while (cumulativeChangeIndex < cumulativeChanges.Count && cumulativeChanges[cumulativeChangeIndex].Span.End < change.Span.Start) 160if (!cumulativeChange.Span.IntersectsWith(change.Span)) 169if (change.Span != cumulativeChange.Span || change.NewText != cumulativeChange.NewText) 176if (change.Span == cumulativeChange.Span) 240while (commentChangeIndex < commentChangesList.Count && commentChangesList[commentChangeIndex].Span.End <= mergedChange.Span.Start) 244mergeConflictResolutionSpans.Add(new TextSpan(commentChangesList[commentChangeIndex].Span.Start + currentPositionDelta, commentChangesList[commentChangeIndex].NewText.Length)); 245currentPositionDelta += (commentChangesList[commentChangeIndex].NewText.Length - commentChangesList[commentChangeIndex].Span.Length); 249if (commentChangeIndex >= commentChangesList.Count || mergedChange.Span.End <= commentChangesList[commentChangeIndex].Span.Start) 253currentPositionDelta += (mergedChange.NewText.Length - mergedChange.Span.Length); 258var conflictingCommentInsertionLocation = new TextSpan(mergedChange.Span.Start, 0); 259while (commentChangeIndex < commentChangesList.Count && commentChangesList[commentChangeIndex].Span.Start < mergedChange.Span.End) 262mergeConflictResolutionSpans.Add(new TextSpan(commentChangesList[commentChangeIndex].Span.Start + currentPositionDelta, commentChangesList[commentChangeIndex].NewText.Length)); 270currentPositionDelta += (mergedChange.NewText.Length - mergedChange.Span.Length); 277mergeConflictResolutionSpans.Add(new TextSpan(commentChangesList[commentChangeIndex].Span.Start + currentPositionDelta, commentChangesList[commentChangeIndex].NewText.Length)); 279currentPositionDelta += (commentChangesList[commentChangeIndex].NewText.Length - commentChangesList[commentChangeIndex].Span.Length); 296changes = changes.OrderBy(c => c.Span.Start); 302if (nextChange.Span.Start == currentChange.Span.End) 304currentChange = new TextChange(TextSpan.FromBounds(currentChange.Span.Start, nextChange.Span.End), currentChange.NewText + nextChange.NewText);
ParsedDocument.cs (1)
84textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
TextChangeRangeExtensions.cs (1)
104return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
Workspace\Solution\Document.cs (1)
396if (textChanges.Count > 1 || (textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldText.Length)))
Microsoft.VisualStudio.LanguageServices (15)
ProjectSystem\TextEditApplication.cs (2)
42edit.Replace(change.Span.Start, change.Span.Length, change.NewText);
Venus\ContainedDocument.cs (11)
290if (change.Span.End < visibleSpan.Start) 296if (visibleSpan.End < change.Span.Start) 308if (visibleSpan.Contains(change.Span)) 338if (change.Span.End <= visibleTextSpan.Start) 343if (visibleTextSpan.End <= change.Span.Start) 355var leftText = originalText.ToString(changeInOriginalText.Span); 357var offsetInOriginalText = changeInOriginalText.Span.Start; 737visibleSpansInOriginal[currentVisibleSpanIndex].End < change.Span.Start) 749var span = change.Span.ToSpan(); 819var newChanges = FilterTextChanges(document.GetTextSynchronously(CancellationToken.None), visibleSpans, changes.ToReadOnlyCollection()).Where(t => visibleSpan.Contains(t.Span)); 823edit.Replace(change.Span.ToSpan(), change.NewText);
Venus\ContainedDocument.DocumentServiceProvider.cs (1)
79var mappedSpanResults = await MapSpansAsync(oldDocument, textChanges.Select(tc => tc.Span), CancellationToken.None).ConfigureAwait(false);
Workspace\VisualStudioFormattingRuleFactoryServiceFactory.cs (1)
114return changes.Where(c => span.IntersectsWith(c.Span));
Microsoft.VisualStudio.LanguageServices.LiveShare (2)
Client\RemoteLanguageServiceWorkspace.cs (2)
536edit.Replace(change.Span.Start, change.Span.Length, change.NewText);
Microsoft.VisualStudio.LanguageServices.Xaml (1)
Implementation\LanguageServer\Handler\OnAutoInsert\OnAutoInsertHandler.cs (1)
71Range = ProtocolConversions.TextSpanToRange(result.TextChange.Span, text)