Add TextMateGrammar.tokenizeLines convenience method

It can be used in specs to test parsing. It takes a block of text,
splits it into lines, and then tokenizes them, returning an array
of token arrays, one for each line.
This commit is contained in:
Nathan Sobo
2013-04-25 17:11:21 -06:00
parent 7e0ac1db9c
commit 89fe8e1628

View File

@@ -161,6 +161,13 @@ class TextMateGrammar
ruleStack.forEach (rule) -> rule.clearAnchorPosition()
{ tokens, ruleStack }
tokenizeLines: (text) ->
lines = text.split('\n')
ruleStack = null
for line, i in lines
{ tokens, ruleStack } = @tokenizeLine(line, ruleStack, i is 0)
tokens
getMaxTokensPerLine: ->
@maxTokensPerLine