diff --git a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs index eccfa38c27a86..725664d4f1ffc 100644 --- a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs +++ b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs @@ -86,14 +86,14 @@ private static ImmutableArray AnalyzeCodeBlock(CodeBlockAnalysisContex return simplifier.Spans; } - private ImmutableArray AnalyzeSemanticModel(SemanticModelAnalysisContext context, int positionOfFirstReducingNullableDirective, TextSpanIntervalTree? codeBlockIntervalTree, TextSpanIntervalTree? possibleNullableImpactIntervalTree) + private ImmutableArray AnalyzeSemanticModel(SemanticModelAnalysisContext context, int positionOfFirstReducingNullableDirective, TextSpanMutableIntervalTree? codeBlockIntervalTree, TextSpanMutableIntervalTree? possibleNullableImpactIntervalTree) { var root = context.SemanticModel.SyntaxTree.GetCompilationUnitRoot(context.CancellationToken); using (var simplifier = new NullableImpactingSpanWalker(context.SemanticModel, positionOfFirstReducingNullableDirective, ignoredSpans: codeBlockIntervalTree, context.CancellationToken)) { simplifier.Visit(root); - possibleNullableImpactIntervalTree ??= new TextSpanIntervalTree(); + possibleNullableImpactIntervalTree ??= new TextSpanMutableIntervalTree(); foreach (var interval in simplifier.Spans) { possibleNullableImpactIntervalTree.AddIntervalInPlace(interval); @@ -144,7 +144,7 @@ SyntaxKind.IfDirectiveTrivia or SyntaxKind.ElifDirectiveTrivia or SyntaxKind.ElseDirectiveTrivia) { - possibleNullableImpactIntervalTree ??= new TextSpanIntervalTree(); + possibleNullableImpactIntervalTree ??= new TextSpanMutableIntervalTree(); possibleNullableImpactIntervalTree.AddIntervalInPlace(directive.Span); } } @@ -173,16 +173,16 @@ private SyntaxTreeState(bool completed, int? positionOfFirstReducingNullableDire PositionOfFirstReducingNullableDirective = positionOfFirstReducingNullableDirective; if (!completed) { - IntervalTree = new TextSpanIntervalTree(); - PossibleNullableImpactIntervalTree = new TextSpanIntervalTree(); + IntervalTree = new TextSpanMutableIntervalTree(); + PossibleNullableImpactIntervalTree = new TextSpanMutableIntervalTree(); } } [MemberNotNullWhen(false, nameof(PositionOfFirstReducingNullableDirective), nameof(IntervalTree), nameof(PossibleNullableImpactIntervalTree))] public bool Completed { get; private set; } public int? PositionOfFirstReducingNullableDirective { get; } - public TextSpanIntervalTree? IntervalTree { get; } - public TextSpanIntervalTree? PossibleNullableImpactIntervalTree { get; } + public TextSpanMutableIntervalTree? IntervalTree { get; } + public TextSpanMutableIntervalTree? PossibleNullableImpactIntervalTree { get; } public static SyntaxTreeState Create(bool defaultCompleted, NullableContextOptions compilationOptions, SyntaxTree tree, CancellationToken cancellationToken) { diff --git a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/NullableImpactingSpanWalker.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/NullableImpactingSpanWalker.cs index 5cc1092c91878..38622e35bf702 100644 --- a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/NullableImpactingSpanWalker.cs +++ b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/NullableImpactingSpanWalker.cs @@ -17,12 +17,12 @@ namespace Microsoft.CodeAnalysis.CSharp.Analyzers.RemoveUnnecessaryNullableDirec internal sealed class NullableImpactingSpanWalker( SemanticModel semanticModel, int positionOfFirstReducingNullableDirective, - TextSpanIntervalTree? ignoredSpans, + TextSpanMutableIntervalTree? ignoredSpans, CancellationToken cancellationToken) : CSharpSyntaxWalker(SyntaxWalkerDepth.StructuredTrivia), IDisposable { private readonly SemanticModel _semanticModel = semanticModel; private readonly int _positionOfFirstReducingNullableDirective = positionOfFirstReducingNullableDirective; - private readonly TextSpanIntervalTree? _ignoredSpans = ignoredSpans; + private readonly TextSpanMutableIntervalTree? _ignoredSpans = ignoredSpans; private readonly CancellationToken _cancellationToken = cancellationToken; private ImmutableArray.Builder? _spans; diff --git a/src/Analyzers/Core/Analyzers/SimplifyTypeNames/SimplifyTypeNamesDiagnosticAnalyzerBase.cs b/src/Analyzers/Core/Analyzers/SimplifyTypeNames/SimplifyTypeNamesDiagnosticAnalyzerBase.cs index fdaf88e7069f3..1e156b4354322 100644 --- a/src/Analyzers/Core/Analyzers/SimplifyTypeNames/SimplifyTypeNamesDiagnosticAnalyzerBase.cs +++ b/src/Analyzers/Core/Analyzers/SimplifyTypeNames/SimplifyTypeNamesDiagnosticAnalyzerBase.cs @@ -119,7 +119,7 @@ private void AnalyzeCompilation(CompilationStartAnalysisContext context) /// . protected abstract bool IsIgnoredCodeBlock(SyntaxNode codeBlock); protected abstract ImmutableArray AnalyzeCodeBlock(CodeBlockAnalysisContext context, SyntaxNode root); - protected abstract ImmutableArray AnalyzeSemanticModel(SemanticModelAnalysisContext context, SyntaxNode root, TextSpanIntervalTree? codeBlockIntervalTree); + protected abstract ImmutableArray AnalyzeSemanticModel(SemanticModelAnalysisContext context, SyntaxNode root, TextSpanMutableIntervalTree? codeBlockIntervalTree); public bool TrySimplify(SemanticModel model, SyntaxNode node, [NotNullWhen(true)] out Diagnostic? diagnostic, TSimplifierOptions options, AnalyzerOptions analyzerOptions, CancellationToken cancellationToken) { @@ -229,14 +229,14 @@ private class AnalyzerImpl(SimplifyTypeNamesDiagnosticAnalyzerBase /// /// - private readonly ConcurrentDictionary completed, TextSpanIntervalTree? intervalTree)> _codeBlockIntervals = []; + private readonly ConcurrentDictionary completed, TextSpanMutableIntervalTree? intervalTree)> _codeBlockIntervals = []; public void AnalyzeCodeBlock(CodeBlockAnalysisContext context) { if (_analyzer.IsIgnoredCodeBlock(context.CodeBlock)) return; - var (completed, intervalTree) = _codeBlockIntervals.GetOrAdd(context.CodeBlock.SyntaxTree, _ => (new StrongBox(false), new TextSpanIntervalTree())); + var (completed, intervalTree) = _codeBlockIntervals.GetOrAdd(context.CodeBlock.SyntaxTree, _ => (new StrongBox(false), new TextSpanMutableIntervalTree())); if (completed.Value) return; @@ -256,7 +256,7 @@ public void AnalyzeCodeBlock(CodeBlockAnalysisContext context) context.ReportDiagnostic(diagnostic); } - static bool TryProceedWithInterval(bool addIfAvailable, TextSpan span, StrongBox completed, TextSpanIntervalTree intervalTree) + static bool TryProceedWithInterval(bool addIfAvailable, TextSpan span, StrongBox completed, TextSpanMutableIntervalTree intervalTree) { lock (completed) { diff --git a/src/EditorFeatures/Core/Shared/Tagging/Utilities/TagSpanIntervalTree.cs b/src/EditorFeatures/Core/Shared/Tagging/Utilities/TagSpanIntervalTree.cs index 7807cb4fb4b38..85948abd1fd45 100644 --- a/src/EditorFeatures/Core/Shared/Tagging/Utilities/TagSpanIntervalTree.cs +++ b/src/EditorFeatures/Core/Shared/Tagging/Utilities/TagSpanIntervalTree.cs @@ -27,7 +27,7 @@ internal sealed partial class TagSpanIntervalTree(SpanTrackingMode spanTra public static readonly TagSpanIntervalTree Empty = new(SpanTrackingMode.EdgeInclusive); private readonly SpanTrackingMode _spanTrackingMode = spanTrackingMode; - private readonly FlatArrayIntervalTree> _tree = FlatArrayIntervalTree>.Empty; + private readonly ImmutableIntervalTree> _tree = ImmutableIntervalTree>.Empty; public TagSpanIntervalTree( ITextSnapshot textSnapshot, @@ -39,7 +39,7 @@ public TagSpanIntervalTree( // routines), and allows us to build the balanced tree directly without having to do any additional work. values.Sort(static (t1, t2) => t1.Span.Start.Position - t2.Span.Start.Position); - _tree = FlatArrayIntervalTree>.CreateFromSorted( + _tree = ImmutableIntervalTree>.CreateFromSorted( new IntervalIntrospector(textSnapshot, trackingMode), values); } diff --git a/src/Features/CSharp/Portable/ConvertToRawString/ConvertInterpolatedStringToRawStringCodeRefactoringProvider.cs b/src/Features/CSharp/Portable/ConvertToRawString/ConvertInterpolatedStringToRawStringCodeRefactoringProvider.cs index 26644ad33783f..b22d3ef4782dc 100644 --- a/src/Features/CSharp/Portable/ConvertToRawString/ConvertInterpolatedStringToRawStringCodeRefactoringProvider.cs +++ b/src/Features/CSharp/Portable/ConvertToRawString/ConvertInterpolatedStringToRawStringCodeRefactoringProvider.cs @@ -475,7 +475,7 @@ private static string GetIndentationStringForPosition(SourceText text, SyntaxFor private static void AppendFullLine(StringBuilder builder, TextLine line) => builder.Append(line.Text!.ToString(line.SpanIncludingLineBreak)); - private static (FlatArrayIntervalTree interpolationInteriorSpans, FlatArrayIntervalTree restrictedSpans) GetInterpolationSpans( + private static (ImmutableIntervalTree interpolationInteriorSpans, ImmutableIntervalTree restrictedSpans) GetInterpolationSpans( InterpolatedStringExpressionSyntax stringExpression, CancellationToken cancellationToken) { var interpolationInteriorSpans = new SegmentedList(); @@ -515,8 +515,8 @@ private static (FlatArrayIntervalTree interpolationInteriorSpans, Flat } return ( - FlatArrayIntervalTree.CreateFromUnsorted(new TextSpanIntervalIntrospector(), interpolationInteriorSpans), - FlatArrayIntervalTree.CreateFromUnsorted(new TextSpanIntervalIntrospector(), restrictedSpans)); + ImmutableIntervalTree.CreateFromUnsorted(new TextSpanIntervalIntrospector(), interpolationInteriorSpans), + ImmutableIntervalTree.CreateFromUnsorted(new TextSpanIntervalIntrospector(), restrictedSpans)); } private static InterpolatedStringExpressionSyntax CleanInterpolatedString( @@ -630,7 +630,7 @@ private static InterpolatedStringExpressionSyntax CleanInterpolatedString( private static string ComputeCommonWhitespacePrefix( ArrayBuilder lines, - FlatArrayIntervalTree interpolationInteriorSpans) + ImmutableIntervalTree interpolationInteriorSpans) { string? commonLeadingWhitespace = null; diff --git a/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs b/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs index 70c4dfc1096a2..9d9581c44d5b5 100644 --- a/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs +++ b/src/Features/CSharp/Portable/Diagnostics/Analyzers/CSharpSimplifyTypeNamesDiagnosticAnalyzer.cs @@ -64,7 +64,7 @@ protected override ImmutableArray AnalyzeCodeBlock(CodeBlockAnalysis return simplifier.Diagnostics; } - protected override ImmutableArray AnalyzeSemanticModel(SemanticModelAnalysisContext context, SyntaxNode root, TextSpanIntervalTree? codeBlockIntervalTree) + protected override ImmutableArray AnalyzeSemanticModel(SemanticModelAnalysisContext context, SyntaxNode root, TextSpanMutableIntervalTree? codeBlockIntervalTree) { var options = context.GetCSharpAnalyzerOptions().GetSimplifierOptions(); if (ShouldSkipAnalysis(context.FilterTree, context.Options, context.SemanticModel.Compilation.Options, GetAllNotifications(options), context.CancellationToken)) diff --git a/src/Features/CSharp/Portable/Diagnostics/Analyzers/TypeSyntaxSimplifierWalker.cs b/src/Features/CSharp/Portable/Diagnostics/Analyzers/TypeSyntaxSimplifierWalker.cs index a4aacbe0e6ee7..5958630a7e3f0 100644 --- a/src/Features/CSharp/Portable/Diagnostics/Analyzers/TypeSyntaxSimplifierWalker.cs +++ b/src/Features/CSharp/Portable/Diagnostics/Analyzers/TypeSyntaxSimplifierWalker.cs @@ -42,7 +42,7 @@ internal class TypeSyntaxSimplifierWalker : CSharpSyntaxWalker, IDisposable private readonly SemanticModel _semanticModel; private readonly CSharpSimplifierOptions _options; private readonly AnalyzerOptions _analyzerOptions; - private readonly TextSpanIntervalTree? _ignoredSpans; + private readonly TextSpanMutableIntervalTree? _ignoredSpans; private readonly CancellationToken _cancellationToken; private ImmutableArray.Builder? _diagnostics; @@ -70,7 +70,7 @@ public ImmutableArray.Builder DiagnosticsBuilder } } - public TypeSyntaxSimplifierWalker(CSharpSimplifyTypeNamesDiagnosticAnalyzer analyzer, SemanticModel semanticModel, CSharpSimplifierOptions options, AnalyzerOptions analyzerOptions, TextSpanIntervalTree? ignoredSpans, CancellationToken cancellationToken) + public TypeSyntaxSimplifierWalker(CSharpSimplifyTypeNamesDiagnosticAnalyzer analyzer, SemanticModel semanticModel, CSharpSimplifierOptions options, AnalyzerOptions analyzerOptions, TextSpanMutableIntervalTree? ignoredSpans, CancellationToken cancellationToken) : base(SyntaxWalkerDepth.StructuredTrivia) { _analyzer = analyzer; diff --git a/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/TypeSyntaxSimplifierWalker.vb b/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/TypeSyntaxSimplifierWalker.vb index 515a3bee981a2..2d4058c1dda9e 100644 --- a/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/TypeSyntaxSimplifierWalker.vb +++ b/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/TypeSyntaxSimplifierWalker.vb @@ -40,7 +40,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.SimplifyTypeNames Private ReadOnly _semanticModel As SemanticModel Private ReadOnly _options As VisualBasicSimplifierOptions Private ReadOnly _analyzerOptions As AnalyzerOptions - Private ReadOnly _ignoredSpans As TextSpanIntervalTree + Private ReadOnly _ignoredSpans As TextSpanMutableIntervalTree Private ReadOnly _cancellationToken As CancellationToken Private _diagnostics As ImmutableArray(Of Diagnostic).Builder @@ -69,7 +69,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.SimplifyTypeNames End Get End Property - Public Sub New(analyzer As VisualBasicSimplifyTypeNamesDiagnosticAnalyzer, semanticModel As SemanticModel, options As VisualBasicSimplifierOptions, analyzerOptions As AnalyzerOptions, ignoredSpans As TextSpanIntervalTree, cancellationToken As CancellationToken) + Public Sub New(analyzer As VisualBasicSimplifyTypeNamesDiagnosticAnalyzer, semanticModel As SemanticModel, options As VisualBasicSimplifierOptions, analyzerOptions As AnalyzerOptions, ignoredSpans As TextSpanMutableIntervalTree, cancellationToken As CancellationToken) MyBase.New(SyntaxWalkerDepth.StructuredTrivia) _analyzer = analyzer diff --git a/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/VisualBasicSimplifyTypeNamesDiagnosticAnalyzer.vb b/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/VisualBasicSimplifyTypeNamesDiagnosticAnalyzer.vb index 1ad930e165edb..36f180f698934 100644 --- a/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/VisualBasicSimplifyTypeNamesDiagnosticAnalyzer.vb +++ b/src/Features/VisualBasic/Portable/Diagnostics/Analyzers/VisualBasicSimplifyTypeNamesDiagnosticAnalyzer.vb @@ -51,7 +51,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.SimplifyTypeNames Return simplifier.Diagnostics End Function - Protected Overrides Function AnalyzeSemanticModel(context As SemanticModelAnalysisContext, root As SyntaxNode, codeBlockIntervalTree As TextSpanIntervalTree) As ImmutableArray(Of Diagnostic) + Protected Overrides Function AnalyzeSemanticModel(context As SemanticModelAnalysisContext, root As SyntaxNode, codeBlockIntervalTree As TextSpanMutableIntervalTree) As ImmutableArray(Of Diagnostic) Dim simplifierOptions = context.GetVisualBasicAnalyzerOptions().GetSimplifierOptions() If (ShouldSkipAnalysis(context.FilterTree, context.Options, context.SemanticModel.Compilation.Options, GetAllNotifications(simplifierOptions), context.CancellationToken)) Then Return ImmutableArray(Of Diagnostic).Empty diff --git a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.DocumentOutlineViewState.cs b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.DocumentOutlineViewState.cs index 88f1824a023d5..44631624bb0dc 100644 --- a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.DocumentOutlineViewState.cs +++ b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.DocumentOutlineViewState.cs @@ -40,13 +40,13 @@ private sealed class DocumentOutlineViewState /// Interval-tree view over so that we can quickly determine which of them /// intersect with a particular position in the document. /// - public readonly FlatArrayIntervalTree ViewModelItemsTree; + public readonly ImmutableIntervalTree ViewModelItemsTree; public DocumentOutlineViewState( ITextSnapshot textSnapshot, string searchText, ImmutableArray viewModelItems, - FlatArrayIntervalTree viewModelItemsTree) + ImmutableIntervalTree viewModelItemsTree) { TextSnapshot = textSnapshot; SearchText = searchText; diff --git a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.cs b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.cs index 9b88fa427ecd0..394931e2d375d 100644 --- a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.cs +++ b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.cs @@ -324,7 +324,7 @@ private async ValueTask ComputeViewStateAsync(CancellationToken cancellationToke // models given any position in the file with any particular text snapshot. using var _ = SegmentedListPool.GetPooledList(out var models); AddAllModels(newViewModelItems, models); - var intervalTree = FlatArrayIntervalTree.CreateFromUnsorted( + var intervalTree = ImmutableIntervalTree.CreateFromUnsorted( new IntervalIntrospector(), models); var newViewState = new DocumentOutlineViewState( diff --git a/src/VisualStudio/Core/Def/InheritanceMargin/InheritanceGlyphManager.cs b/src/VisualStudio/Core/Def/InheritanceMargin/InheritanceGlyphManager.cs index 62d6b4320c233..32d7e80796b17 100644 --- a/src/VisualStudio/Core/Def/InheritanceMargin/InheritanceGlyphManager.cs +++ b/src/VisualStudio/Core/Def/InheritanceMargin/InheritanceGlyphManager.cs @@ -47,7 +47,7 @@ internal sealed partial class InheritanceGlyphManager : IDisposable /// /// Mutable. Must only be accessed from the UI thread. /// - private SimpleBinaryIntervalTree _glyphDataTree; + private SimpleMutableIntervalTree _glyphDataTree; public InheritanceGlyphManager( Workspace workspace, diff --git a/src/Workspaces/Core/Portable/Classification/ClassifierHelper.cs b/src/Workspaces/Core/Portable/Classification/ClassifierHelper.cs index 5a4416e7a42bd..a89d5e38b40b8 100644 --- a/src/Workspaces/Core/Portable/Classification/ClassifierHelper.cs +++ b/src/Workspaces/Core/Portable/Classification/ClassifierHelper.cs @@ -251,7 +251,7 @@ public static void MergeParts.CreateFromUnsorted( + var semanticPartsTree = ImmutableIntervalTree.CreateFromUnsorted( default(TClassifiedSpanIntervalIntrospector), semanticSpans); using var tempBuffer = TemporaryArray.Empty; diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/TextChangeMerger.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/TextChangeMerger.cs index 00fd11ba200d3..1a65c1ab54d61 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/TextChangeMerger.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/TextChangeMerger.cs @@ -27,7 +27,7 @@ public TextSpan GetSpan(TextChange value) private readonly Document _oldDocument; private readonly IDocumentTextDifferencingService _differenceService; - private readonly SimpleBinaryIntervalTree _totalChangesIntervalTree = + private readonly SimpleMutableIntervalTree _totalChangesIntervalTree = BinaryIntervalTree.Create(new IntervalIntrospector(), Array.Empty()); public TextChangeMerger(Document document) @@ -78,7 +78,7 @@ public async Task GetFinalMergedTextAsync(CancellationToken cancella } private static bool AllChangesCanBeApplied( - SimpleBinaryIntervalTree cumulativeChanges, + SimpleMutableIntervalTree cumulativeChanges, ImmutableArray currentChanges) { using var overlappingSpans = TemporaryArray.Empty; @@ -91,7 +91,7 @@ private static bool AllChangesCanBeApplied( } private static bool AllChangesCanBeApplied( - SimpleBinaryIntervalTree cumulativeChanges, + SimpleMutableIntervalTree cumulativeChanges, ImmutableArray currentChanges, ref TemporaryArray overlappingSpans, ref TemporaryArray intersectingSpans) diff --git a/src/Workspaces/Core/Portable/Editing/ImportAdderService.cs b/src/Workspaces/Core/Portable/Editing/ImportAdderService.cs index 29f778e9a0278..5b13036e05388 100644 --- a/src/Workspaces/Core/Portable/Editing/ImportAdderService.cs +++ b/src/Workspaces/Core/Portable/Editing/ImportAdderService.cs @@ -42,7 +42,7 @@ public async Task AddImportsAsync( var generator = document.GetRequiredLanguageService(); // Create a simple interval tree for simplification spans. - var spansTree = new TextSpanIntervalTree(spans); + var spansTree = new TextSpanMutableIntervalTree(spans); // Only dive deeper into nodes that actually overlap with the span we care about. And also only include // those child nodes that themselves overlap with the span. i.e. if we have: diff --git a/src/Workspaces/Core/Portable/Simplification/AbstractSimplificationService.cs b/src/Workspaces/Core/Portable/Simplification/AbstractSimplificationService.cs index 2ad302dcb1782..c7af9c3154d4e 100644 --- a/src/Workspaces/Core/Portable/Simplification/AbstractSimplificationService.cs +++ b/src/Workspaces/Core/Portable/Simplification/AbstractSimplificationService.cs @@ -103,7 +103,7 @@ private async Task ReduceCoreAsync( CancellationToken cancellationToken) { // Create a simple interval tree for simplification spans. - var spansTree = new TextSpanIntervalTree(spans); + var spansTree = new TextSpanMutableIntervalTree(spans); var root = (TCompilationUnitSyntax)await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); diff --git a/src/Workspaces/CoreTest/UtilityTest/IntervalTreeTests.cs b/src/Workspaces/CoreTest/UtilityTest/IntervalTreeTests.cs index a45606d7ad8fb..0d7879eafd087 100644 --- a/src/Workspaces/CoreTest/UtilityTest/IntervalTreeTests.cs +++ b/src/Workspaces/CoreTest/UtilityTest/IntervalTreeTests.cs @@ -264,8 +264,8 @@ public TextSpan GetSpan(int value) => new(value, 0); } - private static BinaryIntervalTree CreateIntTree(params int[] values) - => BinaryIntervalTree.Create(new Int32Introspector(), values); + private static MutableIntervalTree CreateIntTree(params int[] values) + => MutableIntervalTree.Create(new Int32Introspector(), values); [Fact] public void TestSortedEnumerable1() @@ -304,7 +304,7 @@ public void TestSortedEnumerable1() [Fact] public void TestSortedEnumerable2() { - var tree = BinaryIntervalTree.Create(new Int32Introspector(), new[] { 1, 0 }); + var tree = MutableIntervalTree.Create(new Int32Introspector(), new[] { 1, 0 }); Assert.Equal(tree, new[] { 0, 1 }); } @@ -357,17 +357,17 @@ private protected override IEnumerable>> C private protected override bool HasIntervalThatIntersectsWith(IIntervalTree> tree, int position) { - return ((BinaryIntervalTree>)tree).Algorithms.HasIntervalThatIntersectsWith(position, new TupleIntrospector()); + return ((MutableIntervalTree>)tree).Algorithms.HasIntervalThatIntersectsWith(position, new TupleIntrospector()); } private protected override ImmutableArray> GetIntervalsThatIntersectWith(IIntervalTree> tree, int start, int length) { - return ((BinaryIntervalTree>)tree).Algorithms.GetIntervalsThatIntersectWith(start, length, new TupleIntrospector()); + return ((MutableIntervalTree>)tree).Algorithms.GetIntervalsThatIntersectWith(start, length, new TupleIntrospector()); } private protected override ImmutableArray> GetIntervalsThatOverlapWith(IIntervalTree> tree, int start, int length) { - return ((BinaryIntervalTree>)tree).Algorithms.GetIntervalsThatOverlapWith(start, length, new TupleIntrospector()); + return ((MutableIntervalTree>)tree).Algorithms.GetIntervalsThatOverlapWith(start, length, new TupleIntrospector()); } } @@ -375,22 +375,22 @@ public sealed class FlatArrayIntervalTreeTests : IntervalTreeTests { private protected override IEnumerable>> CreateTrees(IEnumerable> values) { - yield return FlatArrayIntervalTree>.CreateFromUnsorted(new TupleIntrospector(), new SegmentedList>(values)); + yield return ImmutableIntervalTree>.CreateFromUnsorted(new TupleIntrospector(), new SegmentedList>(values)); } private protected override bool HasIntervalThatIntersectsWith(IIntervalTree> tree, int position) { - return ((FlatArrayIntervalTree>)tree).Algorithms.HasIntervalThatIntersectsWith(position, new TupleIntrospector()); + return ((ImmutableIntervalTree>)tree).Algorithms.HasIntervalThatIntersectsWith(position, new TupleIntrospector()); } private protected override ImmutableArray> GetIntervalsThatIntersectWith(IIntervalTree> tree, int start, int length) { - return ((FlatArrayIntervalTree>)tree).Algorithms.GetIntervalsThatIntersectWith(start, length, new TupleIntrospector()); + return ((ImmutableIntervalTree>)tree).Algorithms.GetIntervalsThatIntersectWith(start, length, new TupleIntrospector()); } private protected override ImmutableArray> GetIntervalsThatOverlapWith(IIntervalTree> tree, int start, int length) { - return ((FlatArrayIntervalTree>)tree).Algorithms.GetIntervalsThatOverlapWith(start, length, new TupleIntrospector()); + return ((ImmutableIntervalTree>)tree).Algorithms.GetIntervalsThatOverlapWith(start, length, new TupleIntrospector()); } private readonly struct Int32IntervalIntrospector : IIntervalIntrospector @@ -410,7 +410,7 @@ public void TestProperBalancing() { for (var i = 0; i < 3000; i++) { - var tree = FlatArrayIntervalTree.CreateFromUnsorted(new Int32IntervalIntrospector(), new(Enumerable.Range(1, i))); + var tree = ImmutableIntervalTree.CreateFromUnsorted(new Int32IntervalIntrospector(), new(Enumerable.Range(1, i))); // Ensure that the tree produces the same elements in sorted order. AssertEx.Equal(tree, Enumerable.Range(1, i)); diff --git a/src/Workspaces/Remote/ServiceHub/Services/SemanticClassification/RemoteSemanticClassificationService.Caching.cs b/src/Workspaces/Remote/ServiceHub/Services/SemanticClassification/RemoteSemanticClassificationService.Caching.cs index 6bb8113b40e18..37af8b88a1cae 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/SemanticClassification/RemoteSemanticClassificationService.Caching.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/SemanticClassification/RemoteSemanticClassificationService.Caching.cs @@ -85,7 +85,7 @@ private static string GetPersistenceName(ClassificationType type) { var classifiedSpans = await TryGetOrReadCachedSemanticClassificationsAsync( documentKey, type, checksum, cancellationToken).ConfigureAwait(false); - var textSpanIntervalTree = new TextSpanIntervalTree(textSpans); + var textSpanIntervalTree = new TextSpanMutableIntervalTree(textSpans); return classifiedSpans.IsDefault ? null : SerializableClassifiedSpans.Dehydrate(classifiedSpans.WhereAsArray(c => textSpanIntervalTree.HasIntervalThatIntersectsWith(c.TextSpan))); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/CSharpSyntaxFormatting.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/CSharpSyntaxFormatting.cs index d56f6b058ed0e..19b67ce8243ab 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/CSharpSyntaxFormatting.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/CSharpSyntaxFormatting.cs @@ -42,7 +42,7 @@ public override SyntaxFormattingOptions DefaultOptions public override SyntaxFormattingOptions GetFormattingOptions(IOptionsReader options, SyntaxFormattingOptions? fallbackOptions) => new CSharpSyntaxFormattingOptions(options, (CSharpSyntaxFormattingOptions?)fallbackOptions); - protected override IFormattingResult CreateAggregatedFormattingResult(SyntaxNode node, IList results, TextSpanIntervalTree? formattingSpans = null) + protected override IFormattingResult CreateAggregatedFormattingResult(SyntaxNode node, IList results, TextSpanMutableIntervalTree? formattingSpans = null) => new AggregatedFormattingResult(node, results, formattingSpans); protected override AbstractFormattingResult Format(SyntaxNode node, SyntaxFormattingOptions options, ImmutableArray formattingRules, SyntaxToken startToken, SyntaxToken endToken, CancellationToken cancellationToken) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/AggregatedFormattingResult.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/AggregatedFormattingResult.cs index 0cbec655edfc9..2b8003af0e4b8 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/AggregatedFormattingResult.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/AggregatedFormattingResult.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.CSharp.Formatting; internal class AggregatedFormattingResult : AbstractAggregatedFormattingResult { - public AggregatedFormattingResult(SyntaxNode node, IList results, TextSpanIntervalTree? formattingSpans) + public AggregatedFormattingResult(SyntaxNode node, IList results, TextSpanMutableIntervalTree? formattingSpans) : base(node, results, formattingSpans) { } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/FormattingResult.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/FormattingResult.cs index 9879bb3a36533..b3e30ce857f6e 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/FormattingResult.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/FormattingResult.cs @@ -23,7 +23,7 @@ internal FormattingResult(TreeData treeInfo, TokenStream tokenStream, TextSpan s protected override SyntaxNode Rewriter(Dictionary, TriviaData> changeMap, CancellationToken cancellationToken) { - var rewriter = new TriviaRewriter(this.TreeInfo.Root, new TextSpanIntervalTree(this.FormattedSpan), changeMap, cancellationToken); + var rewriter = new TriviaRewriter(this.TreeInfo.Root, new TextSpanMutableIntervalTree(this.FormattedSpan), changeMap, cancellationToken); return rewriter.Transform(); } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/Trivia/TriviaRewriter.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/Trivia/TriviaRewriter.cs index 4877963eb1308..58f85e2643cad 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/Trivia/TriviaRewriter.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/Trivia/TriviaRewriter.cs @@ -19,7 +19,7 @@ namespace Microsoft.CodeAnalysis.CSharp.Formatting; internal class TriviaRewriter : CSharpSyntaxRewriter { private readonly SyntaxNode _node; - private readonly TextSpanIntervalTree _spans; + private readonly TextSpanMutableIntervalTree _spans; private readonly CancellationToken _cancellationToken; private readonly Dictionary _trailingTriviaMap = []; @@ -27,7 +27,7 @@ internal class TriviaRewriter : CSharpSyntaxRewriter public TriviaRewriter( SyntaxNode node, - TextSpanIntervalTree spanToFormat, + TextSpanMutableIntervalTree spanToFormat, Dictionary, TriviaData> map, CancellationToken cancellationToken) { diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/FlatArrayIntervalTree`1.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/FlatArrayIntervalTree`1.cs index 5def187934fb9..5c37cea81a642 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/FlatArrayIntervalTree`1.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/FlatArrayIntervalTree`1.cs @@ -17,11 +17,11 @@ namespace Microsoft.CodeAnalysis.Shared.Collections; /// values of the interval tree are known up front and will not change after the tree is created. /// /// -internal readonly struct FlatArrayIntervalTree : IIntervalTree +internal readonly struct ImmutableIntervalTree : IIntervalTree { private readonly record struct Node(T Value, int MaxEndNodeIndex); - public static readonly FlatArrayIntervalTree Empty = new(new SegmentedArray(0)); + public static readonly ImmutableIntervalTree Empty = new(new SegmentedArray(0)); /// /// The nodes of this interval tree flatted into a single array. The root is as index 0. The left child of any @@ -35,23 +35,23 @@ namespace Microsoft.CodeAnalysis.Shared.Collections; /// private readonly SegmentedArray _array; - private FlatArrayIntervalTree(SegmentedArray array) + private ImmutableIntervalTree(SegmentedArray array) => _array = array; /// /// Provides access to lots of common algorithms on this interval tree. /// - public IntervalTreeAlgorithms> Algorithms => new(this); + public IntervalTreeAlgorithms> Algorithms => new(this); /// - /// Creates a from an unsorted list of . This will + /// Creates a from an unsorted list of . This will /// incur a delegate allocation to sort the values. If callers can avoid that allocation by pre-sorting the values, /// they should do so and call instead. /// /// /// will be sorted in place. /// - public static FlatArrayIntervalTree CreateFromUnsorted(in TIntrospector introspector, SegmentedList values) + public static ImmutableIntervalTree CreateFromUnsorted(in TIntrospector introspector, SegmentedList values) where TIntrospector : struct, IIntervalIntrospector { var localIntrospector = introspector; @@ -73,7 +73,7 @@ public static FlatArrayIntervalTree CreateFromUnsorted(in TInt /// The list will be mutated as part of this operation. /// /// - public static FlatArrayIntervalTree CreateFromSorted(in TIntrospector introspector, SegmentedList values) + public static ImmutableIntervalTree CreateFromSorted(in TIntrospector introspector, SegmentedList values) where TIntrospector : struct, IIntervalIntrospector { #if DEBUG @@ -93,7 +93,7 @@ public static FlatArrayIntervalTree CreateFromSorted(in TIntro // Next, do a pass over the entire tree, updating each node to point at the max end node in its subtree. ComputeMaxEndNodes(array, 0, in introspector); - return new FlatArrayIntervalTree(array); + return new ImmutableIntervalTree(array); static void BuildCompleteTreeTop(SegmentedList source, SegmentedArray destination) { @@ -255,14 +255,14 @@ private static int GetRightChildIndex(int nodeIndex) => (2 * nodeIndex) + 2; bool IIntervalTree.Any(int start, int length, TestInterval testInterval, in TIntrospector introspector) - => IntervalTreeHelpers, /*TNode*/ int, FlatArrayIntervalTreeHelper>.Any(this, start, length, testInterval, in introspector); + => IntervalTreeHelpers, /*TNode*/ int, FlatArrayIntervalTreeHelper>.Any(this, start, length, testInterval, in introspector); int IIntervalTree.FillWithIntervalsThatMatch( int start, int length, TestInterval testInterval, ref TemporaryArray builder, in TIntrospector introspector, bool stopAfterFirst) { - return IntervalTreeHelpers, /*TNode*/ int, FlatArrayIntervalTreeHelper>.FillWithIntervalsThatMatch( + return IntervalTreeHelpers, /*TNode*/ int, FlatArrayIntervalTreeHelper>.FillWithIntervalsThatMatch( this, start, length, testInterval, ref builder, in introspector, stopAfterFirst); } @@ -270,32 +270,32 @@ IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public IEnumerator GetEnumerator() - => IntervalTreeHelpers, /*TNode*/ int, FlatArrayIntervalTreeHelper>.GetEnumerator(this); + => IntervalTreeHelpers, /*TNode*/ int, FlatArrayIntervalTreeHelper>.GetEnumerator(this); /// /// Wrapper type to allow the IntervalTreeHelpers type to work with this type. /// - private readonly struct FlatArrayIntervalTreeHelper : IIntervalTreeHelper, int> + private readonly struct FlatArrayIntervalTreeHelper : IIntervalTreeWitness, int> { - public T GetValue(FlatArrayIntervalTree tree, int node) + public T GetValue(ImmutableIntervalTree tree, int node) => tree._array[node].Value; - public int GetMaxEndNode(FlatArrayIntervalTree tree, int node) + public int GetMaxEndNode(ImmutableIntervalTree tree, int node) => tree._array[node].MaxEndNodeIndex; - public bool TryGetRoot(FlatArrayIntervalTree tree, out int root) + public bool TryGetRoot(ImmutableIntervalTree tree, out int root) { root = 0; return tree._array.Length > 0; } - public bool TryGetLeftNode(FlatArrayIntervalTree tree, int node, out int leftNode) + public bool TryGetLeftNode(ImmutableIntervalTree tree, int node, out int leftNode) { leftNode = GetLeftChildIndex(node); return leftNode < tree._array.Length; } - public bool TryGetRightNode(FlatArrayIntervalTree tree, int node, out int rightNode) + public bool TryGetRightNode(ImmutableIntervalTree tree, int node, out int rightNode) { rightNode = GetRightChildIndex(node); return rightNode < tree._array.Length; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/IntervalTreeHelpers.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/IntervalTreeHelpers.cs index 4f9e2a500aaea..e7729acd18bb1 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/IntervalTreeHelpers.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/IntervalTreeHelpers.cs @@ -10,7 +10,14 @@ namespace Microsoft.CodeAnalysis.Shared.Collections; -internal interface IIntervalTreeHelper +/// +/// Witness interface that allows transparent access to information about a specific +/// implementation without needing to know the specifics of that implementation. This allows to operate transparently over any +/// implementation. IntervalTreeHelpers constrains its TIntervalTreeWitness type to be a struct to ensure this can be +/// entirely reified and erased by the runtime. +/// +internal interface IIntervalTreeWitness where TIntervalTree : IIntervalTree { public bool TryGetRoot(TIntervalTree tree, [NotNullWhen(true)] out TNode? root); @@ -24,22 +31,22 @@ internal interface IIntervalTreeHelper /// /// Utility helpers used to allow code sharing for the different implementations of s. /// -internal static class IntervalTreeHelpers +internal static class IntervalTreeHelpers where TIntervalTree : IIntervalTree - where TIntervalTreeHelper : struct, IIntervalTreeHelper + where TIntervalTreeWitness : struct, IIntervalTreeWitness { private static readonly ObjectPool> s_nodeStackPool = new(() => new(), 128, trimOnFree: false); public static IEnumerator GetEnumerator(TIntervalTree tree) { - var helper = default(TIntervalTreeHelper); - if (!helper.TryGetRoot(tree, out var root)) + var witness = default(TIntervalTreeWitness); + if (!witness.TryGetRoot(tree, out var root)) return SpecializedCollections.EmptyEnumerator(); - return GetEnumeratorWorker(tree, helper, root); + return GetEnumeratorWorker(tree, witness, root); static IEnumerator GetEnumeratorWorker( - TIntervalTree tree, TIntervalTreeHelper helper, TNode root) + TIntervalTree tree, TIntervalTreeWitness witness, TNode root) { using var _ = s_nodeStackPool.GetPooledObject(out var stack); var currentNode = root; @@ -51,7 +58,7 @@ static IEnumerator GetEnumeratorWorker( while (currentNodeHasValue) { stack.Push(currentNode!); - currentNodeHasValue = helper.TryGetLeftNode(tree, currentNode!, out currentNode); + currentNodeHasValue = witness.TryGetLeftNode(tree, currentNode!, out currentNode); } Contract.ThrowIfTrue(currentNodeHasValue); @@ -60,10 +67,10 @@ static IEnumerator GetEnumeratorWorker( // We only get to a node once we've walked the left side of it. So we can now return the parent node at // that point. - yield return helper.GetValue(tree, currentNode); + yield return witness.GetValue(tree, currentNode); // now get the right side and set things up so we can walk into it. - currentNodeHasValue = helper.TryGetRightNode(tree, currentNode, out currentNode); + currentNodeHasValue = witness.TryGetRightNode(tree, currentNode, out currentNode); } } } @@ -76,9 +83,8 @@ public static int FillWithIntervalsThatMatch( bool stopAfterFirst) where TIntrospector : struct, IIntervalIntrospector { - var helper = default(TIntervalTreeHelper); - - if (!helper.TryGetRoot(tree, out var root)) + var witness = default(TIntervalTreeWitness); + if (!witness.TryGetRoot(tree, out var root)) return 0; using var _ = s_nodeStackPool.GetPooledObject(out var stack); @@ -94,7 +100,7 @@ public static int FillWithIntervalsThatMatch( while (currentNodeHasValue) { stack.Push(currentNode!); - currentNodeHasValue = helper.TryGetLeftNode(tree, currentNode!, out currentNode); + currentNodeHasValue = witness.TryGetLeftNode(tree, currentNode!, out currentNode); } Contract.ThrowIfTrue(currentNodeHasValue); @@ -104,7 +110,7 @@ public static int FillWithIntervalsThatMatch( // We only get to a node once we've walked the left side of it. So we can now process the parent node at // that point. - var currentNodeValue = helper.GetValue(tree, currentNode); + var currentNodeValue = witness.GetValue(tree, currentNode); if (testInterval(currentNodeValue, start, length, in introspector)) { matches++; @@ -115,7 +121,7 @@ public static int FillWithIntervalsThatMatch( } // now get the right side and set things up so we can walk into it. - currentNodeHasValue = helper.TryGetRightNode(tree, currentNode, out currentNode); + currentNodeHasValue = witness.TryGetRightNode(tree, currentNode, out currentNode); } return matches; @@ -126,8 +132,8 @@ public static bool Any(TIntervalTree tree, int start, int length, { // Inlined version of FillWithIntervalsThatMatch, optimized to do less work and stop once it finds a match. - var helper = default(TIntervalTreeHelper); - if (!helper.TryGetRoot(tree, out var root)) + var witness = default(TIntervalTreeWitness); + if (!witness.TryGetRoot(tree, out var root)) return false; using var _ = s_nodeStackPool.GetPooledObject(out var candidates); @@ -141,7 +147,7 @@ public static bool Any(TIntervalTree tree, int start, int length, // Check the nodes as we go down. That way we can stop immediately when we find something that matches, // instead of having to do an entire in-order walk, which might end up hitting a lot of nodes we don't care // about and placing a lot into the stack. - if (testInterval(helper.GetValue(tree, currentNode), start, length, in introspector)) + if (testInterval(witness.GetValue(tree, currentNode), start, length, in introspector)) return true; if (ShouldExamineRight(tree, start, end, currentNode, in introspector, out var right)) @@ -162,14 +168,14 @@ private static bool ShouldExamineRight( in TIntrospector introspector, [NotNullWhen(true)] out TNode? right) where TIntrospector : struct, IIntervalIntrospector { - var helper = default(TIntervalTreeHelper); + var witness = default(TIntervalTreeWitness); // right children's starts will never be to the left of the parent's start so we should consider right // subtree only if root's start overlaps with interval's End, - if (introspector.GetSpan(helper.GetValue(tree, currentNode)).Start <= end) + if (introspector.GetSpan(witness.GetValue(tree, currentNode)).Start <= end) { - if (helper.TryGetRightNode(tree, currentNode, out var rightNode) && - GetEnd(helper.GetValue(tree, helper.GetMaxEndNode(tree, rightNode)), in introspector) >= start) + if (witness.TryGetRightNode(tree, currentNode, out var rightNode) && + GetEnd(witness.GetValue(tree, witness.GetMaxEndNode(tree, rightNode)), in introspector) >= start) { right = rightNode; return true; @@ -187,11 +193,11 @@ private static bool ShouldExamineLeft( in TIntrospector introspector, [NotNullWhen(true)] out TNode? left) where TIntrospector : struct, IIntervalIntrospector { - var helper = default(TIntervalTreeHelper); + var witness = default(TIntervalTreeWitness); // only if left's maxVal overlaps with interval's start, we should consider // left subtree - if (helper.TryGetLeftNode(tree, currentNode, out left) && - GetEnd(helper.GetValue(tree, helper.GetMaxEndNode(tree, left)), in introspector) >= start) + if (witness.TryGetLeftNode(tree, currentNode, out left) && + GetEnd(witness.GetValue(tree, witness.GetMaxEndNode(tree, left)), in introspector) >= start) { return true; } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/IntervalTree`1.Node.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/IntervalTree`1.Node.cs index 264e31509ff40..e260aacc9ef8e 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/IntervalTree`1.Node.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/IntervalTree`1.Node.cs @@ -7,7 +7,7 @@ namespace Microsoft.CodeAnalysis.Shared.Collections; -internal partial class BinaryIntervalTree +internal partial class MutableIntervalTree { protected sealed class Node { diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/IntervalTree`1.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/IntervalTree`1.cs index 43bb3a2ebfd7d..a944fd074b26e 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/IntervalTree`1.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/IntervalTree`1.cs @@ -17,16 +17,16 @@ namespace Microsoft.CodeAnalysis.Shared.Collections; /// Ths is the root type for all interval trees that store their data in a binary tree format. This format is good for /// when mutation of the tree is expected, and a client wants to perform tests before and after such mutation. /// -internal partial class BinaryIntervalTree : IIntervalTree +internal partial class MutableIntervalTree : IIntervalTree { - public static readonly BinaryIntervalTree Empty = new(); + public static readonly MutableIntervalTree Empty = new(); protected Node? root; - public static BinaryIntervalTree Create(in TIntrospector introspector, IEnumerable values) + public static MutableIntervalTree Create(in TIntrospector introspector, IEnumerable values) where TIntrospector : struct, IIntervalIntrospector { - var result = new BinaryIntervalTree(); + var result = new MutableIntervalTree(); foreach (var value in values) result.root = Insert(result.root, new Node(value), in introspector); @@ -37,17 +37,17 @@ public static BinaryIntervalTree Create(in TIntrospector intro /// /// Provides access to lots of common algorithms on this interval tree. /// - public IntervalTreeAlgorithms> Algorithms => new(this); + public IntervalTreeAlgorithms> Algorithms => new(this); bool IIntervalTree.Any(int start, int length, TestInterval testInterval, in TIntrospector introspector) - => IntervalTreeHelpers, Node, BinaryIntervalTreeHelper>.Any(this, start, length, testInterval, in introspector); + => IntervalTreeHelpers, Node, BinaryIntervalTreeHelper>.Any(this, start, length, testInterval, in introspector); int IIntervalTree.FillWithIntervalsThatMatch( int start, int length, TestInterval testInterval, ref TemporaryArray builder, in TIntrospector introspector, bool stopAfterFirst) { - return IntervalTreeHelpers, Node, BinaryIntervalTreeHelper>.FillWithIntervalsThatMatch( + return IntervalTreeHelpers, Node, BinaryIntervalTreeHelper>.FillWithIntervalsThatMatch( this, start, length, testInterval, ref builder, in introspector, stopAfterFirst); } @@ -124,7 +124,7 @@ static int BalanceFactor(Node? node) } public IEnumerator GetEnumerator() - => IntervalTreeHelpers, Node, BinaryIntervalTreeHelper>.GetEnumerator(this); + => IntervalTreeHelpers, Node, BinaryIntervalTreeHelper>.GetEnumerator(this); IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator(); @@ -143,27 +143,27 @@ private static int Height(Node? node) /// /// Wrapper type to allow the IntervalTreeHelpers type to work with this type. /// - private readonly struct BinaryIntervalTreeHelper : IIntervalTreeHelper, Node> + private readonly struct BinaryIntervalTreeHelper : IIntervalTreeWitness, Node> { - public T GetValue(BinaryIntervalTree tree, Node node) + public T GetValue(MutableIntervalTree tree, Node node) => node.Value; - public Node GetMaxEndNode(BinaryIntervalTree tree, Node node) + public Node GetMaxEndNode(MutableIntervalTree tree, Node node) => node.MaxEndNode; - public bool TryGetRoot(BinaryIntervalTree tree, [NotNullWhen(true)] out Node? root) + public bool TryGetRoot(MutableIntervalTree tree, [NotNullWhen(true)] out Node? root) { root = tree.root; return root != null; } - public bool TryGetLeftNode(BinaryIntervalTree tree, Node node, [NotNullWhen(true)] out Node? leftNode) + public bool TryGetLeftNode(MutableIntervalTree tree, Node node, [NotNullWhen(true)] out Node? leftNode) { leftNode = node.Left; return leftNode != null; } - public bool TryGetRightNode(BinaryIntervalTree tree, Node node, [NotNullWhen(true)] out Node? rightNode) + public bool TryGetRightNode(MutableIntervalTree tree, Node node, [NotNullWhen(true)] out Node? rightNode) { rightNode = node.Right; return rightNode != null; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/SimpleIntervalTree.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/SimpleIntervalTree.cs index 632958fe10045..546e1551a56e8 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/SimpleIntervalTree.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/SimpleIntervalTree.cs @@ -8,15 +8,15 @@ namespace Microsoft.CodeAnalysis.Shared.Collections; internal class BinaryIntervalTree { - public static SimpleBinaryIntervalTree Create(in TIntrospector introspector, params T[] values) + public static SimpleMutableIntervalTree Create(in TIntrospector introspector, params T[] values) where TIntrospector : struct, IIntervalIntrospector { return Create(in introspector, (IEnumerable)values); } - public static SimpleBinaryIntervalTree Create(in TIntrospector introspector, IEnumerable? values = null) + public static SimpleMutableIntervalTree Create(in TIntrospector introspector, IEnumerable? values = null) where TIntrospector : struct, IIntervalIntrospector { - return new SimpleBinaryIntervalTree(in introspector, values); + return new SimpleMutableIntervalTree(in introspector, values); } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/SimpleIntervalTree`2.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/SimpleIntervalTree`2.cs index 7566a4b378e1b..fe1fd19c494f8 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/SimpleIntervalTree`2.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/SimpleIntervalTree`2.cs @@ -7,12 +7,12 @@ namespace Microsoft.CodeAnalysis.Shared.Collections; -internal class SimpleBinaryIntervalTree : BinaryIntervalTree +internal class SimpleMutableIntervalTree : MutableIntervalTree where TIntrospector : struct, IIntervalIntrospector { private readonly TIntrospector _introspector; - public SimpleBinaryIntervalTree(in TIntrospector introspector, IEnumerable? values) + public SimpleMutableIntervalTree(in TIntrospector introspector, IEnumerable? values) { _introspector = introspector; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/TextSpanIntervalIntrospector.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/TextSpanIntervalIntrospector.cs index 446ac010872b3..0c8647b4e755f 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/TextSpanIntervalIntrospector.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Collections/TextSpanIntervalIntrospector.cs @@ -13,14 +13,14 @@ public TextSpan GetSpan(TextSpan value) => value; } -internal sealed class TextSpanIntervalTree(IEnumerable? values) - : SimpleBinaryIntervalTree(new TextSpanIntervalIntrospector(), values) +internal sealed class TextSpanMutableIntervalTree(IEnumerable? values) + : SimpleMutableIntervalTree(new TextSpanIntervalIntrospector(), values) { - public TextSpanIntervalTree() : this(null) + public TextSpanMutableIntervalTree() : this(null) { } - public TextSpanIntervalTree(params TextSpan[]? values) : this((IEnumerable?)values) + public TextSpanMutableIntervalTree(params TextSpan[]? values) : this((IEnumerable?)values) { } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/AbstractSyntaxFormatting.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/AbstractSyntaxFormatting.cs index 22865e0751e08..8817da296f1b2 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/AbstractSyntaxFormatting.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/AbstractSyntaxFormatting.cs @@ -25,7 +25,7 @@ internal abstract class AbstractSyntaxFormatting : ISyntaxFormatting public abstract ImmutableArray GetDefaultFormattingRules(); - protected abstract IFormattingResult CreateAggregatedFormattingResult(SyntaxNode node, IList results, TextSpanIntervalTree? formattingSpans = null); + protected abstract IFormattingResult CreateAggregatedFormattingResult(SyntaxNode node, IList results, TextSpanMutableIntervalTree? formattingSpans = null); protected abstract AbstractFormattingResult Format(SyntaxNode node, SyntaxFormattingOptions options, ImmutableArray rules, SyntaxToken startToken, SyntaxToken endToken, CancellationToken cancellationToken); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/Context/FormattingContext.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/Context/FormattingContext.cs index 3d22b9e90d1da..c8b089dba4893 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/Context/FormattingContext.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/Context/FormattingContext.cs @@ -28,15 +28,15 @@ internal partial class FormattingContext // interval tree for inseparable regions (Span to indentation data) // due to dependencies, each region defined in the data can't be formatted independently. - private readonly ContextIntervalTree _relativeIndentationTree; + private readonly ContextMutableIntervalTree _relativeIndentationTree; // interval tree for each operations. // given a span in the tree, it returns data (indentation, anchor delta, etc) to be applied for the span - private readonly ContextIntervalTree _indentationTree; - private readonly ContextIntervalTree _suppressWrappingTree; - private readonly ContextIntervalTree _suppressSpacingTree; - private readonly ContextIntervalTree _suppressFormattingTree; - private readonly ContextIntervalTree _anchorTree; + private readonly ContextMutableIntervalTree _indentationTree; + private readonly ContextMutableIntervalTree _suppressWrappingTree; + private readonly ContextMutableIntervalTree _suppressSpacingTree; + private readonly ContextMutableIntervalTree _suppressFormattingTree; + private readonly ContextMutableIntervalTree _anchorTree; // anchor token to anchor data map. // unlike anchorTree that would return anchor data for given span in the tree, it will return @@ -62,13 +62,13 @@ public FormattingContext(AbstractFormatEngine engine, TokenStream tokenStream) _engine = engine; _tokenStream = tokenStream; - _relativeIndentationTree = new ContextIntervalTree(new FormattingContextIntervalIntrospector()); + _relativeIndentationTree = new ContextMutableIntervalTree(new FormattingContextIntervalIntrospector()); - _indentationTree = new ContextIntervalTree(new FormattingContextIntervalIntrospector()); - _suppressWrappingTree = new ContextIntervalTree(new SuppressIntervalIntrospector()); - _suppressSpacingTree = new ContextIntervalTree(new SuppressIntervalIntrospector()); - _suppressFormattingTree = new ContextIntervalTree(new SuppressIntervalIntrospector()); - _anchorTree = new ContextIntervalTree(new FormattingContextIntervalIntrospector()); + _indentationTree = new ContextMutableIntervalTree(new FormattingContextIntervalIntrospector()); + _suppressWrappingTree = new ContextMutableIntervalTree(new SuppressIntervalIntrospector()); + _suppressSpacingTree = new ContextMutableIntervalTree(new SuppressIntervalIntrospector()); + _suppressFormattingTree = new ContextMutableIntervalTree(new SuppressIntervalIntrospector()); + _anchorTree = new ContextMutableIntervalTree(new FormattingContextIntervalIntrospector()); } public void Initialize( @@ -408,7 +408,7 @@ public void AddAnchorIndentationOperation(AnchorIndentationOperation operation) } [Conditional("DEBUG")] - private static void DebugCheckEmpty(ContextIntervalTree tree, TextSpan textSpan) + private static void DebugCheckEmpty(ContextMutableIntervalTree tree, TextSpan textSpan) where TIntrospector : struct, IIntervalIntrospector { var intervals = tree.GetIntervalsThatContain(textSpan.Start, textSpan.Length); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/ContextIntervalTree.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/ContextIntervalTree.cs index 0e9673d9b2acb..8831efc680626 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/ContextIntervalTree.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/ContextIntervalTree.cs @@ -15,19 +15,19 @@ namespace Microsoft.CodeAnalysis.Formatting; /// it now has an ability to return a smallest span that contains a position rather than /// all Intersecting or overlapping spans /// -internal sealed class ContextIntervalTree : SimpleBinaryIntervalTree +internal sealed class ContextMutableIntervalTree : SimpleMutableIntervalTree where TIntrospector : struct, IIntervalIntrospector { private readonly Func _edgeExclusivePredicate; private readonly Func _edgeInclusivePredicate; private readonly Func _containPredicate; - public ContextIntervalTree(in TIntrospector introspector) + public ContextMutableIntervalTree(in TIntrospector introspector) : base(introspector, values: null) { _edgeExclusivePredicate = ContainsEdgeExclusive; _edgeInclusivePredicate = ContainsEdgeInclusive; - _containPredicate = (value, start, end) => IntervalTreeAlgorithms>.Contains(value, start, end, in Introspector); + _containPredicate = (value, start, end) => IntervalTreeAlgorithms>.Contains(value, start, end, in Introspector); } public T? GetSmallestEdgeExclusivelyContainingInterval(int start, int length) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/Engine/AbstractAggregatedFormattingResult.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/Engine/AbstractAggregatedFormattingResult.cs index 7c65bd9a28fc0..4253c2f4d7cca 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/Engine/AbstractAggregatedFormattingResult.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/Engine/AbstractAggregatedFormattingResult.cs @@ -19,7 +19,7 @@ internal abstract class AbstractAggregatedFormattingResult : IFormattingResult protected readonly SyntaxNode Node; private readonly IList _formattingResults; - private readonly TextSpanIntervalTree? _formattingSpans; + private readonly TextSpanMutableIntervalTree? _formattingSpans; private readonly CancellableLazy> _lazyTextChanges; private readonly CancellableLazy _lazyNode; @@ -27,7 +27,7 @@ internal abstract class AbstractAggregatedFormattingResult : IFormattingResult public AbstractAggregatedFormattingResult( SyntaxNode node, IList formattingResults, - TextSpanIntervalTree? formattingSpans) + TextSpanMutableIntervalTree? formattingSpans) { Contract.ThrowIfNull(node); Contract.ThrowIfNull(formattingResults); @@ -45,8 +45,8 @@ public AbstractAggregatedFormattingResult( /// protected abstract SyntaxNode Rewriter(Dictionary, TriviaData> changeMap, CancellationToken cancellationToken); - protected TextSpanIntervalTree GetFormattingSpans() - => _formattingSpans ?? new TextSpanIntervalTree(_formattingResults.Select(r => r.FormattedSpan)); + protected TextSpanMutableIntervalTree GetFormattingSpans() + => _formattingSpans ?? new TextSpanMutableIntervalTree(_formattingResults.Select(r => r.FormattedSpan)); #region IFormattingResult implementation diff --git a/src/Workspaces/VisualBasic/Portable/CodeCleanup/Providers/AbstractTokensCodeCleanupProvider.vb b/src/Workspaces/VisualBasic/Portable/CodeCleanup/Providers/AbstractTokensCodeCleanupProvider.vb index 347e0bbf05bdc..b2e712e8018a5 100644 --- a/src/Workspaces/VisualBasic/Portable/CodeCleanup/Providers/AbstractTokensCodeCleanupProvider.vb +++ b/src/Workspaces/VisualBasic/Portable/CodeCleanup/Providers/AbstractTokensCodeCleanupProvider.vb @@ -35,7 +35,7 @@ Namespace Microsoft.CodeAnalysis.CodeCleanup.Providers Protected MustInherit Class Rewriter Inherits VisualBasicSyntaxRewriter - Protected ReadOnly _spans As TextSpanIntervalTree + Protected ReadOnly _spans As TextSpanMutableIntervalTree Protected ReadOnly _cancellationToken As CancellationToken ' a global state indicating whether the visitor is visiting structured trivia or not @@ -46,7 +46,7 @@ Namespace Microsoft.CodeAnalysis.CodeCleanup.Providers MyBase.New(visitIntoStructuredTrivia:=True) _cancellationToken = cancellationToken - _spans = New TextSpanIntervalTree(spans) + _spans = New TextSpanMutableIntervalTree(spans) _underStructuredTrivia = False End Sub diff --git a/src/Workspaces/VisualBasic/Portable/CodeCleanup/Providers/NormalizeModifiersOrOperatorsCodeCleanupProvider.vb b/src/Workspaces/VisualBasic/Portable/CodeCleanup/Providers/NormalizeModifiersOrOperatorsCodeCleanupProvider.vb index 1ff9275c8e7e0..b0f318fcfcaf2 100644 --- a/src/Workspaces/VisualBasic/Portable/CodeCleanup/Providers/NormalizeModifiersOrOperatorsCodeCleanupProvider.vb +++ b/src/Workspaces/VisualBasic/Portable/CodeCleanup/Providers/NormalizeModifiersOrOperatorsCodeCleanupProvider.vb @@ -71,7 +71,7 @@ Namespace Microsoft.CodeAnalysis.CodeCleanup.Providers {SyntaxKind.LessThanEqualsToken, New List(Of SyntaxKind) From {SyntaxKind.EqualsToken, SyntaxKind.LessThanToken}} } - Private ReadOnly _spans As TextSpanIntervalTree + Private ReadOnly _spans As TextSpanMutableIntervalTree Private ReadOnly _cancellationToken As CancellationToken Shared Sub New() @@ -81,7 +81,7 @@ Namespace Microsoft.CodeAnalysis.CodeCleanup.Providers Public Sub New(spans As ImmutableArray(Of TextSpan), cancellationToken As CancellationToken) MyBase.New(visitIntoStructuredTrivia:=True) - _spans = New TextSpanIntervalTree(spans) + _spans = New TextSpanMutableIntervalTree(spans) _cancellationToken = cancellationToken End Sub diff --git a/src/Workspaces/VisualBasic/Portable/Formatting/Engine/AggregatedFormattingResult.vb b/src/Workspaces/VisualBasic/Portable/Formatting/Engine/AggregatedFormattingResult.vb index 6ea621447d76b..18aeb9d68ef7e 100644 --- a/src/Workspaces/VisualBasic/Portable/Formatting/Engine/AggregatedFormattingResult.vb +++ b/src/Workspaces/VisualBasic/Portable/Formatting/Engine/AggregatedFormattingResult.vb @@ -12,7 +12,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting Inherits AbstractAggregatedFormattingResult Implements IFormattingResult - Public Sub New(node As SyntaxNode, results As IList(Of AbstractFormattingResult), formattingSpans As TextSpanIntervalTree) + Public Sub New(node As SyntaxNode, results As IList(Of AbstractFormattingResult), formattingSpans As TextSpanMutableIntervalTree) MyBase.New(node, results, formattingSpans) End Sub diff --git a/src/Workspaces/VisualBasic/Portable/Formatting/Engine/FormattingResult.vb b/src/Workspaces/VisualBasic/Portable/Formatting/Engine/FormattingResult.vb index 115fd42de299d..1ef2726a4b76f 100644 --- a/src/Workspaces/VisualBasic/Portable/Formatting/Engine/FormattingResult.vb +++ b/src/Workspaces/VisualBasic/Portable/Formatting/Engine/FormattingResult.vb @@ -23,7 +23,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting End Sub Protected Overrides Function Rewriter(changeMap As Dictionary(Of ValueTuple(Of SyntaxToken, SyntaxToken), TriviaData), cancellationToken As CancellationToken) As SyntaxNode - Dim triviaRewriter = New TriviaDataFactory.TriviaRewriter(Me.TreeInfo.Root, New TextSpanIntervalTree(Me.FormattedSpan), changeMap, cancellationToken) + Dim triviaRewriter = New TriviaDataFactory.TriviaRewriter(Me.TreeInfo.Root, New TextSpanMutableIntervalTree(Me.FormattedSpan), changeMap, cancellationToken) Return triviaRewriter.Transform() End Function End Class diff --git a/src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.TriviaRewriter.vb b/src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.TriviaRewriter.vb index 0dc158f289b53..d9aa766a0f533 100644 --- a/src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.TriviaRewriter.vb +++ b/src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.TriviaRewriter.vb @@ -13,14 +13,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting Inherits VisualBasicSyntaxRewriter Private ReadOnly _node As SyntaxNode - Private ReadOnly _spans As TextSpanIntervalTree + Private ReadOnly _spans As TextSpanMutableIntervalTree Private ReadOnly _lastToken As SyntaxToken Private ReadOnly _cancellationToken As CancellationToken Private ReadOnly _trailingTriviaMap As Dictionary(Of SyntaxToken, SyntaxTriviaList) Private ReadOnly _leadingTriviaMap As Dictionary(Of SyntaxToken, SyntaxTriviaList) - Public Sub New(node As SyntaxNode, spanToFormat As TextSpanIntervalTree, map As Dictionary(Of ValueTuple(Of SyntaxToken, SyntaxToken), TriviaData), cancellationToken As CancellationToken) + Public Sub New(node As SyntaxNode, spanToFormat As TextSpanMutableIntervalTree, map As Dictionary(Of ValueTuple(Of SyntaxToken, SyntaxToken), TriviaData), cancellationToken As CancellationToken) Contract.ThrowIfNull(node) Contract.ThrowIfNull(map) diff --git a/src/Workspaces/VisualBasic/Portable/Formatting/VisualBasicSyntaxFormatting.vb b/src/Workspaces/VisualBasic/Portable/Formatting/VisualBasicSyntaxFormatting.vb index 598ce18a2d40b..9ab542e29c0ce 100644 --- a/src/Workspaces/VisualBasic/Portable/Formatting/VisualBasicSyntaxFormatting.vb +++ b/src/Workspaces/VisualBasic/Portable/Formatting/VisualBasicSyntaxFormatting.vb @@ -39,7 +39,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting Return New VisualBasicSyntaxFormattingOptions(options, DirectCast(fallbackOptions, VisualBasicSyntaxFormattingOptions)) End Function - Protected Overrides Function CreateAggregatedFormattingResult(node As SyntaxNode, results As IList(Of AbstractFormattingResult), Optional formattingSpans As TextSpanIntervalTree = Nothing) As IFormattingResult + Protected Overrides Function CreateAggregatedFormattingResult(node As SyntaxNode, results As IList(Of AbstractFormattingResult), Optional formattingSpans As TextSpanMutableIntervalTree = Nothing) As IFormattingResult Return New AggregatedFormattingResult(node, results, formattingSpans) End Function