diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 28aa783..87059be 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,22 +3,25 @@ "isRoot": true, "tools": { "dotnet-reportgenerator-globaltool": { - "version": "5.3.5", + "version": "5.3.11", "commands": [ "reportgenerator" - ] + ], + "rollForward": false }, "dotnet-config": { - "version": "1.0.6", + "version": "1.2.0", "commands": [ "dotnet-config" - ] + ], + "rollForward": false }, "dotnet-stryker": { - "version": "4.0.6", + "version": "4.3.0", "commands": [ "dotnet-stryker" - ] + ], + "rollForward": false } } } \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props index 1cc0fb6..c465bcc 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,9 +1,9 @@ - - - - + + + + @@ -11,11 +11,11 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -26,8 +26,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -36,7 +36,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/src/OffDotNet.CodeAnalysis.Pdf/packages.lock.json b/src/OffDotNet.CodeAnalysis.Pdf/packages.lock.json index fb42a09..4c6556c 100644 --- a/src/OffDotNet.CodeAnalysis.Pdf/packages.lock.json +++ b/src/OffDotNet.CodeAnalysis.Pdf/packages.lock.json @@ -4,27 +4,27 @@ "net8.0": { "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Direct", - "requested": "[8.0.1, )", - "resolved": "8.0.1", - "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "+6f2qv2a3dLwd5w6JanPIPs47CxRbnk+ZocMJUhv9NxP88VlOcJYZs9jY+MYSjxvady08bUZn6qgiNh7DadGgg==" }, "Microsoft.Extensions.ObjectPool": { "type": "Direct", - "requested": "[8.0.7, )", - "resolved": "8.0.7", - "contentHash": "2yLweyqmpuuFSRo+I3sLHMxmnAgNcI537kBJiyv49U2ZEqo00jZcG8lrnD8uCiOJp9IklYyTZULtbsXoFVzsjQ==" + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "UbsU/gYe4nv1DeqMXIVzDfNNek7Sk2kKuAOXL/Y+sLcAR0HwFUqzg1EPiU88jeHNe0g81aPvvHbvHarQr3r9IA==" }, "Roslynator.Analyzers": { "type": "Direct", - "requested": "[4.12.4, )", - "resolved": "4.12.4", - "contentHash": "isl8hAh7yFNjyBEC4YlTSi+xGBblqBUC/2MCMmnBPwuXPewb7XYnMRzT3vXbP/gOGwT8hZUOy1g/aRH3lAF/NQ==" + "requested": "[4.12.9, )", + "resolved": "4.12.9", + "contentHash": "X6lDpN/D5wuinq37KIx+l3GSUe9No+8bCjGBTI5sEEtxapLztkHg6gzNVhMXpXw8P+/5gFYxTXJ5Pf8O4iNz/w==" }, "SonarAnalyzer.CSharp": { "type": "Direct", - "requested": "[9.30.0.95878, )", - "resolved": "9.30.0.95878", - "contentHash": "P0DylTJphECGE9HD6yho7rb6qs2WTTW36QUu5ezGRJeZpq8ItlRLmzUpxNHVOaudJywcnKO1DdRyZSaU7LXOcA==" + "requested": "[9.32.0.97167, )", + "resolved": "9.32.0.97167", + "contentHash": "Yxk86RV+8ynJpUhku1Yw2hITFmnmXKkXJ73cIFSy85ol5SnWREQg9RuTyV8nI7V7+pyLKpCfRmD7P0widsgjkg==" }, "StyleCop.Analyzers": { "type": "Direct", @@ -37,57 +37,63 @@ }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Transitive", - "resolved": "8.0.1", - "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", + "resolved": "9.0.0", + "contentHash": "g0UfujELzlLbHoVG8kPKVBaW470Ewi+jnptGS9KUi6jcb+k2StujtK3m26DFSGGwQ/+bVgZfsWqNzlP6YOejvw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0", + "System.Diagnostics.DiagnosticSource": "9.0.0" } }, "Microsoft.Extensions.Options": { "type": "Transitive", - "resolved": "8.0.2", - "contentHash": "dWGKvhFybsaZpGmzkGCbNNwBD1rVlWzrZKANLW/CcbFJpCEceMCGzT7zZwHOGBCbwM0SzBuceMj5HN1LKV1QqA==", + "resolved": "9.0.0", + "contentHash": "y2146b3jrPI3Q0lokKXdKLpmXqakYbDIPDV6r3M8SqvSf45WwOTzkyfDpxnZXJsJQEpAsAqjUq5Pu8RCJMjubg==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", - "Microsoft.Extensions.Primitives": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0", + "Microsoft.Extensions.Primitives": "9.0.0" } }, "Microsoft.Extensions.Primitives": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g==" + "resolved": "9.0.0", + "contentHash": "N3qEBzmLMYiASUlKxxFIISP4AiwuPTHF5uCh+2CWSwwzAJiIYx0kBJsS30cp1nvhSySFAVi30jecD307jV+8Kg==" }, "StyleCop.Analyzers.Unstable": { "type": "Transitive", "resolved": "1.2.0.556", "contentHash": "zvn9Mqs/ox/83cpYPignI8hJEM2A93s2HkHs8HYMOAQW0PkampyoErAiIyKxgTLqbbad29HX/shv/6LGSjPJNQ==" }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "9.0.0", + "contentHash": "ddppcFpnbohLWdYKr/ZeLZHmmI+DXFgZ3Snq+/E7SwcdW4UnvxmaugkwGywvGVWkHPGCSZjCP+MLzu23AL5SDw==" + }, "offdotnet.codeanalysis": { "type": "Project", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "[8.0.1, )", - "Microsoft.Extensions.Localization": "[8.0.7, )", - "Microsoft.Extensions.Localization.Abstractions": "[8.0.7, )", - "Microsoft.Extensions.ObjectPool": "[8.0.7, )" + "Microsoft.Extensions.DependencyInjection.Abstractions": "[9.0.0, )", + "Microsoft.Extensions.Localization": "[9.0.0, )", + "Microsoft.Extensions.Localization.Abstractions": "[9.0.0, )", + "Microsoft.Extensions.ObjectPool": "[9.0.0, )" } }, "Microsoft.Extensions.Localization": { "type": "CentralTransitive", - "requested": "[8.0.7, )", - "resolved": "8.0.7", - "contentHash": "kdI24IfC1Jk3zfhWvYmuzvkzuKp+5Shjmfq0vk6EKBB+Udt4Gu1SkVSkMWJkYZFag+ndd+sTroUKDC/sud/DYQ==", + "requested": "[8.0.10, )", + "resolved": "9.0.0", + "contentHash": "Up8Juy8Bh+vL+fXmMWsoSg/G6rszmLFiF44aI2tpOMJE7Ln4D9s37YxOOm81am4Z+V7g8Am3AgVwHYJzi+cL/g==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1", - "Microsoft.Extensions.Localization.Abstractions": "8.0.7", - "Microsoft.Extensions.Logging.Abstractions": "8.0.1", - "Microsoft.Extensions.Options": "8.0.2" + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0", + "Microsoft.Extensions.Localization.Abstractions": "9.0.0", + "Microsoft.Extensions.Logging.Abstractions": "9.0.0", + "Microsoft.Extensions.Options": "9.0.0" } }, "Microsoft.Extensions.Localization.Abstractions": { "type": "CentralTransitive", - "requested": "[8.0.7, )", - "resolved": "8.0.7", - "contentHash": "uCsxqBBJEsSoV52tX/v+bxxN0e1O8WYIRR7tmcEmVVkRSX+0k4ZJcaL79ddus+0HIm3ssjV/dJk56XufDrGDqg==" + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "wc7PaRhPOnio5Csj80b3UgBWA5l6bp28EhGem7gtfpVopcwbkfPb2Sk8Cu6eBnIW3ZNf1YUgYJzwtjzZEM8+iw==" } } } diff --git a/src/OffDotNet.CodeAnalysis/Lexer/ITextCursor.cs b/src/OffDotNet.CodeAnalysis/Lexer/ITextCursor.cs index bba4621..a7ddc65 100644 --- a/src/OffDotNet.CodeAnalysis/Lexer/ITextCursor.cs +++ b/src/OffDotNet.CodeAnalysis/Lexer/ITextCursor.cs @@ -7,109 +7,69 @@ namespace OffDotNet.CodeAnalysis.Lexer; using Utils; -/// Represents a text cursor for navigating and processing text data. -/// -/// -/// SLIDING position -/// WINDOW | -/// -------- + -------- -/// | | -/// basis =======>> offset -/// | | -/// ------------------------------- -/// SRC: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | -/// ------------------------------- -/// | | -/// basis ==>> offset -/// | | -/// ---- + ---- -/// LEXEME | -/// SUB-WINDOW position -/// -/// +/// public interface ITextCursor : IDisposable { - /// Gets the source text. + /// ISourceText SourceText { get; } - /// - /// Gets the current byte at the cursor position. - /// + /// Option Current { get; } - /// - /// Gets a value indicating whether the cursor is at the end of the text. - /// + /// bool IsAtEnd { get; } - /// Gets the start offset inside the window (relative to the start). + /// int WindowStart { get; } - /// Gets the end offset inside the window (relative to the ). + /// int Offset { get; } - /// Gets the absolute position in the . + /// int Position => WindowStart + Offset; - /// Gets a value indicating whether the window is in parsing lexeme mode. + /// bool IsLexemeMode { get; } - /// Gets the lexeme start offset relative to the window start. + /// int LexemeStart { get; } - /// Gets the absolute position of the lexeme in the . + /// int LexemePosition => WindowStart + LexemeStart; - /// Gets the width of the lexeme. + /// int LexemeWidth => Offset - LexemeStart; - /// Gets the text window. + /// ReadOnlyMemory Window { get; } - /// Gets the number of characters in the window. + /// int WindowSize { get; } - /// - /// Peeks at the byte at the specified delta from the current position. - /// - /// The delta from the current position. - /// The byte at the specified delta if available; otherwise, . - Option Peek(int delta = 0); - - /// - /// Advances the cursor by the specified delta. - /// - /// The delta by which to advance the cursor. + /// + Option Peek(); + + /// + Option Peek(int delta); + + /// void Advance(int delta = 1); - /// - /// Advances the cursor while the specified predicate is true. - /// - /// The predicate to test each byte against. + /// void Advance(Predicate predicate); - /// - /// Tries to advance the cursor if the current byte matches the specified byte. - /// - /// The byte to match against. - /// True if the cursor was advanced; otherwise, false. + /// bool TryAdvance(byte b); - /// - /// Tries to advance the cursor if the subsequent bytes match the specified subtext. - /// - /// The subtext to match against. - /// True if the cursor was advanced; otherwise, false. + /// bool TryAdvance(ReadOnlySpan subtext); - /// Slides the text window to the specified start position and size. - /// The start position of the window. - /// The size of the window. + /// void SlideTextWindow(int windowStart = -1, int windowSize = -1); - /// Starts parsing a lexeme and sets the to the current value. + /// public void StartLexemeMode(); - /// Stops parsing a lexeme. + /// public void StopLexemeMode(); } diff --git a/src/OffDotNet.CodeAnalysis/Lexer/TextCursor.cs b/src/OffDotNet.CodeAnalysis/Lexer/TextCursor.cs index bac2bef..20b3f25 100644 --- a/src/OffDotNet.CodeAnalysis/Lexer/TextCursor.cs +++ b/src/OffDotNet.CodeAnalysis/Lexer/TextCursor.cs @@ -12,21 +12,21 @@ namespace OffDotNet.CodeAnalysis.Lexer; /// Represents a text cursor for navigating and processing text data. /// /// -/// SLIDING position -/// WINDOW | -/// -------- + -------- -/// | | -/// basis =======>> offset -/// | | +/// SLIDING position +/// WINDOW | +/// ------ size ------ +/// | | +/// start =======>> offset +/// | | /// ------------------------------- -/// SRC: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +/// TXT: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | /// ------------------------------- -/// | | -/// basis ==>> offset -/// | | -/// ---- + ---- -/// LEXEME | -/// SUB-WINDOW position +/// | | | +/// | start | +/// | | | +/// - position | width - +/// LEXEME +/// SUB-WINDOW /// /// internal sealed class TextCursor : ITextCursor @@ -82,20 +82,25 @@ public TextCursor(in ISourceText text, IOptions options) /// Gets the number of valid characters in the text window. public int WindowSize { get; private set; } + /// Peeks at the byte at the specified delta from the current position. + /// The byte at the specified delta if available; otherwise, . + public Option Peek() + { + return !HasMoreBytes() ? Option.None : _characterWindowMemoryOwner.Memory.Span[Offset]; + } + /// Peeks at the byte at the specified delta from the current position. /// The delta from the current position. /// The byte at the specified delta if available; otherwise, . - public Option Peek(int delta = 0) + public Option Peek(int delta) { Debug.Assert(delta >= 0, "Delta should be positive"); - var windowStart = WindowStart; - var offset = Offset; + var position = Position; Advance(delta); var b = !HasMoreBytes() ? Option.None : _characterWindowMemoryOwner.Memory.Span[Offset]; - SlideTextWindow(windowStart); - Advance(offset); + SlideTextWindow(position); return b; } @@ -153,38 +158,9 @@ public bool TryAdvance(ReadOnlySpan subtext) /// The size of the window. public void SlideTextWindow(int windowStart = -1, int windowSize = -1) { - if (windowStart < 0) - return; - - if (windowStart >= SourceText.Length) - return; - - // do not slide the window if the window start and size are the same - if (windowStart == WindowStart && windowSize == WindowSize) - return; - - if (windowSize >= 0) - { - var oldCharacterWindowMemoryOwner = _characterWindowMemoryOwner; - - // the new memory owner size is not guaranteed to match the requested window size as it is rounded up to the nearest power of 2 - _characterWindowMemoryOwner = MemoryPool.Shared.Rent(windowSize); - var newWindowSize = Math.Min(windowSize, WindowSize); - oldCharacterWindowMemoryOwner.Memory.Span[..newWindowSize].CopyTo(_characterWindowMemoryOwner.Memory.Span); - oldCharacterWindowMemoryOwner.Dispose(); - } - - var count = Math.Min(SourceText.Length - windowStart, _characterWindowMemoryOwner.Memory.Span.Length); - - if (count > 0) - { - SourceText.CopyTo(windowStart, _characterWindowMemoryOwner.Memory.Span, 0, count); - } - - Offset = 0; - WindowStart = windowStart; - WindowSize = count; - StopLexemeMode(); + ChangeWindowSize(windowSize); + ChangeWindowStart(windowStart); + AdjustTextWindowCursors(windowStart); } /// Starts parsing a lexeme and sets the to the current value. @@ -215,7 +191,79 @@ private bool HasMoreBytes() if (Position >= SourceText.Length) return false; - SlideTextWindow(Position); + if (IsLexemeMode) + { + // grow the window to include the entire lexeme + var offset = Offset; + var size = WindowSize == 0 ? _characterWindowMemoryOwner.Memory.Span.Length : WindowSize; + var windowSize = size * 2; + + SlideTextWindow(WindowStart, windowSize); + Offset = offset; + } + else + { + SlideTextWindow(Position); + } + return WindowSize > 0; } + + private void ChangeWindowSize(int windowSize) + { + if (windowSize < 0) + return; + + if (windowSize == WindowSize) + return; + + // the new memory owner size is not guaranteed to match the requested window size as it is rounded up to the nearest power of 2 + var newCharacterWindowMemoryOwner = MemoryPool.Shared.Rent(windowSize); + var oldCharacterWindowMemoryOwner = _characterWindowMemoryOwner; + + var newWindowSize = Math.Min(windowSize, WindowSize); + oldCharacterWindowMemoryOwner.Memory.Span[..newWindowSize].CopyTo(newCharacterWindowMemoryOwner.Memory.Span); + oldCharacterWindowMemoryOwner.Dispose(); + + _characterWindowMemoryOwner = newCharacterWindowMemoryOwner; + } + + private void ChangeWindowStart(int windowStart) + { + if (windowStart < 0) + return; + + if (windowStart >= SourceText.Length) + return; + + var windowSpan = _characterWindowMemoryOwner.Memory.Span; + var count = Math.Min(SourceText.Length - windowStart, windowSpan.Length); + + if (count > 0) + { + SourceText.CopyTo(windowStart, windowSpan, 0, count); + } + + WindowStart = windowStart; + WindowSize = count; + } + + private void AdjustTextWindowCursors(int windowStart) + { + var windowStartChanged = windowStart != WindowStart; + var relative = windowStart - WindowStart; + var isRelativeWithinBounds = relative >= 0 && relative <= WindowSize; + + if (windowStartChanged || Offset >= WindowSize) + { + Offset = 0; + StopLexemeMode(); + return; + } + + if (isRelativeWithinBounds && relative != Offset) + { + Offset = relative; + } + } } diff --git a/src/OffDotNet.CodeAnalysis/Utils/Option.cs b/src/OffDotNet.CodeAnalysis/Utils/Option.cs index cf47f54..7b08acf 100644 --- a/src/OffDotNet.CodeAnalysis/Utils/Option.cs +++ b/src/OffDotNet.CodeAnalysis/Utils/Option.cs @@ -63,7 +63,20 @@ public bool TryGetValue([MaybeNullWhen(false)] out T value) /// Returns a string that represents the current option. /// A string that represents the current option. - public override string ToString() => IsSome ? $"Some({_value})" : "None"; + public override string ToString() + { + if (!IsSome) + { + return "None"; + } + + if (_value is byte b) + { + return $"Some('{Convert.ToChar(b)}' | 0x{b:X})"; + } + + return $"Some({_value})"; + } private string DebuggerDisplay() => ToString(); } diff --git a/src/OffDotNet.CodeAnalysis/packages.lock.json b/src/OffDotNet.CodeAnalysis/packages.lock.json index b26b2c1..505c039 100644 --- a/src/OffDotNet.CodeAnalysis/packages.lock.json +++ b/src/OffDotNet.CodeAnalysis/packages.lock.json @@ -4,45 +4,45 @@ "net8.0": { "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "Direct", - "requested": "[8.0.1, )", - "resolved": "8.0.1", - "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "+6f2qv2a3dLwd5w6JanPIPs47CxRbnk+ZocMJUhv9NxP88VlOcJYZs9jY+MYSjxvady08bUZn6qgiNh7DadGgg==" }, "Microsoft.Extensions.Localization": { "type": "Direct", - "requested": "[8.0.7, )", - "resolved": "8.0.7", - "contentHash": "kdI24IfC1Jk3zfhWvYmuzvkzuKp+5Shjmfq0vk6EKBB+Udt4Gu1SkVSkMWJkYZFag+ndd+sTroUKDC/sud/DYQ==", + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "Up8Juy8Bh+vL+fXmMWsoSg/G6rszmLFiF44aI2tpOMJE7Ln4D9s37YxOOm81am4Z+V7g8Am3AgVwHYJzi+cL/g==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1", - "Microsoft.Extensions.Localization.Abstractions": "8.0.7", - "Microsoft.Extensions.Logging.Abstractions": "8.0.1", - "Microsoft.Extensions.Options": "8.0.2" + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0", + "Microsoft.Extensions.Localization.Abstractions": "9.0.0", + "Microsoft.Extensions.Logging.Abstractions": "9.0.0", + "Microsoft.Extensions.Options": "9.0.0" } }, "Microsoft.Extensions.Localization.Abstractions": { "type": "Direct", - "requested": "[8.0.7, )", - "resolved": "8.0.7", - "contentHash": "uCsxqBBJEsSoV52tX/v+bxxN0e1O8WYIRR7tmcEmVVkRSX+0k4ZJcaL79ddus+0HIm3ssjV/dJk56XufDrGDqg==" + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "wc7PaRhPOnio5Csj80b3UgBWA5l6bp28EhGem7gtfpVopcwbkfPb2Sk8Cu6eBnIW3ZNf1YUgYJzwtjzZEM8+iw==" }, "Microsoft.Extensions.ObjectPool": { "type": "Direct", - "requested": "[8.0.7, )", - "resolved": "8.0.7", - "contentHash": "2yLweyqmpuuFSRo+I3sLHMxmnAgNcI537kBJiyv49U2ZEqo00jZcG8lrnD8uCiOJp9IklYyTZULtbsXoFVzsjQ==" + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "UbsU/gYe4nv1DeqMXIVzDfNNek7Sk2kKuAOXL/Y+sLcAR0HwFUqzg1EPiU88jeHNe0g81aPvvHbvHarQr3r9IA==" }, "Roslynator.Analyzers": { "type": "Direct", - "requested": "[4.12.4, )", - "resolved": "4.12.4", - "contentHash": "isl8hAh7yFNjyBEC4YlTSi+xGBblqBUC/2MCMmnBPwuXPewb7XYnMRzT3vXbP/gOGwT8hZUOy1g/aRH3lAF/NQ==" + "requested": "[4.12.9, )", + "resolved": "4.12.9", + "contentHash": "X6lDpN/D5wuinq37KIx+l3GSUe9No+8bCjGBTI5sEEtxapLztkHg6gzNVhMXpXw8P+/5gFYxTXJ5Pf8O4iNz/w==" }, "SonarAnalyzer.CSharp": { "type": "Direct", - "requested": "[9.30.0.95878, )", - "resolved": "9.30.0.95878", - "contentHash": "P0DylTJphECGE9HD6yho7rb6qs2WTTW36QUu5ezGRJeZpq8ItlRLmzUpxNHVOaudJywcnKO1DdRyZSaU7LXOcA==" + "requested": "[9.32.0.97167, )", + "resolved": "9.32.0.97167", + "contentHash": "Yxk86RV+8ynJpUhku1Yw2hITFmnmXKkXJ73cIFSy85ol5SnWREQg9RuTyV8nI7V7+pyLKpCfRmD7P0widsgjkg==" }, "StyleCop.Analyzers": { "type": "Direct", @@ -55,30 +55,36 @@ }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Transitive", - "resolved": "8.0.1", - "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", + "resolved": "9.0.0", + "contentHash": "g0UfujELzlLbHoVG8kPKVBaW470Ewi+jnptGS9KUi6jcb+k2StujtK3m26DFSGGwQ/+bVgZfsWqNzlP6YOejvw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0", + "System.Diagnostics.DiagnosticSource": "9.0.0" } }, "Microsoft.Extensions.Options": { "type": "Transitive", - "resolved": "8.0.2", - "contentHash": "dWGKvhFybsaZpGmzkGCbNNwBD1rVlWzrZKANLW/CcbFJpCEceMCGzT7zZwHOGBCbwM0SzBuceMj5HN1LKV1QqA==", + "resolved": "9.0.0", + "contentHash": "y2146b3jrPI3Q0lokKXdKLpmXqakYbDIPDV6r3M8SqvSf45WwOTzkyfDpxnZXJsJQEpAsAqjUq5Pu8RCJMjubg==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", - "Microsoft.Extensions.Primitives": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0", + "Microsoft.Extensions.Primitives": "9.0.0" } }, "Microsoft.Extensions.Primitives": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g==" + "resolved": "9.0.0", + "contentHash": "N3qEBzmLMYiASUlKxxFIISP4AiwuPTHF5uCh+2CWSwwzAJiIYx0kBJsS30cp1nvhSySFAVi30jecD307jV+8Kg==" }, "StyleCop.Analyzers.Unstable": { "type": "Transitive", "resolved": "1.2.0.556", "contentHash": "zvn9Mqs/ox/83cpYPignI8hJEM2A93s2HkHs8HYMOAQW0PkampyoErAiIyKxgTLqbbad29HX/shv/6LGSjPJNQ==" + }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "9.0.0", + "contentHash": "ddppcFpnbohLWdYKr/ZeLZHmmI+DXFgZ3Snq+/E7SwcdW4UnvxmaugkwGywvGVWkHPGCSZjCP+MLzu23AL5SDw==" } } } diff --git a/tests/OffDotNet.CodeAnalysis.Pdf.Tests/packages.lock.json b/tests/OffDotNet.CodeAnalysis.Pdf.Tests/packages.lock.json index 73fbc85..152804b 100644 --- a/tests/OffDotNet.CodeAnalysis.Pdf.Tests/packages.lock.json +++ b/tests/OffDotNet.CodeAnalysis.Pdf.Tests/packages.lock.json @@ -10,19 +10,19 @@ }, "Microsoft.NET.Test.Sdk": { "type": "Direct", - "requested": "[17.10.0, )", - "resolved": "17.10.0", - "contentHash": "0/2HeACkaHEYU3wc83YlcD2Fi4LMtECJjqrtvw0lPi9DCEa35zSPt1j4fuvM8NagjDqJuh1Ja35WcRtn1Um6/A==", + "requested": "[17.11.1, )", + "resolved": "17.11.1", + "contentHash": "U3Ty4BaGoEu+T2bwSko9tWqWUOU16WzSFkq6U8zve75oRBMSLTBdMAZrVNNz1Tq12aCdDom9fcOcM9QZaFHqFg==", "dependencies": { - "Microsoft.CodeCoverage": "17.10.0", - "Microsoft.TestPlatform.TestHost": "17.10.0" + "Microsoft.CodeCoverage": "17.11.1", + "Microsoft.TestPlatform.TestHost": "17.11.1" } }, "NSubstitute": { "type": "Direct", - "requested": "[5.1.0, )", - "resolved": "5.1.0", - "contentHash": "ZCqOP3Kpp2ea7QcLyjMU4wzE+0wmrMN35PQMsdPOHYc2IrvjmusG9hICOiqiOTPKN0gJon6wyCn6ZuGHdNs9hQ==", + "requested": "[5.3.0, )", + "resolved": "5.3.0", + "contentHash": "lJ47Cps5Qzr86N99lcwd+OUvQma7+fBgr8+Mn+aOC0WrlqMNkdivaYD9IvnZ5Mqo6Ky3LS7ZI+tUq1/s9ERd0Q==", "dependencies": { "Castle.Core": "5.1.1" } @@ -35,15 +35,15 @@ }, "Roslynator.Analyzers": { "type": "Direct", - "requested": "[4.12.4, )", - "resolved": "4.12.4", - "contentHash": "isl8hAh7yFNjyBEC4YlTSi+xGBblqBUC/2MCMmnBPwuXPewb7XYnMRzT3vXbP/gOGwT8hZUOy1g/aRH3lAF/NQ==" + "requested": "[4.12.9, )", + "resolved": "4.12.9", + "contentHash": "X6lDpN/D5wuinq37KIx+l3GSUe9No+8bCjGBTI5sEEtxapLztkHg6gzNVhMXpXw8P+/5gFYxTXJ5Pf8O4iNz/w==" }, "SonarAnalyzer.CSharp": { "type": "Direct", - "requested": "[9.30.0.95878, )", - "resolved": "9.30.0.95878", - "contentHash": "P0DylTJphECGE9HD6yho7rb6qs2WTTW36QUu5ezGRJeZpq8ItlRLmzUpxNHVOaudJywcnKO1DdRyZSaU7LXOcA==" + "requested": "[9.32.0.97167, )", + "resolved": "9.32.0.97167", + "contentHash": "Yxk86RV+8ynJpUhku1Yw2hITFmnmXKkXJ73cIFSy85ol5SnWREQg9RuTyV8nI7V7+pyLKpCfRmD7P0widsgjkg==" }, "StyleCop.Analyzers": { "type": "Direct", @@ -56,13 +56,13 @@ }, "xunit": { "type": "Direct", - "requested": "[2.9.0, )", - "resolved": "2.9.0", - "contentHash": "PtU3rZ0ThdmdJqTbK7GkgFf6iBaCR6Q0uvJHznID+XEYk2v6O/b7sRxqnbi3B2gRDXxjTqMkVNayzwsqsFUxRw==", + "requested": "[2.9.2, )", + "resolved": "2.9.2", + "contentHash": "7LhFS2N9Z6Xgg8aE5lY95cneYivRMfRI8v+4PATa4S64D5Z/Plkg0qa8dTRHSiGRgVZ/CL2gEfJDE5AUhOX+2Q==", "dependencies": { - "xunit.analyzers": "1.15.0", - "xunit.assert": "2.9.0", - "xunit.core": "[2.9.0]" + "xunit.analyzers": "1.16.0", + "xunit.assert": "2.9.2", + "xunit.core": "[2.9.2]" } }, "xunit.runner.visualstudio": { @@ -81,45 +81,46 @@ }, "Microsoft.CodeCoverage": { "type": "Transitive", - "resolved": "17.10.0", - "contentHash": "yC7oSlnR54XO5kOuHlVOKtxomNNN1BWXX8lK1G2jaPXT9sUok7kCOoA4Pgs0qyFaCtMrNsprztYMeoEGqCm4uA==" + "resolved": "17.11.1", + "contentHash": "nPJqrcA5iX+Y0kqoT3a+pD/8lrW/V7ayqnEJQsTonSoPz59J8bmoQhcSN4G8+UJ64Hkuf0zuxnfuj2lkHOq4cA==" }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Transitive", - "resolved": "8.0.1", - "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", + "resolved": "9.0.0", + "contentHash": "g0UfujELzlLbHoVG8kPKVBaW470Ewi+jnptGS9KUi6jcb+k2StujtK3m26DFSGGwQ/+bVgZfsWqNzlP6YOejvw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0", + "System.Diagnostics.DiagnosticSource": "9.0.0" } }, "Microsoft.Extensions.Options": { "type": "Transitive", - "resolved": "8.0.2", - "contentHash": "dWGKvhFybsaZpGmzkGCbNNwBD1rVlWzrZKANLW/CcbFJpCEceMCGzT7zZwHOGBCbwM0SzBuceMj5HN1LKV1QqA==", + "resolved": "9.0.0", + "contentHash": "y2146b3jrPI3Q0lokKXdKLpmXqakYbDIPDV6r3M8SqvSf45WwOTzkyfDpxnZXJsJQEpAsAqjUq5Pu8RCJMjubg==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", - "Microsoft.Extensions.Primitives": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0", + "Microsoft.Extensions.Primitives": "9.0.0" } }, "Microsoft.Extensions.Primitives": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g==" + "resolved": "9.0.0", + "contentHash": "N3qEBzmLMYiASUlKxxFIISP4AiwuPTHF5uCh+2CWSwwzAJiIYx0kBJsS30cp1nvhSySFAVi30jecD307jV+8Kg==" }, "Microsoft.TestPlatform.ObjectModel": { "type": "Transitive", - "resolved": "17.10.0", - "contentHash": "KkwhjQevuDj0aBRoPLY6OLAhGqbPUEBuKLbaCs0kUVw29qiOYncdORd4mLVJbn9vGZ7/iFGQ/+AoJl0Tu5Umdg==", + "resolved": "17.11.1", + "contentHash": "E2jZqAU6JeWEVsyOEOrSW1o1bpHLgb25ypvKNB/moBXPVsFYBPd/Jwi7OrYahG50J83LfHzezYI+GaEkpAotiA==", "dependencies": { "System.Reflection.Metadata": "1.6.0" } }, "Microsoft.TestPlatform.TestHost": { "type": "Transitive", - "resolved": "17.10.0", - "contentHash": "LWpMdfqhHvcUkeMCvNYJO8QlPLlYz9XPPb+ZbaXIKhdmjAV0wqTSrTiW5FLaf7RRZT50AQADDOYMOe0HxDxNgA==", + "resolved": "17.11.1", + "contentHash": "DnG+GOqJXO/CkoqlJWeDFTgPhqD/V6VqUIL3vINizCWZ3X+HshCtbbyDdSHQQEjrc2Sl/K3yaxX6s+5LFEdYuw==", "dependencies": { - "Microsoft.TestPlatform.ObjectModel": "17.10.0", + "Microsoft.TestPlatform.ObjectModel": "17.11.1", "Newtonsoft.Json": "13.0.1" } }, @@ -133,6 +134,11 @@ "resolved": "1.2.0.556", "contentHash": "zvn9Mqs/ox/83cpYPignI8hJEM2A93s2HkHs8HYMOAQW0PkampyoErAiIyKxgTLqbbad29HX/shv/6LGSjPJNQ==" }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "9.0.0", + "contentHash": "ddppcFpnbohLWdYKr/ZeLZHmmI+DXFgZ3Snq+/E7SwcdW4UnvxmaugkwGywvGVWkHPGCSZjCP+MLzu23AL5SDw==" + }, "System.Diagnostics.EventLog": { "type": "Transitive", "resolved": "6.0.0", @@ -150,94 +156,94 @@ }, "xunit.analyzers": { "type": "Transitive", - "resolved": "1.15.0", - "contentHash": "s+M8K/Rtlgr6CmD7AYQKrNTvT5sh0l0ZKDoZ3Z/ExhlIwfV9mGAMR4f7KqIB7SSK7ZOhqDTgTUMYPmKfmvWUWQ==" + "resolved": "1.16.0", + "contentHash": "hptYM7vGr46GUIgZt21YHO4rfuBAQS2eINbFo16CV/Dqq+24Tp+P5gDCACu1AbFfW4Sp/WRfDPSK8fmUUb8s0Q==" }, "xunit.assert": { "type": "Transitive", - "resolved": "2.9.0", - "contentHash": "Z/1pyia//860wEYTKn6Q5dmgikJdRjgE4t5AoxJkK8oTmidzPLEPG574kmm7LFkMLbH6Frwmgb750kcyR+hwoA==" + "resolved": "2.9.2", + "contentHash": "QkNBAQG4pa66cholm28AxijBjrmki98/vsEh4Sx5iplzotvPgpiotcxqJQMRC8d7RV7nIT8ozh97957hDnZwsQ==" }, "xunit.core": { "type": "Transitive", - "resolved": "2.9.0", - "contentHash": "uRaop9tZsZMCaUS4AfbSPGYHtvywWnm8XXFNUqII7ShWyDBgdchY6gyDNgO4AK1Lv/1NNW61Zq63CsDV6oH6Jg==", + "resolved": "2.9.2", + "contentHash": "O6RrNSdmZ0xgEn5kT927PNwog5vxTtKrWMihhhrT0Sg9jQ7iBDciYOwzBgP2krBEk5/GBXI18R1lKvmnxGcb4w==", "dependencies": { - "xunit.extensibility.core": "[2.9.0]", - "xunit.extensibility.execution": "[2.9.0]" + "xunit.extensibility.core": "[2.9.2]", + "xunit.extensibility.execution": "[2.9.2]" } }, "xunit.extensibility.core": { "type": "Transitive", - "resolved": "2.9.0", - "contentHash": "zjDEUSxsr6UNij4gIwCgMqQox+oLDPRZ+mubwWLci+SssPBFQD1xeRR4SvgBuXqbE0QXCJ/STVTp+lxiB5NLVA==", + "resolved": "2.9.2", + "contentHash": "Ol+KlBJz1x8BrdnhN2DeOuLrr1I/cTwtHCggL9BvYqFuVd/TUSzxNT5O0NxCIXth30bsKxgMfdqLTcORtM52yQ==", "dependencies": { "xunit.abstractions": "2.0.3" } }, "xunit.extensibility.execution": { "type": "Transitive", - "resolved": "2.9.0", - "contentHash": "5ZTQZvmPLlBw6QzCOwM0KnMsZw6eGjbmC176QHZlcbQoMhGIeGcYzYwn5w9yXxf+4phtplMuVqTpTbFDQh2bqQ==", + "resolved": "2.9.2", + "contentHash": "rKMpq4GsIUIJibXuZoZ8lYp5EpROlnYaRpwu9Zr0sRZXE7JqJfEEbCsUriZqB+ByXCLFBJyjkTRULMdC+U566g==", "dependencies": { - "xunit.extensibility.core": "[2.9.0]" + "xunit.extensibility.core": "[2.9.2]" } }, "offdotnet.codeanalysis": { "type": "Project", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "[8.0.1, )", - "Microsoft.Extensions.Localization": "[8.0.7, )", - "Microsoft.Extensions.Localization.Abstractions": "[8.0.7, )", - "Microsoft.Extensions.ObjectPool": "[8.0.7, )" + "Microsoft.Extensions.DependencyInjection.Abstractions": "[9.0.0, )", + "Microsoft.Extensions.Localization": "[9.0.0, )", + "Microsoft.Extensions.Localization.Abstractions": "[9.0.0, )", + "Microsoft.Extensions.ObjectPool": "[9.0.0, )" } }, "offdotnet.codeanalysis.pdf": { "type": "Project", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "[8.0.1, )", - "Microsoft.Extensions.ObjectPool": "[8.0.7, )", + "Microsoft.Extensions.DependencyInjection.Abstractions": "[9.0.0, )", + "Microsoft.Extensions.ObjectPool": "[9.0.0, )", "OffDotNet.CodeAnalysis": "[1.0.0, )" } }, "offdotnet.codeanalysis.tests": { "type": "Project", "dependencies": { - "Microsoft.NET.Test.Sdk": "[17.10.0, )", - "NSubstitute": "[5.1.0, )", + "Microsoft.NET.Test.Sdk": "[17.11.1, )", + "NSubstitute": "[5.3.0, )", "OffDotNet.CodeAnalysis": "[1.0.0, )", - "xunit": "[2.9.0, )" + "xunit": "[2.9.2, )" } }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "CentralTransitive", - "requested": "[8.0.1, )", - "resolved": "8.0.1", - "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "+6f2qv2a3dLwd5w6JanPIPs47CxRbnk+ZocMJUhv9NxP88VlOcJYZs9jY+MYSjxvady08bUZn6qgiNh7DadGgg==" }, "Microsoft.Extensions.Localization": { "type": "CentralTransitive", - "requested": "[8.0.7, )", - "resolved": "8.0.7", - "contentHash": "kdI24IfC1Jk3zfhWvYmuzvkzuKp+5Shjmfq0vk6EKBB+Udt4Gu1SkVSkMWJkYZFag+ndd+sTroUKDC/sud/DYQ==", + "requested": "[8.0.10, )", + "resolved": "9.0.0", + "contentHash": "Up8Juy8Bh+vL+fXmMWsoSg/G6rszmLFiF44aI2tpOMJE7Ln4D9s37YxOOm81am4Z+V7g8Am3AgVwHYJzi+cL/g==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1", - "Microsoft.Extensions.Localization.Abstractions": "8.0.7", - "Microsoft.Extensions.Logging.Abstractions": "8.0.1", - "Microsoft.Extensions.Options": "8.0.2" + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0", + "Microsoft.Extensions.Localization.Abstractions": "9.0.0", + "Microsoft.Extensions.Logging.Abstractions": "9.0.0", + "Microsoft.Extensions.Options": "9.0.0" } }, "Microsoft.Extensions.Localization.Abstractions": { "type": "CentralTransitive", - "requested": "[8.0.7, )", - "resolved": "8.0.7", - "contentHash": "uCsxqBBJEsSoV52tX/v+bxxN0e1O8WYIRR7tmcEmVVkRSX+0k4ZJcaL79ddus+0HIm3ssjV/dJk56XufDrGDqg==" + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "wc7PaRhPOnio5Csj80b3UgBWA5l6bp28EhGem7gtfpVopcwbkfPb2Sk8Cu6eBnIW3ZNf1YUgYJzwtjzZEM8+iw==" }, "Microsoft.Extensions.ObjectPool": { "type": "CentralTransitive", - "requested": "[8.0.7, )", - "resolved": "8.0.7", - "contentHash": "2yLweyqmpuuFSRo+I3sLHMxmnAgNcI537kBJiyv49U2ZEqo00jZcG8lrnD8uCiOJp9IklYyTZULtbsXoFVzsjQ==" + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "UbsU/gYe4nv1DeqMXIVzDfNNek7Sk2kKuAOXL/Y+sLcAR0HwFUqzg1EPiU88jeHNe0g81aPvvHbvHarQr3r9IA==" } } } diff --git a/tests/OffDotNet.CodeAnalysis.Tests/Lexer/TextCursorTests.cs b/tests/OffDotNet.CodeAnalysis.Tests/Lexer/TextCursorTests.cs index 1b0251a..c469133 100644 --- a/tests/OffDotNet.CodeAnalysis.Tests/Lexer/TextCursorTests.cs +++ b/tests/OffDotNet.CodeAnalysis.Tests/Lexer/TextCursorTests.cs @@ -870,15 +870,17 @@ public void SlideTextWindow_WhenInitialized_WhenShrinking_ShouldCopyOldWindowToN } [WorkItem("https://github.com/sunt-programator/off-dotnet/issues/335")] - [Fact(DisplayName = $"{nameof(TextCursor.SlideTextWindow)} method should set {nameof(TextCursor.Offset)} to 0 when sliding the window")] - public void SlideTextWindow_WhenSliding_ShouldSetOffsetToZero() + [Theory(DisplayName = $"{nameof(TextCursor.SlideTextWindow)} method should adjust {nameof(TextCursor.Offset)} when sliding the window")] + [InlineData(5, 0)] + [InlineData(16, 0)] + [InlineData(17, 0)] + public void SlideTextWindow_WhenSliding_ShouldSetOffset(int advanceDelta, int expectedOffset) { // Arrange const int TextLength = 256; const int WindowStart = 0; const int DefaultWindowSize = 128; - const int WindowSize = 48; - const int ExpectedOffset = 0; + const int WindowSize = 16; var sourceText = GetSourceText(GenerateIncrementingString(TextLength)); _options.Value.Returns(new TextCursorOptions { WindowSize = DefaultWindowSize }); @@ -886,23 +888,25 @@ public void SlideTextWindow_WhenSliding_ShouldSetOffsetToZero() // Act cursor.Peek(); - cursor.Advance(5); + cursor.Advance(advanceDelta); cursor.SlideTextWindow(WindowStart, WindowSize); // Assert - Assert.Equal(ExpectedOffset, cursor.Offset); + Assert.Equal(expectedOffset, cursor.Offset); } [WorkItem("https://github.com/sunt-programator/off-dotnet/issues/335")] - [Fact(DisplayName = $"{nameof(TextCursor.SlideTextWindow)} method should set {nameof(TextCursor.LexemeStart)} to 0 when sliding the window")] - public void SlideTextWindow_WhenSliding_ShouldSetLexemeStartToZero() + [Theory(DisplayName = $"{nameof(TextCursor.SlideTextWindow)} method should adjust {nameof(TextCursor.LexemeStart)} when sliding the window")] + [InlineData(5, 5, true)] + [InlineData(16, 0, false)] + [InlineData(17, 0, false)] + public void SlideTextWindow_WhenSliding_ShouldSetLexemeStartToZero(int advanceDelta, int expectedLexemeStart, bool expectedLexemeMode) { // Arrange const int TextLength = 256; const int WindowStart = 0; const int DefaultWindowSize = 128; - const int WindowSize = 48; - const int ExpectedLexemeStart = 0; + const int WindowSize = 16; var sourceText = GetSourceText(GenerateIncrementingString(TextLength)); _options.Value.Returns(new TextCursorOptions { WindowSize = DefaultWindowSize }); @@ -910,12 +914,13 @@ public void SlideTextWindow_WhenSliding_ShouldSetLexemeStartToZero() // Act cursor.Peek(); - cursor.Advance(5); + cursor.Advance(advanceDelta); + cursor.StartLexemeMode(); cursor.SlideTextWindow(WindowStart, WindowSize); // Assert - Assert.Equal(ExpectedLexemeStart, cursor.LexemeStart); - Assert.False(cursor.IsLexemeMode); + Assert.Equal(expectedLexemeStart, cursor.LexemeStart); + Assert.Equal(expectedLexemeMode, cursor.IsLexemeMode); } [WorkItem("https://github.com/sunt-programator/off-dotnet/issues/335")] @@ -966,6 +971,31 @@ public void Peek_CustomWindowStart_WhenDeltaIsOutsideWindow_ShouldRestoreWindowS Assert.Equal(expectedByte, actual); } + [WorkItem("https://github.com/sunt-programator/off-dotnet/issues/335")] + [Fact(DisplayName = $"{nameof(TextCursor.WindowSize)} property should be increased " + + $"when {nameof(TextCursor.IsLexemeMode)} is true and {nameof(TextCursor.Offset)} is outside the window")] + public void WindowSize_WhenLexemeModeIsTrue_WhenOffsetIsOutsideWindow_ShouldIncreaseWindowSize() + { + // Arrange + const int TextLength = 256; + const int DefaultWindowSize = 16; + const int ExpectedWindowSize = 32; + const byte ExpectedByte = (byte)'q'; + + var sourceText = GetSourceText(GenerateIncrementingString(TextLength)); + _options.Value.Returns(new TextCursorOptions { WindowSize = DefaultWindowSize }); + ITextCursor cursor = new TextCursor(sourceText, _options); + + // Act + cursor.StartLexemeMode(); + var actual = cursor.Peek(DefaultWindowSize); + + // Assert + Assert.True(cursor.IsLexemeMode); + Assert.Equal(ExpectedWindowSize, cursor.WindowSize); + Assert.Equal(ExpectedByte, actual); + } + private static ISourceText GetSourceText(string text) => new StringText(Encoding.ASCII.GetBytes(text)); private static string GenerateIncrementingString(int n) diff --git a/tests/OffDotNet.CodeAnalysis.Tests/packages.lock.json b/tests/OffDotNet.CodeAnalysis.Tests/packages.lock.json index 2259755..38a53bc 100644 --- a/tests/OffDotNet.CodeAnalysis.Tests/packages.lock.json +++ b/tests/OffDotNet.CodeAnalysis.Tests/packages.lock.json @@ -10,19 +10,19 @@ }, "Microsoft.NET.Test.Sdk": { "type": "Direct", - "requested": "[17.10.0, )", - "resolved": "17.10.0", - "contentHash": "0/2HeACkaHEYU3wc83YlcD2Fi4LMtECJjqrtvw0lPi9DCEa35zSPt1j4fuvM8NagjDqJuh1Ja35WcRtn1Um6/A==", + "requested": "[17.11.1, )", + "resolved": "17.11.1", + "contentHash": "U3Ty4BaGoEu+T2bwSko9tWqWUOU16WzSFkq6U8zve75oRBMSLTBdMAZrVNNz1Tq12aCdDom9fcOcM9QZaFHqFg==", "dependencies": { - "Microsoft.CodeCoverage": "17.10.0", - "Microsoft.TestPlatform.TestHost": "17.10.0" + "Microsoft.CodeCoverage": "17.11.1", + "Microsoft.TestPlatform.TestHost": "17.11.1" } }, "NSubstitute": { "type": "Direct", - "requested": "[5.1.0, )", - "resolved": "5.1.0", - "contentHash": "ZCqOP3Kpp2ea7QcLyjMU4wzE+0wmrMN35PQMsdPOHYc2IrvjmusG9hICOiqiOTPKN0gJon6wyCn6ZuGHdNs9hQ==", + "requested": "[5.3.0, )", + "resolved": "5.3.0", + "contentHash": "lJ47Cps5Qzr86N99lcwd+OUvQma7+fBgr8+Mn+aOC0WrlqMNkdivaYD9IvnZ5Mqo6Ky3LS7ZI+tUq1/s9ERd0Q==", "dependencies": { "Castle.Core": "5.1.1" } @@ -35,15 +35,15 @@ }, "Roslynator.Analyzers": { "type": "Direct", - "requested": "[4.12.4, )", - "resolved": "4.12.4", - "contentHash": "isl8hAh7yFNjyBEC4YlTSi+xGBblqBUC/2MCMmnBPwuXPewb7XYnMRzT3vXbP/gOGwT8hZUOy1g/aRH3lAF/NQ==" + "requested": "[4.12.9, )", + "resolved": "4.12.9", + "contentHash": "X6lDpN/D5wuinq37KIx+l3GSUe9No+8bCjGBTI5sEEtxapLztkHg6gzNVhMXpXw8P+/5gFYxTXJ5Pf8O4iNz/w==" }, "SonarAnalyzer.CSharp": { "type": "Direct", - "requested": "[9.30.0.95878, )", - "resolved": "9.30.0.95878", - "contentHash": "P0DylTJphECGE9HD6yho7rb6qs2WTTW36QUu5ezGRJeZpq8ItlRLmzUpxNHVOaudJywcnKO1DdRyZSaU7LXOcA==" + "requested": "[9.32.0.97167, )", + "resolved": "9.32.0.97167", + "contentHash": "Yxk86RV+8ynJpUhku1Yw2hITFmnmXKkXJ73cIFSy85ol5SnWREQg9RuTyV8nI7V7+pyLKpCfRmD7P0widsgjkg==" }, "StyleCop.Analyzers": { "type": "Direct", @@ -56,13 +56,13 @@ }, "xunit": { "type": "Direct", - "requested": "[2.9.0, )", - "resolved": "2.9.0", - "contentHash": "PtU3rZ0ThdmdJqTbK7GkgFf6iBaCR6Q0uvJHznID+XEYk2v6O/b7sRxqnbi3B2gRDXxjTqMkVNayzwsqsFUxRw==", + "requested": "[2.9.2, )", + "resolved": "2.9.2", + "contentHash": "7LhFS2N9Z6Xgg8aE5lY95cneYivRMfRI8v+4PATa4S64D5Z/Plkg0qa8dTRHSiGRgVZ/CL2gEfJDE5AUhOX+2Q==", "dependencies": { - "xunit.analyzers": "1.15.0", - "xunit.assert": "2.9.0", - "xunit.core": "[2.9.0]" + "xunit.analyzers": "1.16.0", + "xunit.assert": "2.9.2", + "xunit.core": "[2.9.2]" } }, "xunit.runner.visualstudio": { @@ -81,45 +81,46 @@ }, "Microsoft.CodeCoverage": { "type": "Transitive", - "resolved": "17.10.0", - "contentHash": "yC7oSlnR54XO5kOuHlVOKtxomNNN1BWXX8lK1G2jaPXT9sUok7kCOoA4Pgs0qyFaCtMrNsprztYMeoEGqCm4uA==" + "resolved": "17.11.1", + "contentHash": "nPJqrcA5iX+Y0kqoT3a+pD/8lrW/V7ayqnEJQsTonSoPz59J8bmoQhcSN4G8+UJ64Hkuf0zuxnfuj2lkHOq4cA==" }, "Microsoft.Extensions.Logging.Abstractions": { "type": "Transitive", - "resolved": "8.0.1", - "contentHash": "RIFgaqoaINxkM2KTOw72dmilDmTrYA0ns2KW4lDz4gZ2+o6IQ894CzmdL3StM2oh7QQq44nCWiqKqc4qUI9Jmg==", + "resolved": "9.0.0", + "contentHash": "g0UfujELzlLbHoVG8kPKVBaW470Ewi+jnptGS9KUi6jcb+k2StujtK3m26DFSGGwQ/+bVgZfsWqNzlP6YOejvw==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0", + "System.Diagnostics.DiagnosticSource": "9.0.0" } }, "Microsoft.Extensions.Options": { "type": "Transitive", - "resolved": "8.0.2", - "contentHash": "dWGKvhFybsaZpGmzkGCbNNwBD1rVlWzrZKANLW/CcbFJpCEceMCGzT7zZwHOGBCbwM0SzBuceMj5HN1LKV1QqA==", + "resolved": "9.0.0", + "contentHash": "y2146b3jrPI3Q0lokKXdKLpmXqakYbDIPDV6r3M8SqvSf45WwOTzkyfDpxnZXJsJQEpAsAqjUq5Pu8RCJMjubg==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", - "Microsoft.Extensions.Primitives": "8.0.0" + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0", + "Microsoft.Extensions.Primitives": "9.0.0" } }, "Microsoft.Extensions.Primitives": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g==" + "resolved": "9.0.0", + "contentHash": "N3qEBzmLMYiASUlKxxFIISP4AiwuPTHF5uCh+2CWSwwzAJiIYx0kBJsS30cp1nvhSySFAVi30jecD307jV+8Kg==" }, "Microsoft.TestPlatform.ObjectModel": { "type": "Transitive", - "resolved": "17.10.0", - "contentHash": "KkwhjQevuDj0aBRoPLY6OLAhGqbPUEBuKLbaCs0kUVw29qiOYncdORd4mLVJbn9vGZ7/iFGQ/+AoJl0Tu5Umdg==", + "resolved": "17.11.1", + "contentHash": "E2jZqAU6JeWEVsyOEOrSW1o1bpHLgb25ypvKNB/moBXPVsFYBPd/Jwi7OrYahG50J83LfHzezYI+GaEkpAotiA==", "dependencies": { "System.Reflection.Metadata": "1.6.0" } }, "Microsoft.TestPlatform.TestHost": { "type": "Transitive", - "resolved": "17.10.0", - "contentHash": "LWpMdfqhHvcUkeMCvNYJO8QlPLlYz9XPPb+ZbaXIKhdmjAV0wqTSrTiW5FLaf7RRZT50AQADDOYMOe0HxDxNgA==", + "resolved": "17.11.1", + "contentHash": "DnG+GOqJXO/CkoqlJWeDFTgPhqD/V6VqUIL3vINizCWZ3X+HshCtbbyDdSHQQEjrc2Sl/K3yaxX6s+5LFEdYuw==", "dependencies": { - "Microsoft.TestPlatform.ObjectModel": "17.10.0", + "Microsoft.TestPlatform.ObjectModel": "17.11.1", "Newtonsoft.Json": "13.0.1" } }, @@ -133,6 +134,11 @@ "resolved": "1.2.0.556", "contentHash": "zvn9Mqs/ox/83cpYPignI8hJEM2A93s2HkHs8HYMOAQW0PkampyoErAiIyKxgTLqbbad29HX/shv/6LGSjPJNQ==" }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "9.0.0", + "contentHash": "ddppcFpnbohLWdYKr/ZeLZHmmI+DXFgZ3Snq+/E7SwcdW4UnvxmaugkwGywvGVWkHPGCSZjCP+MLzu23AL5SDw==" + }, "System.Diagnostics.EventLog": { "type": "Transitive", "resolved": "6.0.0", @@ -150,77 +156,77 @@ }, "xunit.analyzers": { "type": "Transitive", - "resolved": "1.15.0", - "contentHash": "s+M8K/Rtlgr6CmD7AYQKrNTvT5sh0l0ZKDoZ3Z/ExhlIwfV9mGAMR4f7KqIB7SSK7ZOhqDTgTUMYPmKfmvWUWQ==" + "resolved": "1.16.0", + "contentHash": "hptYM7vGr46GUIgZt21YHO4rfuBAQS2eINbFo16CV/Dqq+24Tp+P5gDCACu1AbFfW4Sp/WRfDPSK8fmUUb8s0Q==" }, "xunit.assert": { "type": "Transitive", - "resolved": "2.9.0", - "contentHash": "Z/1pyia//860wEYTKn6Q5dmgikJdRjgE4t5AoxJkK8oTmidzPLEPG574kmm7LFkMLbH6Frwmgb750kcyR+hwoA==" + "resolved": "2.9.2", + "contentHash": "QkNBAQG4pa66cholm28AxijBjrmki98/vsEh4Sx5iplzotvPgpiotcxqJQMRC8d7RV7nIT8ozh97957hDnZwsQ==" }, "xunit.core": { "type": "Transitive", - "resolved": "2.9.0", - "contentHash": "uRaop9tZsZMCaUS4AfbSPGYHtvywWnm8XXFNUqII7ShWyDBgdchY6gyDNgO4AK1Lv/1NNW61Zq63CsDV6oH6Jg==", + "resolved": "2.9.2", + "contentHash": "O6RrNSdmZ0xgEn5kT927PNwog5vxTtKrWMihhhrT0Sg9jQ7iBDciYOwzBgP2krBEk5/GBXI18R1lKvmnxGcb4w==", "dependencies": { - "xunit.extensibility.core": "[2.9.0]", - "xunit.extensibility.execution": "[2.9.0]" + "xunit.extensibility.core": "[2.9.2]", + "xunit.extensibility.execution": "[2.9.2]" } }, "xunit.extensibility.core": { "type": "Transitive", - "resolved": "2.9.0", - "contentHash": "zjDEUSxsr6UNij4gIwCgMqQox+oLDPRZ+mubwWLci+SssPBFQD1xeRR4SvgBuXqbE0QXCJ/STVTp+lxiB5NLVA==", + "resolved": "2.9.2", + "contentHash": "Ol+KlBJz1x8BrdnhN2DeOuLrr1I/cTwtHCggL9BvYqFuVd/TUSzxNT5O0NxCIXth30bsKxgMfdqLTcORtM52yQ==", "dependencies": { "xunit.abstractions": "2.0.3" } }, "xunit.extensibility.execution": { "type": "Transitive", - "resolved": "2.9.0", - "contentHash": "5ZTQZvmPLlBw6QzCOwM0KnMsZw6eGjbmC176QHZlcbQoMhGIeGcYzYwn5w9yXxf+4phtplMuVqTpTbFDQh2bqQ==", + "resolved": "2.9.2", + "contentHash": "rKMpq4GsIUIJibXuZoZ8lYp5EpROlnYaRpwu9Zr0sRZXE7JqJfEEbCsUriZqB+ByXCLFBJyjkTRULMdC+U566g==", "dependencies": { - "xunit.extensibility.core": "[2.9.0]" + "xunit.extensibility.core": "[2.9.2]" } }, "offdotnet.codeanalysis": { "type": "Project", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "[8.0.1, )", - "Microsoft.Extensions.Localization": "[8.0.7, )", - "Microsoft.Extensions.Localization.Abstractions": "[8.0.7, )", - "Microsoft.Extensions.ObjectPool": "[8.0.7, )" + "Microsoft.Extensions.DependencyInjection.Abstractions": "[9.0.0, )", + "Microsoft.Extensions.Localization": "[9.0.0, )", + "Microsoft.Extensions.Localization.Abstractions": "[9.0.0, )", + "Microsoft.Extensions.ObjectPool": "[9.0.0, )" } }, "Microsoft.Extensions.DependencyInjection.Abstractions": { "type": "CentralTransitive", - "requested": "[8.0.1, )", - "resolved": "8.0.1", - "contentHash": "fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==" + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "+6f2qv2a3dLwd5w6JanPIPs47CxRbnk+ZocMJUhv9NxP88VlOcJYZs9jY+MYSjxvady08bUZn6qgiNh7DadGgg==" }, "Microsoft.Extensions.Localization": { "type": "CentralTransitive", - "requested": "[8.0.7, )", - "resolved": "8.0.7", - "contentHash": "kdI24IfC1Jk3zfhWvYmuzvkzuKp+5Shjmfq0vk6EKBB+Udt4Gu1SkVSkMWJkYZFag+ndd+sTroUKDC/sud/DYQ==", + "requested": "[8.0.10, )", + "resolved": "9.0.0", + "contentHash": "Up8Juy8Bh+vL+fXmMWsoSg/G6rszmLFiF44aI2tpOMJE7Ln4D9s37YxOOm81am4Z+V7g8Am3AgVwHYJzi+cL/g==", "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1", - "Microsoft.Extensions.Localization.Abstractions": "8.0.7", - "Microsoft.Extensions.Logging.Abstractions": "8.0.1", - "Microsoft.Extensions.Options": "8.0.2" + "Microsoft.Extensions.DependencyInjection.Abstractions": "9.0.0", + "Microsoft.Extensions.Localization.Abstractions": "9.0.0", + "Microsoft.Extensions.Logging.Abstractions": "9.0.0", + "Microsoft.Extensions.Options": "9.0.0" } }, "Microsoft.Extensions.Localization.Abstractions": { "type": "CentralTransitive", - "requested": "[8.0.7, )", - "resolved": "8.0.7", - "contentHash": "uCsxqBBJEsSoV52tX/v+bxxN0e1O8WYIRR7tmcEmVVkRSX+0k4ZJcaL79ddus+0HIm3ssjV/dJk56XufDrGDqg==" + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "wc7PaRhPOnio5Csj80b3UgBWA5l6bp28EhGem7gtfpVopcwbkfPb2Sk8Cu6eBnIW3ZNf1YUgYJzwtjzZEM8+iw==" }, "Microsoft.Extensions.ObjectPool": { "type": "CentralTransitive", - "requested": "[8.0.7, )", - "resolved": "8.0.7", - "contentHash": "2yLweyqmpuuFSRo+I3sLHMxmnAgNcI537kBJiyv49U2ZEqo00jZcG8lrnD8uCiOJp9IklYyTZULtbsXoFVzsjQ==" + "requested": "[9.0.0, )", + "resolved": "9.0.0", + "contentHash": "UbsU/gYe4nv1DeqMXIVzDfNNek7Sk2kKuAOXL/Y+sLcAR0HwFUqzg1EPiU88jeHNe0g81aPvvHbvHarQr3r9IA==" } } }