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)); } }