 capitalizeFirstLetter = (string) ->
   string.charAt(0).toUpperCase() + string.slice(1)
 
-tokenTextForSelector = (tokenizedBuffer, selectorType) ->
+tokenTextForSelector = (editor, selectorType) ->
   matchingTokens = []
-  for {tokens} in tokenizedBuffer.tokenizedLines
-      for token in tokens
-        if hasScope(token.scopes, "entity.other.attribute-name.#{selectorType}.css.tss") and !hasScope(token.scopes, "punctuation.definition.entity.css.#{selectorType}.tss")
-          matchingTokens.push token.value
+  editor.scan(selectorPatterns[selectorType],(item) ->
+    matchingTokens.push(item.match[2].split('[')[0]);
+  );
   matchingTokens
 
 hasScope = (scopesArray, scope) ->

trailingWhitespace = /\s$/
attributePattern = /\s+([a-zA-Z][-a-zA-Z]*)\s*=\s*$/
tagPattern = /<([a-zA-Z][-a-zA-Z]*)(?:\s|$)/

module.exports =
  selector: '.text.alloyxml, .text.xml'

    if attribute == 'id' or attribute == 'class'
      sourceEditor = util.getFileEditor related.getTargetPath('tss')
      if(!sourceEditor.isEmpty())
        values = tokenTextForSelector(sourceEditor, attribute)
        fileName = _.last(sourceEditor.getPath().split('/'))
        for value in values when not prefix or firstCharsEqual(value, prefix)
          completions.push @buildStyleSelectorCompletion(attribute, value, fileName)
