mirror of
https://github.com/atom/atom.git
synced 2026-02-14 16:45:14 -05:00
Load grammars from TextMatePackage. Delete TextMateBundle.
TextMatePackage is only designed to load resources out of a TextMate bundle. It's used only at load time, and from that point out we only refer to our own global `syntax` data structure to access the data that it loads.
This commit is contained in:
@@ -3,7 +3,7 @@ fs = require 'fs'
|
||||
|
||||
module.exports =
|
||||
class AtomPackage extends Package
|
||||
constructor: ->
|
||||
constructor: (@name) ->
|
||||
super
|
||||
@module = require(@path)
|
||||
@module.name = @name
|
||||
@@ -14,4 +14,4 @@ class AtomPackage extends Package
|
||||
extensionKeymapPath = require.resolve(fs.join(@name, "src/keymap"), verifyExistence: false)
|
||||
require extensionKeymapPath if fs.exists(extensionKeymapPath)
|
||||
catch e
|
||||
console.error "Failed to load package named '#{name}'", e.stack
|
||||
console.error "Failed to load package named '#{@name}'", e.stack
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
TextMateBundle = require("text-mate-bundle")
|
||||
fs = require 'fs'
|
||||
_ = require 'underscore'
|
||||
Package = require 'package'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
Range = require 'range'
|
||||
TextMateBundle = require 'text-mate-bundle'
|
||||
_ = require 'underscore'
|
||||
require 'underscore-extensions'
|
||||
|
||||
|
||||
@@ -17,5 +17,8 @@ class Package
|
||||
@path = fs.directory(@path) unless fs.isDirectory(@path)
|
||||
|
||||
load: ->
|
||||
for grammar in @getGrammars()
|
||||
syntax.addGrammar(grammar)
|
||||
|
||||
for { selector, properties } in @getScopedProperties()
|
||||
syntax.addProperties(selector, properties)
|
||||
|
||||
@@ -19,13 +19,6 @@ class TextMateBundle
|
||||
grammars: null
|
||||
|
||||
constructor: (@path) ->
|
||||
@grammars = []
|
||||
if fs.exists(@getSyntaxesPath())
|
||||
for syntaxPath in fs.list(@getSyntaxesPath())
|
||||
try
|
||||
@grammars.push TextMateGrammar.loadFromPath(syntaxPath)
|
||||
catch e
|
||||
console.warn "Failed to load grammar at path '#{syntaxPath}'", e
|
||||
|
||||
getSyntaxesPath: ->
|
||||
fs.join(@path, "Syntaxes")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
Package = require 'package'
|
||||
TextMateBundle = require 'text-mate-bundle'
|
||||
fs = require 'fs'
|
||||
plist = require 'plist'
|
||||
_ = require 'underscore'
|
||||
TextMateGrammar = require 'text-mate-grammar'
|
||||
|
||||
module.exports =
|
||||
class TextMatePackage extends Package
|
||||
@@ -18,20 +18,26 @@ class TextMatePackage extends Package
|
||||
).join(' ')
|
||||
).join(', ')
|
||||
|
||||
load: ->
|
||||
@bundle = TextMateBundle.load(@name)
|
||||
@grammars = @bundle.grammars
|
||||
super
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
@preferencesPath = fs.join(@path, "Preferences")
|
||||
@syntaxesPath = fs.join(@path, "Syntaxes")
|
||||
|
||||
getGrammars: ->
|
||||
return @grammars if @grammars
|
||||
@grammars = []
|
||||
if fs.exists(@syntaxesPath)
|
||||
for grammarPath in fs.list(@syntaxesPath)
|
||||
try
|
||||
@grammars.push TextMateGrammar.loadFromPath(grammarPath)
|
||||
catch e
|
||||
console.warn "Failed to load grammar at path '#{grammarPath}'", e.stack
|
||||
@grammars
|
||||
|
||||
getScopedProperties: ->
|
||||
scopedProperties = []
|
||||
|
||||
for grammar in @grammars
|
||||
for grammar in @getGrammars()
|
||||
if properties = @propertiesFromTextMateSettings(grammar)
|
||||
selector = @cssSelectorFromScopeSelector(grammar.scopeName)
|
||||
scopedProperties.push({selector, properties})
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
# the DOM window.
|
||||
|
||||
Native = require 'native'
|
||||
TextMateBundle = require 'text-mate-bundle'
|
||||
TextMateTheme = require 'text-mate-theme'
|
||||
fs = require 'fs'
|
||||
_ = require 'underscore'
|
||||
$ = require 'jquery'
|
||||
|
||||
Reference in New Issue
Block a user