     @trigger 'grammar-updated'
     true
 
-  getScore: (path, contents) ->
-    contents = fsUtils.read(path) if not contents? and fsUtils.isFileSync(path)
-
-    if syntax.grammarOverrideForPath(path) is @scopeName
+  getScore: (filePath, contents) ->
+    contents = fsUtils.read(filePath) if not contents? and fsUtils.isFileSync(filePath)
+
+    if syntax.grammarOverrideForPath(filePath) is @scopeName
       3
     else if @matchesContents(contents)
       2
-    else if @matchesPath(path)
+    else if @matchesPath(filePath)
       1
     else
       -1

plist = require 'plist'
Token = require 'token'
{OnigRegExp, OnigScanner} = require 'oniguruma'
nodePath = require 'path'
EventEmitter = require 'event-emitter'
pathSplitRegex = new RegExp("[#{nodePath.sep}.]")
TextMateScopeSelector = require 'text-mate-scope-selector'

### Internal ###

module.exports =
class TextMateGrammar
  @load: (path, done) ->
    fsUtils.readObject path, (err, object) ->
      if err
        done(err)
      else
        done(null, new TextMateGrammar(object))

  @loadSync: (path) ->
    new TextMateGrammar(fsUtils.readObjectSync(path))

  name: null
  rawPatterns: null

    lines = contents.split('\n')
    @firstLineRegex.test(lines[0..numberOfNewlinesInRegex].join('\n'))

  matchesPath: (filePath) ->
    return false unless filePath?
    pathComponents = filePath.split(pathSplitRegex)
    _.find @fileTypes, (fileType) ->
      fileTypeComponents = fileType.split(pathSplitRegex)
      pathSuffix = pathComponents[-fileTypeComponents.length..-1]
