       # Odd negative numbers are begin-scope tags.
       if (tag % 2) is -1
         captureIndicesArrayIndex--
-        switch @registry.scopeForId(tag)
+        switch @registry.scopeForId tag
           when 'entity.name.function.opcode.csound'
             # Add names of user-defined opcodes to the opcode dictionary so they
             # can be scoped as function names.

    @userDefinedOpcodesByTextEditors = {}

  createPattern: (options) ->
    new CsoundOrchestraGrammarPattern(this, @registry, options)

  userDefinedOpcodesForTextEditor: (editor) ->
    userDefinedOpcodes = @userDefinedOpcodesByTextEditors[editor]

CSON = require 'season'

class CsoundOrchestraGrammarPattern extends Pattern
  @opcodes = (completion.opcode for completion in CSON.readFileSync(path.resolve __dirname, '..', 'resources', 'opcode-completions.json').completions)

  setTagAtIndexToScope: (tags, index, scope) ->
    tags[index] = @registry.startIdForScope scope
    tags[index + 2] = @registry.endIdForScope scope

  handleMatch: (stack, line, captureIndicesArray, rule, endPatternMatch) ->
    tags = super
