Use scope ids instead of tags

This commit is contained in:
Antonio Scandurra
2017-05-01 15:24:32 +02:00
parent 570cfdeaff
commit f17baf4790
7 changed files with 170 additions and 182 deletions

View File

@@ -7,6 +7,9 @@ TokenIterator = require './token-iterator'
ScopeDescriptor = require './scope-descriptor'
TokenizedBufferIterator = require './tokenized-buffer-iterator'
NullGrammar = require './null-grammar'
{toFirstMateScopeId} = require './first-mate-helpers'
prefixedScopes = new Map()
module.exports =
class TokenizedBuffer extends Model
@@ -46,6 +49,19 @@ class TokenizedBuffer extends Model
buildIterator: ->
new TokenizedBufferIterator(this)
classNameForScopeId: (id) ->
scope = @grammar.scopeForId(toFirstMateScopeId(id))
if scope
prefixedScope = prefixedScopes.get(scope)
if prefixedScope
prefixedScope
else
prefixedScope = "syntax--#{scope.replace(/\./g, ' syntax--')}"
prefixedScopes.set(scope, prefixedScope)
prefixedScope
else
null
getInvalidatedRanges: ->
[]