 CSON = require 'season'
 
 class CsoundOrchestraGrammarPattern extends Pattern
-  @opcodes = (completion.opcode for completion in CSON.readFileSync(path.resolve(__dirname, '..', 'resources', 'opcode-completions.json')).completions)
+  @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)
+    tags[index] = @registry.startIdForScope scope
+    tags[index + 2] = @registry.endIdForScope scope
 
   handleMatch: (stack, line, captureIndicesArray, rule, endPatternMatch) ->
     tags = super

    @userDefinedOpcodesByTextEditors = {}

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

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

          when 'meta.other.csound'
            captureIndices = captureIndicesArray[captureIndicesArrayIndex]
            substring = line.substring captureIndices.start, captureIndices.end
            if /^p\d+$/.test substring
               # The substring is a parameter field.
              @setTagAtIndexToScope newTags, index, 'support.variable.csound'
            else if substring in CsoundOrchestraGrammarPattern.opcodes
