From 4da7ca89f6d7a0ac387eb7b909d07e88949ac1e0 Mon Sep 17 00:00:00 2001 From: Dave Black <656118+udlose@users.noreply.github.com> Date: Sat, 7 Mar 2026 04:36:33 -0600 Subject: [PATCH] Fixes #117 - Fix typo: rename PushAtributed to PushAttributed Renamed all instances of PushAtributed to PushAttributed for clarity and consistency across the codebase, including AttributedScopeStack, LineTokenizer, and related unit tests. Also made minor formatting and readonly improvements in LineTokenizer.cs. --- .../Grammars/AttributedScopeStackTests.cs | 14 +++++------ .../Internal/Grammars/AttributedScopeStack.cs | 2 +- .../Internal/Grammars/LineTokenizer.cs | 25 +++++++++---------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/TextMateSharp.Tests/Internal/Grammars/AttributedScopeStackTests.cs b/src/TextMateSharp.Tests/Internal/Grammars/AttributedScopeStackTests.cs index c203d79..1fe5426 100644 --- a/src/TextMateSharp.Tests/Internal/Grammars/AttributedScopeStackTests.cs +++ b/src/TextMateSharp.Tests/Internal/Grammars/AttributedScopeStackTests.cs @@ -1549,7 +1549,7 @@ public void PushAttributed_NullScopePath_ReturnsSameInstance() AttributedScopeStack stack = CreateStack(("a", 1), ("b", 2)); // act - AttributedScopeStack result = stack.PushAtributed(null, null); + AttributedScopeStack result = stack.PushAttributed(null, null); // assert Assert.AreSame(stack, result); @@ -1562,7 +1562,7 @@ public void PushAttributed_NonNullScope_WithNullGrammar_ThrowsArgumentNullExcept AttributedScopeStack stack = CreateStack(("a", 1)); // act/assert - Assert.Throws(() => stack.PushAtributed("b", null)); + Assert.Throws(() => stack.PushAttributed("b", null)); } [Test] @@ -1572,7 +1572,7 @@ public void PushAttributed_MultiScope_WithNullGrammar_ThrowsArgumentNullExceptio AttributedScopeStack stack = CreateStack(("a", 1)); // act/assert - Assert.Throws(() => stack.PushAtributed("b c", null)); + Assert.Throws(() => stack.PushAttributed("b c", null)); } [Test] @@ -1582,7 +1582,7 @@ public void PushAttributed_EmptyStringScope_WithNullGrammar_ThrowsArgumentNullEx AttributedScopeStack stack = CreateStack(("a", 1)); // act/assert - Assert.Throws(() => stack.PushAtributed("", null)); + Assert.Throws(() => stack.PushAttributed("", null)); } [Test] @@ -1593,7 +1593,7 @@ public void PushAttributed_ShouldHandleTrailingSpacesAndProduceEmptySegment() AttributedScopeStack initial = new AttributedScopeStack(null, "root", 0); // Act - AttributedScopeStack result = initial.PushAtributed("a b ", grammar); + AttributedScopeStack result = initial.PushAttributed("a b ", grammar); List scopes = result.GetScopeNames(); // Assert @@ -1608,7 +1608,7 @@ public void PushAttributed_MultiScope_ProducesSegments() AttributedScopeStack initial = new AttributedScopeStack(null, "root", 0); // Act - AttributedScopeStack result = initial.PushAtributed("a b", grammar); + AttributedScopeStack result = initial.PushAttributed("a b", grammar); List scopes = result.GetScopeNames(); // Assert @@ -1624,7 +1624,7 @@ public void PushAttributed_SingleScope_PreservesScopeStringInstance() const string scopePath = "single.scope"; // Act - AttributedScopeStack result = initial.PushAtributed(scopePath, grammar); + AttributedScopeStack result = initial.PushAttributed(scopePath, grammar); // Assert Assert.AreSame(scopePath, result.ScopePath); diff --git a/src/TextMateSharp/Internal/Grammars/AttributedScopeStack.cs b/src/TextMateSharp/Internal/Grammars/AttributedScopeStack.cs index c44dd64..9b1f598 100644 --- a/src/TextMateSharp/Internal/Grammars/AttributedScopeStack.cs +++ b/src/TextMateSharp/Internal/Grammars/AttributedScopeStack.cs @@ -290,7 +290,7 @@ private static AttributedScopeStack PushSingleScope(AttributedScopeStack target, return new AttributedScopeStack(target, scope, metadata); } - public AttributedScopeStack PushAtributed(string scopePath, Grammar grammar) + public AttributedScopeStack PushAttributed(string scopePath, Grammar grammar) { if (scopePath == null) { diff --git a/src/TextMateSharp/Internal/Grammars/LineTokenizer.cs b/src/TextMateSharp/Internal/Grammars/LineTokenizer.cs index c6b4948..22fe9a6 100644 --- a/src/TextMateSharp/Internal/Grammars/LineTokenizer.cs +++ b/src/TextMateSharp/Internal/Grammars/LineTokenizer.cs @@ -1,8 +1,7 @@ +using Onigwrap; using System; using System.Collections.Generic; using System.Diagnostics; -using Onigwrap; - using TextMateSharp.Grammars; using TextMateSharp.Internal.Matcher; using TextMateSharp.Internal.Rules; @@ -12,16 +11,16 @@ namespace TextMateSharp.Internal.Grammars { class LineTokenizer { - private Grammar _grammar; - private ReadOnlyMemory _lineText; + private readonly Grammar _grammar; + private readonly ReadOnlyMemory _lineText; private bool _isFirstLine; private int _linePos; private StateStack _stack; - private LineTokens _lineTokens; + private readonly LineTokens _lineTokens; private int _anchorPosition = -1; private bool _stop; - private Stopwatch _stopwatch = new Stopwatch(); - private int _lineLength; + private readonly Stopwatch _stopwatch = new Stopwatch(); + private readonly int _lineLength; private readonly List _localStackBuffer = new List(); private readonly List _whileRulesBuffer = new List(); @@ -126,7 +125,7 @@ private void ScanNext() StateStack beforePush = _stack; // push it on the stack rule string scopeName = rule.GetName(_lineText, captureIndices); - AttributedScopeStack nameScopesList = _stack.ContentNameScopesList.PushAtributed( + AttributedScopeStack nameScopesList = _stack.ContentNameScopesList.PushAttributed( scopeName, _grammar); @@ -158,7 +157,7 @@ private void ScanNext() _lineText, captureIndices); - AttributedScopeStack contentNameScopesList = nameScopesList.PushAtributed( + AttributedScopeStack contentNameScopesList = nameScopesList.PushAttributed( contentName, _grammar); @@ -201,7 +200,7 @@ private void ScanNext() _anchorPosition = captureIndices[0].End; string contentName = pushedRule.GetContentName(_lineText, captureIndices); - AttributedScopeStack contentNameScopesList = nameScopesList.PushAtributed(contentName, _grammar); + AttributedScopeStack contentNameScopesList = nameScopesList.PushAttributed(contentName, _grammar); _stack = _stack.WithContentNameScopesList(contentNameScopesList); if (pushedRule.WhileHasBackReferences) @@ -445,9 +444,9 @@ private void HandleCaptures(Grammar grammar, ReadOnlyMemory lineText, bool { // the capture requires additional matching string scopeName = captureRule.GetName(lineText, captureIndices); - AttributedScopeStack nameScopesList = stack.ContentNameScopesList.PushAtributed(scopeName, grammar); + AttributedScopeStack nameScopesList = stack.ContentNameScopesList.PushAttributed(scopeName, grammar); string contentName = captureRule.GetContentName(lineText, captureIndices); - AttributedScopeStack contentNameScopesList = nameScopesList.PushAtributed(contentName, grammar); + AttributedScopeStack contentNameScopesList = nameScopesList.PushAttributed(contentName, grammar); // the capture requires additional matching StateStack stackClone = stack.Push( @@ -472,7 +471,7 @@ private void HandleCaptures(Grammar grammar, ReadOnlyMemory lineText, bool // push AttributedScopeStack baseElement = localStack.Count == 0 ? stack.ContentNameScopesList : localStack[localStack.Count - 1].Scopes; - AttributedScopeStack captureRuleScopesList = baseElement.PushAtributed(captureRuleScopeName, grammar); + AttributedScopeStack captureRuleScopesList = baseElement.PushAttributed(captureRuleScopeName, grammar); localStack.Add(new LocalStackElement(captureRuleScopesList, captureIndex.End)); } }