1 write to Span
Microsoft.CodeAnalysis (1)
Text\TextChange.cs (1)
46
this.
Span
= span;
207 references to Span
Microsoft.AspNetCore.App.Analyzers (4)
RouteEmbeddedLanguage\FrameworkParametersCompletionProvider.cs (2)
259
properties.Add(StartKey, textChange.
Span
.Start.ToString(CultureInfo.InvariantCulture));
260
properties.Add(LengthKey, textChange.
Span
.Length.ToString(CultureInfo.InvariantCulture));
RouteEmbeddedLanguage\RoutePatternCompletionProvider.cs (2)
138
properties.Add(StartKey, textChange.
Span
.Start.ToString(CultureInfo.InvariantCulture));
139
properties.Add(LengthKey, textChange.
Span
.Length.ToString(CultureInfo.InvariantCulture));
Microsoft.AspNetCore.App.Analyzers.Test (13)
RouteEmbeddedLanguage\FrameworkParametersCompletionProviderTests.cs (10)
39
Assert.Equal(result.CompletionListSpan, change.TextChange.
Span
);
67
Assert.Equal(result.CompletionListSpan, change.TextChange.
Span
);
95
Assert.Equal(result.CompletionListSpan, change.TextChange.
Span
);
123
Assert.Equal(result.CompletionListSpan, change.TextChange.
Span
);
153
Assert.Equal(result.CompletionListSpan, change.TextChange.
Span
);
181
Assert.Equal(result.CompletionListSpan, change.TextChange.
Span
);
209
Assert.Equal(result.CompletionListSpan, change.TextChange.
Span
);
237
Assert.Equal(result.CompletionListSpan, change.TextChange.
Span
);
265
Assert.Equal(result.CompletionListSpan, change.TextChange.
Span
);
999
Assert.Equal(result.CompletionListSpan, change.TextChange.
Span
);
RouteEmbeddedLanguage\RoutePatternCompletionProviderTests.cs (3)
124
Assert.Equal(result.CompletionListSpan, change.TextChange.
Span
);
153
Assert.Equal(result.CompletionListSpan, change.TextChange.
Span
);
182
Assert.Equal(result.CompletionListSpan, change.TextChange.
Span
);
Microsoft.CodeAnalysis (18)
Text\SourceText.cs (10)
768
if (change.
Span
.End > this.Length)
772
if (change.
Span
.Start < position)
777
if (change.
Span
.End <= changeRanges.Last().Span.Start)
780
where !c.
Span
.IsEmpty || c.NewText?.Length > 0
781
orderby c.
Span
792
if (change.
Span
.Length == 0 && newTextLength == 0)
796
if (change.
Span
.Start > position)
798
var subText = this.GetSubText(new TextSpan(position, change.
Span
.Start - position));
808
position = change.
Span
.End;
810
changeRanges.Add(new TextChangeRange(change.
Span
, newTextLength));
Text\TextChange.cs (7)
55
return string.Format("{0}: {{ {1}, \"{2}\" }}", this.GetType().Name,
Span
, NewText);
66
EqualityComparer<TextSpan>.Default.Equals(this.
Span
, other.
Span
) &&
72
return Hash.Combine(this.
Span
.GetHashCode(), this.NewText?.GetHashCode() ?? 0);
92
return new TextChangeRange(change.
Span
, change.NewText.Length);
108
return $"new TextChange(new TextSpan({
Span
.Start}, {
Span
.Length}), {newTextDisplay})";
Text\TextChangeRangeExtensions.cs (1)
105
return new TextChangeRange(textChange.
Span
, textChange.NewText?.Length ?? 0);
Microsoft.CodeAnalysis.CodeStyle (16)
src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (8)
65
if (change.NewText.Length > 0 && !change.
Span
.IsEmpty)
70
var offset = change.
Span
.Length - change.NewText.Length;
73
if (oldText.GetSubText(new TextSpan(change.
Span
.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
75
change = new TextChange(new TextSpan(change.
Span
.Start, offset), "");
82
if (oldText.GetSubText(new TextSpan(change.
Span
.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
84
change = new TextChange(new TextSpan(change.
Span
.Start + change.NewText.Length, offset), "");
91
if (change.NewText.Length == 0 && change.
Span
.IsEmpty)
98
var location = Location.Create(tree, change.
Span
);
src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (1)
105
return new TextChangeRange(textChange.
Span
, textChange.NewText?.Length ?? 0);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractAggregatedFormattingResult.cs (1)
76
: changes.Where(s => _formattingSpans.HasIntervalThatIntersectsWith(s.
Span
)).ToList();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractFormattingResult.cs (3)
83
var oldText = (change.
Span
== span) ? originalString : originalString.Substring(change.
Span
.Start - span.Start, change.
Span
.Length);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (1)
239
var span = textChange.
Span
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (2)
697
changes[index].
Span
);
720
if (change.
Span
.Contains(insertionPoint) && IsNullOrWhitespace(change.NewText))
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (1)
79
textChanges.Count == 1 && textChanges[0].
Span
!= new TextSpan(0, oldDocument.Text.Length))
Microsoft.CodeAnalysis.CSharp.EditorFeatures (2)
RawStringLiteral\RawStringLiteralCommandHandler_TypeChar.cs (1)
69
edit.Insert(textChange.
Span
.Start, textChange.NewText);
StringCopyPaste\StringCopyPasteCommandHandler.cs (1)
178
edit.Replace(change.
Span
.ToSpan(), change.NewText);
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (2)
Formatting\Indentation\SmartTokenFormatterFormatRangeTests.cs (1)
3460
edit.Replace(change.
Span
.ToSpan(), change.NewText);
Intents\IntentTestsBase.cs (1)
75
edit.Replace(change.
Span
.ToSpan(), change.NewText);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (14)
Syntax\SyntaxDiffingTests.cs (14)
33
Assert.Equal(new TextSpan(0, 0), changes[0].
Span
);
53
Assert.Equal(new TextSpan(6, 1), changes[0].
Span
);
75
Assert.Equal(new TextSpan(6, 1), changes[0].
Span
);
77
Assert.Equal(new TextSpan(18, 1), changes[1].
Span
);
95
Assert.Equal(new TextSpan(0, 0), changes[0].
Span
);
113
Assert.Equal(new TextSpan(0, 0), changes[0].
Span
);
132
Assert.Equal(new TextSpan(11, 0), changes[0].
Span
);
152
Assert.Equal(new TextSpan(10, 0), changes[0].
Span
);
170
Assert.Equal(new TextSpan(0, 0), changes[0].
Span
);
188
Assert.Equal(new TextSpan(10, 0), changes[0].
Span
);
205
Assert.Equal(new TextSpan(10, 7), changes[0].
Span
);
222
Assert.Equal(new TextSpan(24, 7), changes[0].
Span
);
239
Assert.Equal(new TextSpan(14, 1), changes[0].
Span
);
257
Assert.Equal(new TextSpan(14, 5), changes[0].
Span
);
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
Formatting\CSharpSyntaxFormattingService.cs (1)
118
return [.. tokenEdits.Where(t => t.
Span
.Start >= token.FullSpan.Start)];
Microsoft.CodeAnalysis.EditorFeatures (8)
AutomaticCompletion\BraceCompletionSessionProvider.BraceCompletionSession.cs (1)
456
edit.Replace(change.
Span
.ToSpan(), change.NewText);
Editor\TextEditApplication.cs (2)
42
edit.Replace(change.
Span
.Start, change.
Span
.Length, change.NewText);
IntelliSense\AsyncCompletion\CommitManager.cs (1)
251
var triggerSnapshotSpan = new SnapshotSpan(triggerSnapshot, textChange.
Span
.ToSpan());
Interactive\InteractiveWorkspace.cs (2)
51
edit.Replace(change.
Span
.Start, change.
Span
.Length, change.NewText);
Shared\Extensions\ITextBufferExtensions.cs (2)
73
edit.Replace(change.
Span
.ToSpan(), change.NewText);
87
edit.Replace(change.
Span
.ToSpan(), change.NewText);
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (4)
Completion\AbstractCompletionProviderTests.cs (1)
761
textChange = new TextChange(textChange.
Span
, textChange.NewText.TrimEnd(commitChar) + commitChar);
Formatting\CoreFormatterTestsBase.cs (1)
168
edit.Replace(change.
Span
.ToSpan(), change.NewText);
Workspaces\EditorTestHostDocument.cs (2)
226
edit.Replace(change.
Span
.Start, change.
Span
.Length, change.NewText);
Microsoft.CodeAnalysis.EditorFeatures.Text (1)
Extensions.SnapshotSourceText.cs (1)
213
edit.Replace(change.
Span
.ToSpan(), change.NewText);
Microsoft.CodeAnalysis.Features (28)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaBatchFixHelpers.cs (4)
132
static bool IsPriorSpan(TextSpan span, TextChange textChange) => span.End <= textChange.
Span
.Start;
133
static bool IsFollowingSpan(TextSpan span, TextChange textChange) => span.Start >= textChange.
Span
.End;
134
static bool IsEnclosingSpan(TextSpan span, TextChange textChange) => span.Contains(textChange.
Span
);
154
var delta = textChange.NewText.Length - textChange.
Span
.Length;
CodeRefactorings\AddMissingImports\AbstractAddMissingImportsFeatureService.cs (1)
169
Debug.Assert(textChanges.Last().
Span
.IntersectsWith(insertSpan.End));
Completion\Providers\Snippets\AbstractSnippetCompletionProvider.cs (2)
53
if (change.
Span
.Start > item.Span.Start)
55
var textSpan = TextSpan.FromBounds(item.Span.Start, change.
Span
.End);
Completion\Utilities.cs (3)
31
var totalOldSpan = TextSpan.FromBounds(changes.First().
Span
.Start, changes.Last().
Span
.End);
39
var sumOfDeltas = changes.Sum(c => c.NewText!.Length - c.
Span
.Length);
Copilot\ICopilotChangeAnalysisService.cs (3)
58
Contract.ThrowIfTrue(new NormalizedTextSpanCollection(changes.Select(c => c.
Span
)).Count != changes.Length, "'changes' was not normalized.");
107
newSpans.Add(new TextSpan(change.
Span
.Start + totalDelta, newTextLength));
108
totalDelta += newTextLength - change.
Span
.Length;
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexEmbeddedCompletionProvider.cs (3)
100
properties.Add(KeyValuePairUtil.Create(StartKey, textChange.
Span
.Start.ToString()));
101
properties.Add(KeyValuePairUtil.Create(LengthKey, textChange.
Span
.Length.ToString()));
119
isComplexTextEdit: context.CompletionListSpan != textChange.
Span
));
Snippets\RoslynLSPSnippetConverter.cs (4)
34
var textChangeStart = textChange.
Span
.Start;
46
for (var i = 0; i < textChange.
Span
.Length + 1;)
128
var startPosition = textChange.
Span
.Start;
129
var endPosition = textChange.
Span
.Start + textChangeText.Length;
src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (8)
65
if (change.NewText.Length > 0 && !change.
Span
.IsEmpty)
70
var offset = change.
Span
.Length - change.NewText.Length;
73
if (oldText.GetSubText(new TextSpan(change.
Span
.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
75
change = new TextChange(new TextSpan(change.
Span
.Start, offset), "");
82
if (oldText.GetSubText(new TextSpan(change.
Span
.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText)))
84
change = new TextChange(new TextSpan(change.
Span
.Start + change.NewText.Length, offset), "");
91
if (change.NewText.Length == 0 && change.
Span
.IsEmpty)
98
var location = Location.Create(tree, change.
Span
);
Microsoft.CodeAnalysis.LanguageServer.Protocol (13)
Extensions\ProtocolConversions.cs (2)
349
Range = TextSpanToRange(textChange.
Span
, oldText)
420
var mappedResults = await GetMappedSpanResultAsync(oldDocument, [.. textChanges.Select(tc => tc.
Span
)], cancellationToken).ConfigureAwait(false);
ExternalAccess\Razor\SimplifyMethodHandler.cs (1)
62
var node = newTree.FindNode(pendingChange.
Span
, findInTrivia: false, getInnermostNodeForTie: false, cancellationToken);
Handler\Completion\CompletionResultFactory.cs (4)
522
Debug.Assert(change.
Span
== defaultSpan);
523
PopulateTextEdit(lspItem, change.
Span
, change.NewText ?? string.Empty, documentText, itemDefaultsSupported, defaultSpan);
545
Range = ProtocolConversions.TextSpanToRange(change.
Span
, sourceText),
682
var completionChangeSpan = completionChange.TextChange.
Span
;
Handler\InlineCompletions\InlineCompletionsHandler.cs (4)
187
var snippetEndPosition = textChange.
Span
.Start + textChange.NewText!.Length;
192
var spanToFormat = TextSpan.FromBounds(textChange.
Span
.Start, snippetEndPosition);
236
var textChangesBefore = textChanges.Where(t => t.
Span
.End <= originalSpan.Start);
237
var amountToAdjust = textChangesBefore.Sum(t => t.NewText!.Length - t.
Span
.Length);
Handler\OnAutoInsert\OnAutoInsertHandler.cs (2)
234
Debug.Assert(desiredCaretLocation >= textChange.
Span
.Start);
235
var offsetInTextChange = desiredCaretLocation - textChange.
Span
.Start;
Microsoft.CodeAnalysis.UnitTests (18)
Text\TextChangeTests.cs (18)
250
Assert.Equal(expected.
Span
, actual.
Span
);
663
Assert.Equal(new TextSpan(6, 0), changes[0].
Span
);
719
Assert.Equal(new TextSpan(2, 8), changes[0].
Span
);
733
Assert.Equal(new TextSpan(4, 2), changes[0].
Span
);
747
Assert.Equal(new TextSpan(6, 1), changes[0].
Span
);
853
Assert.Equal(new TextSpan(4, 0), changes[0].
Span
);
867
Assert.Equal(new TextSpan(4, 0), changes[0].
Span
);
869
Assert.Equal(new TextSpan(5, 0), changes[1].
Span
);
883
Assert.Equal(new TextSpan(4, 0), changes[0].
Span
);
885
Assert.Equal(new TextSpan(8, 0), changes[1].
Span
);
900
Assert.Equal(new TextSpan(4, 0), changes[0].
Span
);
918
Assert.Equal(new TextSpan(4, 0), changes[0].
Span
);
980
i = newChange.
Span
.End;
982
editedLength = editedLength - newChange.
Span
.Length + newChange.NewText.Length;
1000
i = newChange.
Span
.End;
1251
Assert.True(position <= change.
Span
.Start);
1252
position = change.
Span
.End;
Microsoft.CodeAnalysis.Workspaces (52)
CodeFixes\FixAllOccurrences\TextChangeMerger.cs (9)
24
=> value.
Span
;
72
var changesToApply = _totalChangesIntervalTree.Distinct().OrderBy(tc => tc.
Span
.Start);
105
change.
Span
.Start, change.
Span
.Length, ref overlappingSpans);
108
change.
Span
.Start, change.
Span
.Length, ref intersectingSpans);
148
=> change.
Span
.IsEmpty;
190
otherChange.
Span
.End == change.
Span
.Start;
LinkedFileDiffMerging\AbstractLinkedFileMergeConflictCommentAdditionService.cs (7)
38
var currentPartitionEndLine = originalSourceText.Lines.GetLineFromPosition(changes.First().
Span
.End);
43
var changeStartLine = originalSourceText.Lines.GetLineFromPosition(change.
Span
.Start);
51
currentPartitionEndLine = originalSourceText.Lines.GetLineFromPosition(change.
Span
.End);
68
var startPosition = changePartition.First().
Span
.Start;
69
var endPosition = changePartition.Last().
Span
.End;
75
var adjustedChanges = changePartition.Select(c => new TextChange(TextSpan.FromBounds(c.
Span
.Start - startLineStartPosition, c.
Span
.End - startLineStartPosition), c.NewText!));
LinkedFileDiffMerging\LinkedFileDiffMergingSession.cs (26)
151
while (cumulativeChangeIndex < cumulativeChanges.Length && cumulativeChanges[cumulativeChangeIndex].
Span
.End < change.
Span
.Start)
161
if (!cumulativeChange.
Span
.IntersectsWith(change.
Span
))
168
if (change.
Span
!= cumulativeChange.
Span
|| change.NewText != cumulativeChange.NewText)
223
while (commentChangeIndex < commentChangesList.Length && commentChangesList[commentChangeIndex].
Span
.End <= mergedChange.
Span
.Start)
227
mergeConflictResolutionSpans.Add(new TextSpan(commentChangesList[commentChangeIndex].
Span
.Start + currentPositionDelta, commentChangesList[commentChangeIndex].NewText!.Length));
228
currentPositionDelta += commentChangesList[commentChangeIndex].NewText!.Length - commentChangesList[commentChangeIndex].
Span
.Length;
232
if (commentChangeIndex >= commentChangesList.Length || mergedChange.
Span
.End <= commentChangesList[commentChangeIndex].
Span
.Start)
236
currentPositionDelta += mergedChange.NewText!.Length - mergedChange.
Span
.Length;
241
var conflictingCommentInsertionLocation = new TextSpan(mergedChange.
Span
.Start, 0);
242
while (commentChangeIndex < commentChangesList.Length && commentChangesList[commentChangeIndex].
Span
.Start < mergedChange.
Span
.End)
245
mergeConflictResolutionSpans.Add(new TextSpan(commentChangesList[commentChangeIndex].
Span
.Start + currentPositionDelta, commentChangesList[commentChangeIndex].NewText!.Length));
253
currentPositionDelta += mergedChange.NewText!.Length - mergedChange.
Span
.Length;
260
mergeConflictResolutionSpans.Add(new TextSpan(commentChangesList[commentChangeIndex].
Span
.Start + currentPositionDelta, commentChangesList[commentChangeIndex].NewText!.Length));
262
currentPositionDelta += commentChangesList[commentChangeIndex].NewText!.Length - commentChangesList[commentChangeIndex].
Span
.Length;
274
var orderedChanges = changes.Sort(static (c1, c2) => c1.
Span
.Start - c2.
Span
.Start);
280
if (nextChange.
Span
.Start == currentChange.
Span
.End)
282
currentChange = new TextChange(TextSpan.FromBounds(currentChange.
Span
.Start, nextChange.
Span
.End), currentChange.NewText + nextChange.NewText);
src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (1)
105
return new TextChangeRange(textChange.
Span
, textChange.NewText?.Length ?? 0);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractAggregatedFormattingResult.cs (1)
76
: changes.Where(s => _formattingSpans.HasIntervalThatIntersectsWith(s.
Span
)).ToList();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractFormattingResult.cs (3)
83
var oldText = (change.
Span
== span) ? originalString : originalString.Substring(change.
Span
.Start - span.Start, change.
Span
.Length);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (1)
239
var span = textChange.
Span
;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (2)
697
changes[index].
Span
);
720
if (change.
Span
.Contains(insertionPoint) && IsNullOrWhitespace(change.NewText))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (1)
79
textChanges.Count == 1 && textChanges[0].
Span
!= new TextSpan(0, oldDocument.Text.Length))
Workspace\Solution\Document.cs (1)
486
if (textChanges.Length > 1 || (textChanges.Length == 1 && textChanges[0].
Span
!= new TextSpan(0, oldText.Length)))
Microsoft.VisualStudio.LanguageServices (10)
Venus\ContainedDocument.cs (8)
335
if (change.
Span
.End <= visibleTextSpan.Start)
340
if (visibleTextSpan.End <= change.
Span
.Start)
352
var leftText = originalText.ToString(changeInOriginalText.
Span
);
354
var offsetInOriginalText = changeInOriginalText.
Span
.Start;
734
visibleSpansInOriginal[currentVisibleSpanIndex].End < change.
Span
.Start)
746
var span = change.
Span
.ToSpan();
816
var newChanges = FilterTextChanges(document.GetTextSynchronously(CancellationToken.None), visibleSpans, changes.ToReadOnlyCollection()).Where(t => visibleSpan.Contains(t.
Span
));
820
edit.Replace(change.
Span
.ToSpan(), change.NewText);
Venus\ContainedDocument.DocumentServiceProvider.cs (1)
78
var mappedSpanResults = await MapSpansAsync(oldDocument, textChanges.Select(tc => tc.
Span
), CancellationToken.None).ConfigureAwait(false);
Workspace\VisualStudioFormattingRuleFactoryServiceFactory.cs (1)
108
return changes.Where(c => span.IntersectsWith(c.
Span
));
Microsoft.VisualStudio.LanguageServices.LiveShare (2)
Client\RemoteLanguageServiceWorkspace.cs (2)
514
edit.Replace(change.
Span
.Start, change.
Span
.Length, change.NewText);