1 write to Span
Microsoft.CodeAnalysis (1)
Text\TextChangeRange.cs (1)
43
this.
Span
= span;
183 references to Span
Microsoft.CodeAnalysis (78)
Syntax\SyntaxDiffer.cs (21)
68
return reducedChanges.Select(c => new TextChange(c.Range.
Span
, c.NewText!)).ToList();
111
int start = change.Range.
Span
.Start + delta;
115
delta += change.Range.NewLength - change.Range.
Span
.Length;
577
if (last.Range.
Span
.End == change.Range.
Span
.Start)
581
new TextChangeRange(new TextSpan(last.Range.
Span
.Start, last.Range.
Span
.Length + change.Range.
Span
.Length), last.Range.NewLength + change.Range.NewLength),
587
Debug.Assert(change.Range.
Span
.Start >= last.Range.
Span
.End);
598
if (last.Range.
Span
.End == textChangeRange.
Span
.Start)
604
new TextChangeRange(new TextSpan(last.Range.
Span
.Start, last.Range.
Span
.Length + textChangeRange.
Span
.Length), last.Range.NewLength + textChangeRange.NewLength),
610
Debug.Assert(textChangeRange.
Span
.Start >= last.Range.
Span
.End);
748
if (cr.Range.
Span
.Length > 0 && cr.Range.NewLength > 0)
763
new TextSpan(range.
Span
.Start + commonLeadingCount, range.
Span
.Length - (commonLeadingCount + commonTrailingCount)),
778
if (range.
Span
.Length > 0 || range.NewLength > 0)
Syntax\SyntaxTreeExtensions.cs (1)
31
var change = TextChangeRange.Collapse(changes).
Span
;
Text\ChangedText.cs (5)
38
deltaLength += change.NewLength - change.
Span
.Length;
46
if (change.
Span
.Start < position)
49
if (change.
Span
.Start > oldText.Length)
52
if (change.
Span
.End > oldText.Length)
55
position = change.
Span
.End;
Text\SourceText.cs (4)
777
if (change.Span.End <= changeRanges.Last().
Span
.Start)
908
var newPos = range.
Span
.Start + newPosDelta;
922
textChanges.Add(new TextChange(range.
Span
, newt));
924
newPosDelta += range.NewLength - range.
Span
.Length;
Text\TextChangeRange.cs (12)
28
internal int NewEnd =>
Span
.Start + NewLength;
53
other.
Span
== this.
Span
&&
71
return Hash.Combine(this.NewLength, this.
Span
.GetHashCode());
107
diff += change.NewLength - change.
Span
.Length;
109
if (change.
Span
.Start < start)
111
start = change.
Span
.Start;
114
if (change.
Span
.End > end)
116
end = change.
Span
.End;
134
return $"new TextChangeRange(new TextSpan({
Span
.Start}, {
Span
.Length}), {NewLength})";
139
return $"TextChangeRange(Span={
Span
}, NewLength={NewLength})";
Text\TextChangeRangeExtensions.cs (35)
38
var currentStart = accumulatedTextChangeSoFar.Value.
Span
.Start;
39
var currentOldEnd = accumulatedTextChangeSoFar.Value.
Span
.End;
40
var currentNewEnd = accumulatedTextChangeSoFar.Value.
Span
.Start + accumulatedTextChangeSoFar.Value.NewLength;
69
if (newChange.
Span
.Start < currentStart)
71
currentStart = newChange.
Span
.Start;
78
if (currentNewEnd > newChange.
Span
.End)
86
currentNewEnd = currentNewEnd + newChange.NewLength - newChange.
Span
.Length;
96
currentOldEnd = currentOldEnd + newChange.
Span
.End - currentNewEnd;
97
currentNewEnd = newChange.
Span
.Start + newChange.NewLength;
150
if (oldChange.
Span
.Length == 0 && oldChange.NewLength == 0)
162
else if (newChange.SpanEnd <= oldChange.
Span
.Start + oldDelta)
180
else if (newChange.SpanStart < oldChange.
Span
.Start + oldDelta)
199
var newChangeLeadingDeletion = oldChange.
Span
.Start + oldDelta - newChange.SpanStart;
201
newChange = new UnadjustedNewChange(oldChange.
Span
.Start + oldDelta, newChange.SpanLength - newChangeLeadingDeletion, newChange.NewLength);
204
else if (newChange.SpanStart > oldChange.
Span
.Start + oldDelta)
222
var oldChangeLeadingInsertion = newChange.SpanStart - (oldChange.
Span
.Start + oldDelta);
224
var oldChangeLeadingDeletion = Math.Min(oldChange.
Span
.Length, oldChangeLeadingInsertion);
225
addAndAdjustOldDelta(builder, ref oldDelta, new TextChangeRange(new TextSpan(oldChange.
Span
.Start, oldChangeLeadingDeletion), oldChangeLeadingInsertion));
226
oldChange = new TextChangeRange(new TextSpan(newChange.SpanStart - oldDelta, oldChange.
Span
.Length - oldChangeLeadingDeletion), oldChange.NewLength - oldChangeLeadingInsertion);
232
Debug.Assert(newChange.SpanStart == oldChange.
Span
.Start + oldDelta);
261
oldChange = new TextChangeRange(oldChange.
Span
, oldChange.NewLength - newChange.SpanLength);
308
oldDelta = oldDelta - oldChange.
Span
.Length + oldChange.NewLength;
310
var newDeletion = newChange.SpanLength + oldChange.
Span
.Length - oldChange.NewLength;
311
newChange = new UnadjustedNewChange(oldChange.
Span
.Start + oldDelta, newDeletion, newChange.NewLength);
373
oldDelta = oldDelta - oldChange.
Span
.Length + oldChange.NewLength;
388
if (last.
Span
.End == change.
Span
.Start)
391
builder[^1] = new TextChangeRange(new TextSpan(last.
Span
.Start, last.
Span
.Length + change.
Span
.Length), last.NewLength + change.NewLength);
394
else if (last.
Span
.End > change.
Span
.Start)
430
: this(range.
Span
.Start, range.
Span
.Length, range.NewLength)
435
private static int NewEnd(this TextChangeRange range) => range.
Span
.Start + range.NewLength;
Microsoft.CodeAnalysis.CodeStyle (36)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (1)
31
var change = TextChangeRange.Collapse(changes).
Span
;
src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (35)
38
var currentStart = accumulatedTextChangeSoFar.Value.
Span
.Start;
39
var currentOldEnd = accumulatedTextChangeSoFar.Value.
Span
.End;
40
var currentNewEnd = accumulatedTextChangeSoFar.Value.
Span
.Start + accumulatedTextChangeSoFar.Value.NewLength;
69
if (newChange.
Span
.Start < currentStart)
71
currentStart = newChange.
Span
.Start;
78
if (currentNewEnd > newChange.
Span
.End)
86
currentNewEnd = currentNewEnd + newChange.NewLength - newChange.
Span
.Length;
96
currentOldEnd = currentOldEnd + newChange.
Span
.End - currentNewEnd;
97
currentNewEnd = newChange.
Span
.Start + newChange.NewLength;
150
if (oldChange.
Span
.Length == 0 && oldChange.NewLength == 0)
162
else if (newChange.SpanEnd <= oldChange.
Span
.Start + oldDelta)
180
else if (newChange.SpanStart < oldChange.
Span
.Start + oldDelta)
199
var newChangeLeadingDeletion = oldChange.
Span
.Start + oldDelta - newChange.SpanStart;
201
newChange = new UnadjustedNewChange(oldChange.
Span
.Start + oldDelta, newChange.SpanLength - newChangeLeadingDeletion, newChange.NewLength);
204
else if (newChange.SpanStart > oldChange.
Span
.Start + oldDelta)
222
var oldChangeLeadingInsertion = newChange.SpanStart - (oldChange.
Span
.Start + oldDelta);
224
var oldChangeLeadingDeletion = Math.Min(oldChange.
Span
.Length, oldChangeLeadingInsertion);
225
addAndAdjustOldDelta(builder, ref oldDelta, new TextChangeRange(new TextSpan(oldChange.
Span
.Start, oldChangeLeadingDeletion), oldChangeLeadingInsertion));
226
oldChange = new TextChangeRange(new TextSpan(newChange.SpanStart - oldDelta, oldChange.
Span
.Length - oldChangeLeadingDeletion), oldChange.NewLength - oldChangeLeadingInsertion);
232
Debug.Assert(newChange.SpanStart == oldChange.
Span
.Start + oldDelta);
261
oldChange = new TextChangeRange(oldChange.
Span
, oldChange.NewLength - newChange.SpanLength);
308
oldDelta = oldDelta - oldChange.
Span
.Length + oldChange.NewLength;
310
var newDeletion = newChange.SpanLength + oldChange.
Span
.Length - oldChange.NewLength;
311
newChange = new UnadjustedNewChange(oldChange.
Span
.Start + oldDelta, newDeletion, newChange.NewLength);
373
oldDelta = oldDelta - oldChange.
Span
.Length + oldChange.NewLength;
388
if (last.
Span
.End == change.
Span
.Start)
391
builder[^1] = new TextChangeRange(new TextSpan(last.
Span
.Start, last.
Span
.Length + change.
Span
.Length), last.NewLength + change.NewLength);
394
else if (last.
Span
.End > change.
Span
.Start)
430
: this(range.
Span
.Start, range.
Span
.Length, range.NewLength)
435
private static int NewEnd(this TextChangeRange range) => range.
Span
.Start + range.NewLength;
Microsoft.CodeAnalysis.CSharp (7)
Parser\Blender.cs (3)
125
var start = Math.Max(Math.Min(changeRange.
Span
.Start, lastCharIndex), 0);
155
var finalSpan = TextSpan.FromBounds(start, changeRange.
Span
.End);
156
var finalLength = changeRange.NewLength + (changeRange.
Span
.Start - start);
Parser\Blender.Reader.cs (3)
129
while (!_changes.IsEmpty && oldPosition >= _changes.Peek().
Span
.End)
134
_changeDelta += change.NewLength - change.
Span
.Length;
285
var changeSpan = _changes.Peek().
Span
;
Syntax\CSharpSyntaxTree.cs (1)
564
if (workingChanges.Count == 1 && workingChanges[0].
Span
== new TextSpan(0, this.Length) && workingChanges[0].NewLength == newText.Length)
Microsoft.CodeAnalysis.EditorFeatures (2)
Classification\Semantic\AbstractSemanticOrEmbeddedClassificationViewTaggerProvider.cs (1)
174
var changedSpan = new TextSpan(collapsedRange.
Span
.Start, collapsedRange.NewLength);
Classification\Syntactic\SyntacticClassificationTaggerProvider.TagComputer.cs (1)
341
? currentSnapshot.GetSpan(changeRange.Value.
Span
.Start, changeRange.Value.NewLength)
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (1)
Classification\SyntacticChangeRangeComputerTests.vb (1)
41
Assert.True(expectedChange = actualChange, expectedChange.ToString() & " != " & actualChange.ToString() & vbCrLf & "Changed span was" & vbCrLf & startingText.ToString(actualChange.
Span
))
Microsoft.CodeAnalysis.Features (7)
SolutionCrawler\AbstractDocumentDifferenceService.cs (7)
112
var oldMember = syntaxFactsService.GetContainingMemberDeclaration(oldRoot, range.
Span
.Start);
113
var newMember = syntaxFactsService.GetContainingMemberDeclaration(newRoot, range.
Span
.Start);
122
if (!syntaxFactsService.ContainsInMemberBody(oldMember, range.
Span
))
153
var oldMember = syntaxFactsService.GetContainingMemberDeclaration(oldRoot, range.
Span
.Start);
154
var newMember = syntaxFactsService.GetContainingMemberDeclaration(newRoot, range.
Span
.Start);
169
if (!oldMember.Span.Contains(range.
Span
))
175
var lengthDelta = range.NewLength - range.
Span
.Length;
Microsoft.CodeAnalysis.UnitTests (3)
Text\TextChangeRangeTest.cs (1)
28
Assert.Equal(span, range.
Span
);
Text\TextChangeTests.cs (2)
78
Assert.Equal(6, changes[0].
Span
.Start);
79
Assert.Equal(0, changes[0].
Span
.Length);
Microsoft.CodeAnalysis.VisualBasic (12)
Scanner\Blender.vb (11)
209
Dim start = _change.
Span
.Start
210
Dim [end] = _change.
Span
.End
221
ExpandByLookAheadAndBehind(_baseTreeRoot, _change.
Span
))
222
_affectedRange = New TextChangeRange(span, span.Length - _change.
Span
.Length + _change.NewLength)
226
If position < _change.
Span
.Start Then
230
If position >= _change.
Span
.Start + _change.NewLength Then
231
Return position - _change.NewLength + _change.
Span
.Length
389
Dim range = New TextSpan(_affectedRange.
Span
.Start, _affectedRange.NewLength)
439
If _affectedRange.
Span
.Length = 0 Then
440
If _curNodeSpan.Contains(_affectedRange.
Span
.Start) Then
444
If _curNodeSpan.OverlapsWith(_affectedRange.
Span
) Then
Syntax\VisualBasicSyntaxTree.vb (1)
120
If changes.Length = 1 AndAlso changes(0).
Span
= New TextSpan(0, Me.Length) AndAlso changes(0).NewLength = newText.Length Then
Microsoft.CodeAnalysis.Workspaces (37)
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (1)
31
var change = TextChangeRange.Collapse(changes).
Span
;
src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (35)
38
var currentStart = accumulatedTextChangeSoFar.Value.
Span
.Start;
39
var currentOldEnd = accumulatedTextChangeSoFar.Value.
Span
.End;
40
var currentNewEnd = accumulatedTextChangeSoFar.Value.
Span
.Start + accumulatedTextChangeSoFar.Value.NewLength;
69
if (newChange.
Span
.Start < currentStart)
71
currentStart = newChange.
Span
.Start;
78
if (currentNewEnd > newChange.
Span
.End)
86
currentNewEnd = currentNewEnd + newChange.NewLength - newChange.
Span
.Length;
96
currentOldEnd = currentOldEnd + newChange.
Span
.End - currentNewEnd;
97
currentNewEnd = newChange.
Span
.Start + newChange.NewLength;
150
if (oldChange.
Span
.Length == 0 && oldChange.NewLength == 0)
162
else if (newChange.SpanEnd <= oldChange.
Span
.Start + oldDelta)
180
else if (newChange.SpanStart < oldChange.
Span
.Start + oldDelta)
199
var newChangeLeadingDeletion = oldChange.
Span
.Start + oldDelta - newChange.SpanStart;
201
newChange = new UnadjustedNewChange(oldChange.
Span
.Start + oldDelta, newChange.SpanLength - newChangeLeadingDeletion, newChange.NewLength);
204
else if (newChange.SpanStart > oldChange.
Span
.Start + oldDelta)
222
var oldChangeLeadingInsertion = newChange.SpanStart - (oldChange.
Span
.Start + oldDelta);
224
var oldChangeLeadingDeletion = Math.Min(oldChange.
Span
.Length, oldChangeLeadingInsertion);
225
addAndAdjustOldDelta(builder, ref oldDelta, new TextChangeRange(new TextSpan(oldChange.
Span
.Start, oldChangeLeadingDeletion), oldChangeLeadingInsertion));
226
oldChange = new TextChangeRange(new TextSpan(newChange.SpanStart - oldDelta, oldChange.
Span
.Length - oldChangeLeadingDeletion), oldChange.NewLength - oldChangeLeadingInsertion);
232
Debug.Assert(newChange.SpanStart == oldChange.
Span
.Start + oldDelta);
261
oldChange = new TextChangeRange(oldChange.
Span
, oldChange.NewLength - newChange.SpanLength);
308
oldDelta = oldDelta - oldChange.
Span
.Length + oldChange.NewLength;
310
var newDeletion = newChange.SpanLength + oldChange.
Span
.Length - oldChange.NewLength;
311
newChange = new UnadjustedNewChange(oldChange.
Span
.Start + oldDelta, newDeletion, newChange.NewLength);
373
oldDelta = oldDelta - oldChange.
Span
.Length + oldChange.NewLength;
388
if (last.
Span
.End == change.
Span
.Start)
391
builder[^1] = new TextChangeRange(new TextSpan(last.
Span
.Start, last.
Span
.Length + change.
Span
.Length), last.NewLength + change.NewLength);
394
else if (last.
Span
.End > change.
Span
.Start)
430
: this(range.
Span
.Start, range.
Span
.Length, range.NewLength)
435
private static int NewEnd(this TextChangeRange range) => range.
Span
.Start + range.NewLength;
Workspace\Solution\DocumentState.cs (1)
285
if (change.
Span
.Length < MaxTextChangeRangeLength && change.NewLength < MaxTextChangeRangeLength)