mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user