1 write to Span
Microsoft.CodeAnalysis (1)
Text\TextChange.cs (1)
45this.Span = span;
189 references to Span
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.AspNetCore.App.Analyzers.Test (13)
RouteEmbeddedLanguage\FrameworkParametersCompletionProviderTests.cs (10)
39Assert.Equal(result.CompletionListSpan, change.TextChange.Span); 67Assert.Equal(result.CompletionListSpan, change.TextChange.Span); 95Assert.Equal(result.CompletionListSpan, change.TextChange.Span); 123Assert.Equal(result.CompletionListSpan, change.TextChange.Span); 153Assert.Equal(result.CompletionListSpan, change.TextChange.Span); 181Assert.Equal(result.CompletionListSpan, change.TextChange.Span); 209Assert.Equal(result.CompletionListSpan, change.TextChange.Span); 237Assert.Equal(result.CompletionListSpan, change.TextChange.Span); 265Assert.Equal(result.CompletionListSpan, change.TextChange.Span); 999Assert.Equal(result.CompletionListSpan, change.TextChange.Span);
RouteEmbeddedLanguage\RoutePatternCompletionProviderTests.cs (3)
124Assert.Equal(result.CompletionListSpan, change.TextChange.Span); 153Assert.Equal(result.CompletionListSpan, change.TextChange.Span); 182Assert.Equal(result.CompletionListSpan, change.TextChange.Span);
Microsoft.CodeAnalysis (18)
Text\SourceText.cs (10)
768if (change.Span.End > this.Length) 772if (change.Span.Start < position) 777if (change.Span.End <= changeRanges.Last().Span.Start) 780where !c.Span.IsEmpty || c.NewText?.Length > 0 781orderby c.Span 792if (change.Span.Length == 0 && newTextLength == 0) 796if (change.Span.Start > position) 798var subText = this.GetSubText(new TextSpan(position, change.Span.Start - position)); 808position = change.Span.End; 810changeRanges.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})";
Text\TextChangeRangeExtensions.cs (1)
105return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
Microsoft.CodeAnalysis.CodeStyle (16)
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\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (1)
105return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractAggregatedFormattingResult.cs (1)
77: changes.Where(s => _formattingSpans.HasIntervalThatIntersectsWith(s.Span)).ToList();
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (1)
240var span = textChange.Span;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (2)
698changes[index].Span); 721if (change.Span.Contains(insertionPoint) && IsNullOrWhitespace(change.NewText))
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (1)
83textChanges.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)
179edit.Replace(change.Span.ToSpan(), change.NewText);
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (2)
Formatting\Indentation\SmartTokenFormatterFormatRangeTests.cs (1)
3454edit.Replace(change.Span.ToSpan(), change.NewText);
Intents\IntentTestsBase.cs (1)
75edit.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)
119return tokenEdits.Where(t => t.Span.Start >= token.FullSpan.Start).ToImmutableArray();
Microsoft.CodeAnalysis.EditorFeatures (8)
AutomaticCompletion\BraceCompletionSessionProvider.BraceCompletionSession.cs (1)
424edit.Replace(change.Span.ToSpan(), change.NewText);
Editor\TextEditApplication.cs (2)
42edit.Replace(change.Span.Start, change.Span.Length, change.NewText);
IntelliSense\AsyncCompletion\CommitManager.cs (1)
251var triggerSnapshotSpan = new SnapshotSpan(triggerSnapshot, textChange.Span.ToSpan());
Interactive\InteractiveWorkspace.cs (2)
52edit.Replace(change.Span.Start, change.Span.Length, change.NewText);
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)
755textChange = new TextChange(textChange.Span, textChange.NewText.TrimEnd(commitChar) + commitChar);
Formatting\CoreFormatterTestsBase.cs (1)
168edit.Replace(change.Span.ToSpan(), change.NewText);
Workspaces\EditorTestHostDocument.cs (2)
224edit.Replace(change.Span.Start, change.Span.Length, change.NewText);
Microsoft.CodeAnalysis.EditorFeatures.Text (1)
Extensions.SnapshotSourceText.cs (1)
214edit.Replace(change.Span.ToSpan(), change.NewText);
Microsoft.CodeAnalysis.Features (24)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaBatchFixHelpers.cs (4)
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)
135var orderedTextInserts = allTextChanges.Where(change => change.Span.IsEmpty) 141.GroupBy(change => change.Span) 191Debug.Assert(textChanges.Last().Span.IntersectsWith(insertSpan.End));
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);
Snippets\RoslynLSPSnippetConverter.cs (4)
35var textChangeStart = textChange.Span.Start; 47for (var i = 0; i < textChange.Span.Length + 1;) 129var startPosition = textChange.Span.Start; 130var endPosition = textChange.Span.Start + textChangeText.Length;
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.LanguageServer.Protocol (13)
Extensions\ProtocolConversions.cs (2)
333Range = TextSpanToRange(textChange.Span, oldText) 404var mappedResults = await GetMappedSpanResultAsync(oldDocument, textChanges.Select(tc => tc.Span).ToImmutableArray(), cancellationToken).ConfigureAwait(false);
ExternalAccess\Razor\SimplifyMethodHandler.cs (1)
62var node = newTree.FindNode(pendingChange.Span, findInTrivia: false, getInnermostNodeForTie: false, cancellationToken);
Handler\Completion\CompletionResultFactory.cs (4)
516Debug.Assert(change.Span == defaultSpan); 517PopulateTextEdit(lspItem, change.Span, change.NewText ?? string.Empty, documentText, itemDefaultsSupported, defaultSpan); 539Range = ProtocolConversions.TextSpanToRange(change.Span, sourceText), 676var completionChangeSpan = completionChange.TextChange.Span;
Handler\InlineCompletions\InlineCompletionsHandler.cs (4)
180var snippetEndPosition = textChange.Span.Start + textChange.NewText!.Length; 185var spanToFormat = TextSpan.FromBounds(textChange.Span.Start, snippetEndPosition); 229var textChangesBefore = textChanges.Where(t => t.Span.End <= originalSpan.Start); 230var amountToAdjust = textChangesBefore.Sum(t => t.NewText!.Length - t.Span.Length);
Handler\OnAutoInsert\OnAutoInsertHandler.cs (2)
230Debug.Assert(desiredCaretLocation >= textChange.Span.Start); 231var 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.Workspaces (38)
CodeFixes\FixAllOccurrences\TextChangeMerger.cs (9)
24=> value.Span; 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;
LinkedFileDiffMerging\AbstractLinkedFileMergeConflictCommentAdditionService.cs (7)
43var currentPartitionEndLine = originalSourceText.Lines.GetLineFromPosition(changes.First().Span.End); 48var changeStartLine = originalSourceText.Lines.GetLineFromPosition(change.Span.Start); 56currentPartitionEndLine = originalSourceText.Lines.GetLineFromPosition(change.Span.End); 73var startPosition = changePartition.First().Span.Start; 74var endPosition = changePartition.Last().Span.End; 80var adjustedChanges = changePartition.Select(c => new TextChange(TextSpan.FromBounds(c.Span.Start - startLineStartPosition, c.Span.End - startLineStartPosition), c.NewText));
LinkedFileDiffMerging\LinkedFileDiffMergingSession.cs (12)
153while (cumulativeChangeIndex < cumulativeChanges.Length && cumulativeChanges[cumulativeChangeIndex].Span.End < change.Span.Start) 163if (!cumulativeChange.Span.IntersectsWith(change.Span)) 170if (change.Span != cumulativeChange.Span || change.NewText != cumulativeChange.NewText) 276var orderedChanges = changes.Sort(static (c1, c2) => c1.Span.Start - c2.Span.Start); 282if (nextChange.Span.Start == currentChange.Span.End) 284currentChange = new TextChange(TextSpan.FromBounds(currentChange.Span.Start, nextChange.Span.End), currentChange.NewText + nextChange.NewText);
src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (1)
105return new TextChangeRange(textChange.Span, textChange.NewText?.Length ?? 0);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractAggregatedFormattingResult.cs (1)
77: changes.Where(s => _formattingSpans.HasIntervalThatIntersectsWith(s.Span)).ToList();
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\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (1)
240var span = textChange.Span;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (2)
698changes[index].Span); 721if (change.Span.Contains(insertionPoint) && IsNullOrWhitespace(change.NewText))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Utilities\ParsedDocument.cs (1)
83textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldDocument.Text.Length))
Workspace\Solution\Document.cs (1)
449if (textChanges.Count > 1 || (textChanges.Count == 1 && textChanges[0].Span != new TextSpan(0, oldText.Length)))
Microsoft.VisualStudio.LanguageServices (10)
Venus\ContainedDocument.cs (8)
335if (change.Span.End <= visibleTextSpan.Start) 340if (visibleTextSpan.End <= change.Span.Start) 352var leftText = originalText.ToString(changeInOriginalText.Span); 354var offsetInOriginalText = changeInOriginalText.Span.Start; 734visibleSpansInOriginal[currentVisibleSpanIndex].End < change.Span.Start) 746var span = change.Span.ToSpan(); 816var newChanges = FilterTextChanges(document.GetTextSynchronously(CancellationToken.None), visibleSpans, changes.ToReadOnlyCollection()).Where(t => visibleSpan.Contains(t.Span)); 820edit.Replace(change.Span.ToSpan(), change.NewText);
Venus\ContainedDocument.DocumentServiceProvider.cs (1)
78var mappedSpanResults = await MapSpansAsync(oldDocument, textChanges.Select(tc => tc.Span), CancellationToken.None).ConfigureAwait(false);
Workspace\VisualStudioFormattingRuleFactoryServiceFactory.cs (1)
110return changes.Where(c => span.IntersectsWith(c.Span));
Microsoft.VisualStudio.LanguageServices.LiveShare (2)
Client\RemoteLanguageServiceWorkspace.cs (2)
514edit.Replace(change.Span.Start, change.Span.Length, change.NewText);