1 write to Span
Microsoft.CodeAnalysis (1)
Text\TextChange.cs (1)
46this.Span = span;
195 references to Span
dotnet-format (4)
Formatters\DocumentFormatter.cs (4)
172var changePosition = originalText.Lines.GetLinePosition(change.Span.Start); 188var isAdd = change.Span.Length == 0; 197? string.Format(Resources.Delete_0_characters, change.Span.Length) 200: string.Format(Resources.Replace_0_characters_with_1, change.Span.Length, textChange);
GenerateDocumentationAndConfigFiles (9)
src\roslyn\src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (1)
105return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractAggregatedFormattingResult.cs (1)
76: changes.Where(s => _formattingSpans.HasIntervalThatIntersectsWith(s.Span)).ToList();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractFormattingResult.cs (3)
83var oldText = (change.Span == span) ? originalString : originalString.Substring(change.Span.Start - span.Start, change.Span.Length);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (1)
239var span = textChange.Span;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (2)
697changes[index].Span); 720if (change.Span.Contains(insertionPoint) && IsNullOrWhitespace(change.NewText))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (1)
79textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
Microsoft.AspNetCore.App.Analyzers (4)
RouteEmbeddedLanguage\FrameworkParametersCompletionProvider.cs (2)
259properties.Add(StartKey, textChange.Span.Start.ToString(CultureInfo.InvariantCulture)); 260properties.Add(LengthKey, textChange.Span.Length.ToString(CultureInfo.InvariantCulture));
RouteEmbeddedLanguage\RoutePatternCompletionProvider.cs (2)
138properties.Add(StartKey, textChange.Span.Start.ToString(CultureInfo.InvariantCulture)); 139properties.Add(LengthKey, textChange.Span.Length.ToString(CultureInfo.InvariantCulture));
Microsoft.CodeAnalysis (18)
Text\SourceText.cs (10)
787if (change.Span.End > this.Length) 791if (change.Span.Start < position) 796if (change.Span.End <= changeRanges.Last().Span.Start) 799where !c.Span.IsEmpty || c.NewText?.Length > 0 800orderby c.Span 811if (change.Span.Length == 0 && newTextLength == 0) 815if (change.Span.Start > position) 817var subText = this.GetSubText(new TextSpan(position, change.Span.Start - position)); 827position = change.Span.End; 829changeRanges.Add(new TextChangeRange(change.Span, newTextLength));
Text\TextChange.cs (7)
55return string.Format("{0}: {{ {1}, \"{2}\" }}", this.GetType().Name, Span, NewText); 66EqualityComparer<TextSpan>.Default.Equals(this.Span, other.Span) && 72return Hash.Combine(this.Span.GetHashCode(), this.NewText?.GetHashCode() ?? 0); 92return new TextChangeRange(change.Span, change.NewText.Length); 108return $"new TextChange(new TextSpan({Span.Start}, {Span.Length}), {newTextDisplay})";
Text\TextChangeRangeExtensions.cs (1)
105return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
Microsoft.CodeAnalysis.Analyzers (9)
src\roslyn\src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (1)
105return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractAggregatedFormattingResult.cs (1)
76: changes.Where(s => _formattingSpans.HasIntervalThatIntersectsWith(s.Span)).ToList();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractFormattingResult.cs (3)
83var oldText = (change.Span == span) ? originalString : originalString.Substring(change.Span.Start - span.Start, change.Span.Length);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (1)
239var span = textChange.Span;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (2)
697changes[index].Span); 720if (change.Span.Contains(insertionPoint) && IsNullOrWhitespace(change.NewText))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (1)
79textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
Microsoft.CodeAnalysis.AnalyzerUtilities (8)
src\roslyn\src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (1)
105return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractAggregatedFormattingResult.cs (1)
76: changes.Where(s => _formattingSpans.HasIntervalThatIntersectsWith(s.Span)).ToList();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractFormattingResult.cs (3)
83var oldText = (change.Span == span) ? originalString : originalString.Substring(change.Span.Start - span.Start, change.Span.Length);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (1)
239var span = textChange.Span;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (2)
697changes[index].Span); 720if (change.Span.Contains(insertionPoint) && IsNullOrWhitespace(change.NewText))
Microsoft.CodeAnalysis.CodeStyle (16)
src\roslyn\src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (8)
64if (change.NewText.Length > 0 && !change.Span.IsEmpty) 69var offset = change.Span.Length - change.NewText.Length; 72if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 74change = new TextChange(new TextSpan(change.Span.Start, offset), ""); 81if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 83change = new TextChange(new TextSpan(change.Span.Start + change.NewText.Length, offset), ""); 90if (change.NewText.Length == 0 && change.Span.IsEmpty) 97var location = Location.Create(tree, change.Span);
src\roslyn\src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (1)
105return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractAggregatedFormattingResult.cs (1)
76: changes.Where(s => _formattingSpans.HasIntervalThatIntersectsWith(s.Span)).ToList();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractFormattingResult.cs (3)
83var oldText = (change.Span == span) ? originalString : originalString.Substring(change.Span.Start - span.Start, change.Span.Length);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (1)
239var span = textChange.Span;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (2)
697changes[index].Span); 720if (change.Span.Contains(insertionPoint) && IsNullOrWhitespace(change.NewText))
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (1)
79textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Formatting\CSharpSyntaxFormattingService.cs (1)
89return [.. tokenEdits.Where(t => t.Span.Start >= token.FullSpan.Start)];
Microsoft.CodeAnalysis.CSharp.Features (1)
Copilot\CSharpCopilotProposalAdjusterService.cs (1)
41var lastChangeEndPos = lastTextChange.Span.End + lastTextChange.NewText?.Length ?? 0;
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Formatting\CSharpSyntaxFormattingService.cs (1)
89return [.. tokenEdits.Where(t => t.Span.Start >= token.FullSpan.Start)];
Microsoft.CodeAnalysis.Features (52)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaBatchFixHelpers.cs (5)
106var orderedChanges = startTokenChanges.Concat(endTokenChanges).OrderBy(change => change.Span).Distinct(); 132static bool IsPriorSpan(TextSpan span, TextChange textChange) => span.End <= textChange.Span.Start; 133static bool IsFollowingSpan(TextSpan span, TextChange textChange) => span.Start >= textChange.Span.End; 134static bool IsEnclosingSpan(TextSpan span, TextChange textChange) => span.Contains(textChange.Span); 154var delta = textChange.NewText.Length - textChange.Span.Length;
CodeRefactorings\AddMissingImports\AbstractAddMissingImportsFeatureService.cs (3)
113.GroupBy(change => change.Span) 169Debug.Assert(textChanges.Last().Span.IntersectsWith(insertSpan.End)); 226if (change.Span.IsEmpty)
Completion\CompletionService.cs (1)
255Debug.Assert(item.Span == change.TextChange.Span || item.IsComplexTextEdit);
Completion\Providers\Snippets\AbstractSnippetCompletionProvider.cs (2)
53if (change.Span.Start > item.Span.Start) 55var 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);
Copilot\CopilotUtilities.cs (10)
46newSpans.Add(new TextSpan(change.Span.Start + totalDelta, newTextLength)); 47totalDelta += newTextLength - change.Span.Length; 67builder.Sort(static (c1, c2) => c1.Span.Start - c2.Span.Start); 75if (lastEdit.Span.OverlapsWith(currentEdit.Span)) 85Contract.ThrowIfTrue(!textChanges.IsSorted(static (c1, c2) => c1.Span.Start - c2.Span.Start), "'changes' was not sorted."); 91Contract.ThrowIfTrue(lastEdit.Span.OverlapsWith(currentEdit.Span), "'changes' contained overlapping edits.");
Copilot\IProposalAdjusterService.cs (10)
192var span = change.Span; 265if (!IntersectsProtectedSpan(change.Span, protectedSpan)) 305var overlapsStart = change.Span.Start <= protectedSpan.Start; 306var overlapsEnd = change.Span.End >= protectedSpan.End; 319var beforeSpan = TextSpan.FromBounds(change.Span.Start, protectedSpan.Start); 324var afterSpan = TextSpan.FromBounds(protectedSpan.End, change.Span.End); 331var overlapText = originalText.ToString(TextSpan.FromBounds(protectedSpan.Start, change.Span.End)); 336TextSpan.FromBounds(change.Span.Start, protectedSpan.Start), 341var overlapText = originalText.ToString(TextSpan.FromBounds(change.Span.Start, protectedSpan.End)); 346TextSpan.FromBounds(protectedSpan.End, change.Span.End),
EmbeddedLanguages\DateAndTime\DateAndTimeEmbeddedCompletionProvider.cs (3)
113properties.Add(new(StartKey, textChange.Span.Start.ToString())); 114properties.Add(new(LengthKey, textChange.Span.Length.ToString())); 129isComplexTextEdit: context.CompletionListSpan != textChange.Span));
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexEmbeddedCompletionProvider.cs (3)
100properties.Add(KeyValuePair.Create(StartKey, textChange.Span.Start.ToString())); 101properties.Add(KeyValuePair.Create(LengthKey, textChange.Span.Length.ToString())); 119isComplexTextEdit: context.CompletionListSpan != textChange.Span));
Snippets\RoslynLSPSnippetConverter.cs (4)
34var textChangeStart = textChange.Span.Start; 46for (var i = 0; i < textChange.Span.Length + 1;) 128var startPosition = textChange.Span.Start; 129var endPosition = textChange.Span.Start + textChangeText.Length;
src\roslyn\src\Analyzers\Core\Analyzers\Formatting\AbstractFormattingAnalyzer.cs (8)
64if (change.NewText.Length > 0 && !change.Span.IsEmpty) 69var offset = change.Span.Length - change.NewText.Length; 72if (oldText.GetSubText(new TextSpan(change.Span.Start + offset, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 74change = new TextChange(new TextSpan(change.Span.Start, offset), ""); 81if (oldText.GetSubText(new TextSpan(change.Span.Start, change.NewText.Length)).ContentEquals(SourceText.From(change.NewText))) 83change = new TextChange(new TextSpan(change.Span.Start + change.NewText.Length, offset), ""); 90if (change.NewText.Length == 0 && change.Span.IsEmpty) 97var location = Location.Create(tree, change.Span);
Microsoft.CodeAnalysis.Razor.Compiler (1)
CSharp\TextChangeExtensions.cs (1)
13return new SourceChange(textChange.Span.AsSourceSpan(), textChange.NewText);
Microsoft.CodeAnalysis.ResxSourceGenerator (8)
src\roslyn\src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (1)
105return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractAggregatedFormattingResult.cs (1)
76: changes.Where(s => _formattingSpans.HasIntervalThatIntersectsWith(s.Span)).ToList();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractFormattingResult.cs (3)
83var oldText = (change.Span == span) ? originalString : originalString.Substring(change.Span.Start - span.Start, change.Span.Length);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (1)
239var span = textChange.Span;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (2)
697changes[index].Span); 720if (change.Span.Contains(insertionPoint) && IsNullOrWhitespace(change.NewText))
Microsoft.CodeAnalysis.Workspaces (52)
CodeFixes\FixAllOccurrences\TextChangeMerger.cs (9)
25=> value.Span; 73var changesToApply = _totalChangesIntervalTree.Distinct().OrderBy(tc => tc.Span.Start); 106change.Span.Start, change.Span.Length, ref overlappingSpans); 109change.Span.Start, change.Span.Length, ref intersectingSpans); 149=> change.Span.IsEmpty; 191otherChange.Span.End == change.Span.Start;
LinkedFileDiffMerging\AbstractLinkedFileMergeConflictCommentAdditionService.cs (7)
38var currentPartitionEndLine = originalSourceText.Lines.GetLineFromPosition(changes.First().Span.End); 43var changeStartLine = originalSourceText.Lines.GetLineFromPosition(change.Span.Start); 51currentPartitionEndLine = originalSourceText.Lines.GetLineFromPosition(change.Span.End); 68var startPosition = changePartition.First().Span.Start; 69var endPosition = changePartition.Last().Span.End; 75var adjustedChanges = changePartition.Select(c => new TextChange(TextSpan.FromBounds(c.Span.Start - startLineStartPosition, c.Span.End - startLineStartPosition), c.NewText!));
LinkedFileDiffMerging\LinkedFileDiffMergingSession.cs (26)
152while (cumulativeChangeIndex < cumulativeChanges.Length && cumulativeChanges[cumulativeChangeIndex].Span.End < change.Span.Start) 162if (!cumulativeChange.Span.IntersectsWith(change.Span)) 169if (change.Span != cumulativeChange.Span || change.NewText != cumulativeChange.NewText) 224while (commentChangeIndex < commentChangesList.Length && commentChangesList[commentChangeIndex].Span.End <= mergedChange.Span.Start) 228mergeConflictResolutionSpans.Add(new TextSpan(commentChangesList[commentChangeIndex].Span.Start + currentPositionDelta, commentChangesList[commentChangeIndex].NewText!.Length)); 229currentPositionDelta += commentChangesList[commentChangeIndex].NewText!.Length - commentChangesList[commentChangeIndex].Span.Length; 233if (commentChangeIndex >= commentChangesList.Length || mergedChange.Span.End <= commentChangesList[commentChangeIndex].Span.Start) 237currentPositionDelta += mergedChange.NewText!.Length - mergedChange.Span.Length; 242var conflictingCommentInsertionLocation = new TextSpan(mergedChange.Span.Start, 0); 243while (commentChangeIndex < commentChangesList.Length && commentChangesList[commentChangeIndex].Span.Start < mergedChange.Span.End) 246mergeConflictResolutionSpans.Add(new TextSpan(commentChangesList[commentChangeIndex].Span.Start + currentPositionDelta, commentChangesList[commentChangeIndex].NewText!.Length)); 254currentPositionDelta += mergedChange.NewText!.Length - mergedChange.Span.Length; 261mergeConflictResolutionSpans.Add(new TextSpan(commentChangesList[commentChangeIndex].Span.Start + currentPositionDelta, commentChangesList[commentChangeIndex].NewText!.Length)); 263currentPositionDelta += commentChangesList[commentChangeIndex].NewText!.Length - commentChangesList[commentChangeIndex].Span.Length; 275var orderedChanges = changes.Sort(static (c1, c2) => c1.Span.Start - c2.Span.Start); 281if (nextChange.Span.Start == currentChange.Span.End) 283currentChange = new TextChange(TextSpan.FromBounds(currentChange.Span.Start, nextChange.Span.End), currentChange.NewText + nextChange.NewText);
src\roslyn\src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (1)
105return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractAggregatedFormattingResult.cs (1)
76: changes.Where(s => _formattingSpans.HasIntervalThatIntersectsWith(s.Span)).ToList();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractFormattingResult.cs (3)
83var oldText = (change.Span == span) ? originalString : originalString.Substring(change.Span.Start - span.Start, change.Span.Length);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (1)
239var span = textChange.Span;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (2)
697changes[index].Span); 720if (change.Span.Contains(insertionPoint) && IsNullOrWhitespace(change.NewText))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (1)
79textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
Workspace\Solution\Document.cs (1)
486if (textChanges.Length > 1 || (textChanges.Length == 1 && textChanges[0].Span != new TextSpan(0, oldText.Length)))
Roslyn.Diagnostics.Analyzers (9)
src\roslyn\src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (1)
105return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractAggregatedFormattingResult.cs (1)
76: changes.Where(s => _formattingSpans.HasIntervalThatIntersectsWith(s.Span)).ToList();
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractFormattingResult.cs (3)
83var oldText = (change.Span == span) ? originalString : originalString.Substring(change.Span.Start - span.Start, change.Span.Length);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (1)
239var span = textChange.Span;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (2)
697changes[index].Span); 720if (change.Span.Contains(insertionPoint) && IsNullOrWhitespace(change.NewText))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (1)
79textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
Roslyn.Diagnostics.CSharp.Analyzers (1)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Formatting\CSharpSyntaxFormattingService.cs (1)
89return [.. tokenEdits.Where(t => t.Span.Start >= token.FullSpan.Start)];