Revert "Move snippet body parsing to web worker"

This reverts commit 5b541ccc2b.
It caused the snippets spec to break. I'll try to achieve the same
thing without that happening.
This commit is contained in:
Nathan Sobo
2013-01-27 11:40:01 -07:00
parent 19a7c04b8f
commit 5bfb9feeda
2 changed files with 6 additions and 11 deletions

View File

@@ -1,5 +1,7 @@
AtomPackage = require 'atom-package'
fs = require 'fs'
PEG = require 'pegjs'
_ = require 'underscore'
SnippetExpansion = require './src/snippet-expansion'
Snippet = require './src/snippet'
LoadSnippetsTask = require './src/load-snippets-task'
@@ -8,6 +10,7 @@ module.exports =
class Snippets extends AtomPackage
snippetsByExtension: {}
parser: PEG.buildParser(fs.read(require.resolve 'snippets/snippets.pegjs'), trackLineAndColumn: true)
loaded: false
activate: (@rootView) ->
@@ -33,7 +36,8 @@ class Snippets extends AtomPackage
for selector, snippetsByName of snippetsBySelector
snippetsByPrefix = {}
for name, attributes of snippetsByName
{ prefix, body, bodyTree } = attributes
{ prefix, body } = attributes
bodyTree = @parser.parse(body)
snippet = new Snippet({name, prefix, bodyTree})
snippetsByPrefix[snippet.prefix] = snippet
syntax.addProperties(selector, snippets: snippetsByPrefix)

View File

@@ -1,17 +1,8 @@
fs = require 'fs'
TextMatePackage = require 'text-mate-package'
PEG = require 'pegjs'
module.exports =
parser: PEG.buildParser(fs.read(require.resolve 'snippets/snippets.pegjs'), trackLineAndColumn: true)
snippetsLoaded: (snippets) ->
for snippet in snippets
for selector, snippetsByName of snippet
for name, attributes of snippetsByName
attributes.bodyTree = @parser.parse(attributes.body)
callTaskMethod('snippetsLoaded', snippets)
snippetsLoaded: (snippets) -> callTaskMethod('snippetsLoaded', snippets)
loadTextmateSnippets: (path) ->
snippetsDirPath = fs.join(path, 'Snippets')