Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -1562,7 +1562,7 @@ public void PushAttributed_NonNullScope_WithNullGrammar_ThrowsArgumentNullExcept
AttributedScopeStack stack = CreateStack(("a", 1));

// act/assert
Assert.Throws<ArgumentNullException>(() => stack.PushAtributed("b", null));
Assert.Throws<ArgumentNullException>(() => stack.PushAttributed("b", null));
}

[Test]
Expand All @@ -1572,7 +1572,7 @@ public void PushAttributed_MultiScope_WithNullGrammar_ThrowsArgumentNullExceptio
AttributedScopeStack stack = CreateStack(("a", 1));

// act/assert
Assert.Throws<ArgumentNullException>(() => stack.PushAtributed("b c", null));
Assert.Throws<ArgumentNullException>(() => stack.PushAttributed("b c", null));
}

[Test]
Expand All @@ -1582,7 +1582,7 @@ public void PushAttributed_EmptyStringScope_WithNullGrammar_ThrowsArgumentNullEx
AttributedScopeStack stack = CreateStack(("a", 1));

// act/assert
Assert.Throws<ArgumentNullException>(() => stack.PushAtributed("", null));
Assert.Throws<ArgumentNullException>(() => stack.PushAttributed("", null));
}

[Test]
Expand All @@ -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<string> scopes = result.GetScopeNames();

// Assert
Expand All @@ -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<string> scopes = result.GetScopeNames();

// Assert
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
25 changes: 12 additions & 13 deletions src/TextMateSharp/Internal/Grammars/LineTokenizer.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,16 +11,16 @@ namespace TextMateSharp.Internal.Grammars
{
class LineTokenizer
{
private Grammar _grammar;
private ReadOnlyMemory<char> _lineText;
private readonly Grammar _grammar;
private readonly ReadOnlyMemory<char> _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<LocalStackElement> _localStackBuffer = new List<LocalStackElement>();
private readonly List<WhileStack> _whileRulesBuffer = new List<WhileStack>();

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -158,7 +157,7 @@ private void ScanNext()
_lineText,
captureIndices);

AttributedScopeStack contentNameScopesList = nameScopesList.PushAtributed(
AttributedScopeStack contentNameScopesList = nameScopesList.PushAttributed(
contentName,
_grammar);

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -445,9 +444,9 @@ private void HandleCaptures(Grammar grammar, ReadOnlyMemory<char> 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(
Expand All @@ -472,7 +471,7 @@ private void HandleCaptures(Grammar grammar, ReadOnlyMemory<char> 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));
}
}
Expand Down
Loading