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