mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-12-28 17:13:45 +03: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:
parent
188d8f8604
commit
08a27cf93d
@ -5,8 +5,6 @@ Keymap = require 'keymap'
|
||||
Point = require 'point'
|
||||
Config = require 'config'
|
||||
Project = require 'project'
|
||||
TextMateBundle = require 'text-mate-bundle'
|
||||
TextMateTheme = require 'text-mate-theme'
|
||||
|
||||
require 'window'
|
||||
requireStylesheet "jasmine.css"
|
||||
|
@ -3,7 +3,6 @@ fs = require 'fs'
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
TokenizedBuffer = require 'tokenized-buffer'
|
||||
TextMateBundle = require 'text-mate-bundle'
|
||||
|
||||
describe "editor.", ->
|
||||
editor = null
|
||||
|
@ -1,7 +1,6 @@
|
||||
Project = require 'project'
|
||||
Buffer = require 'buffer'
|
||||
EditSession = require 'edit-session'
|
||||
TextMateBundle = require 'text-mate-bundle'
|
||||
|
||||
describe "EditSession", ->
|
||||
[buffer, editSession, lineLengths] = []
|
||||
|
@ -1,11 +0,0 @@
|
||||
fs = require('fs')
|
||||
TextMateBundle = require 'text-mate-bundle'
|
||||
|
||||
describe "TextMateBundle", ->
|
||||
describe ".constructor(bundlePath)", ->
|
||||
it "logs warning, but does not raise errors if a grammar can't be parsed", ->
|
||||
bundlePath = fs.join(require.resolve('fixtures'), "test.tmbundle")
|
||||
spyOn(console, 'warn')
|
||||
expect(-> new TextMateBundle(bundlePath)).not.toThrow()
|
||||
expect(console.warn).toHaveBeenCalled()
|
||||
|
@ -9,8 +9,6 @@ Directory = require 'directory'
|
||||
File = require 'file'
|
||||
RootView = require 'root-view'
|
||||
Editor = require 'editor'
|
||||
TextMateBundle = require 'text-mate-bundle'
|
||||
TextMateTheme = require 'text-mate-theme'
|
||||
TokenizedBuffer = require 'tokenized-buffer'
|
||||
fs = require 'fs'
|
||||
require 'window'
|
||||
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user