Remove deserializer shims on window

This commit is contained in:
Kevin Sawicki 2013-11-20 13:51:12 -08:00
parent 71e8e865f2
commit 2eeb399cf1
15 changed files with 20 additions and 30 deletions

View File

@ -95,7 +95,7 @@
"metrics": "0.12.0",
"package-generator": "0.20.0",
"release-notes": "0.12.0",
"settings-view": "0.44.0",
"settings-view": "0.45.0",
"snippets": "0.15.0",
"spell-check": "0.14.0",
"status-bar": "0.19.0",

View File

@ -14,7 +14,7 @@ describe "the `atom` global", ->
pack = atom.packages.loadPackage('package-with-activation-events')
spyOn(pack, 'activateStylesheets').andCallThrough()
expect(pack.mainModule).toBeNull()
object = deserialize({deserializer: 'Foo', data: 5})
object = atom.deserializers.deserialize({deserializer: 'Foo', data: 5})
expect(pack.mainModule).toBeDefined()
expect(object.constructor.name).toBe 'Foo'
expect(object.data).toBe 5

View File

@ -20,7 +20,7 @@ describe "DisplayBuffer", ->
displayBuffer.setTabLength(4)
displayBuffer.setEditorWidthInChars(64)
displayBuffer.createFold(2, 4)
displayBuffer2 = deserialize(displayBuffer.serialize())
displayBuffer2 = atom.deserializers.deserialize(displayBuffer.serialize())
expect(displayBuffer2.id).toBe displayBuffer.id
expect(displayBuffer2.buffer).toBe displayBuffer.buffer
expect(displayBuffer2.tokenizedBuffer.buffer).toBe displayBuffer.tokenizedBuffer.buffer

View File

@ -28,7 +28,7 @@ describe "Editor", ->
editor.foldBufferRow(4)
expect(editor.isFoldedAtBufferRow(4)).toBeTruthy()
editor2 = deserialize(editor.serialize())
editor2 = atom.deserializers.deserialize(editor.serialize())
expect(editor2.id).toBe editor.id
expect(editor2.getBuffer().getPath()).toBe editor.getBuffer().getPath()

View File

@ -9,7 +9,7 @@ describe "PaneContainer", ->
beforeEach ->
class TestView extends View
registerDeserializer(this)
atom.deserializers.add(this)
@deserialize: ({name}) -> new TestView(name)
@content: -> @div tabindex: -1
initialize: (@name) -> @text(@name)
@ -25,7 +25,7 @@ describe "PaneContainer", ->
pane3 = pane2.splitDown(new TestView('3'))
afterEach ->
unregisterDeserializer(TestView)
atom.deserializers.remove(TestView)
describe ".focusNextPane()", ->
it "focuses the pane following the focused pane or the first pane if no pane has focus", ->

View File

@ -16,7 +16,7 @@ describe "Pane", ->
isEqual: (other) -> @id == other.id and @text == other.text
beforeEach ->
registerDeserializer(TestView)
atom.deserializers.add(TestView)
container = new PaneContainer
view1 = new TestView(id: 'view-1', text: 'View 1')
view2 = new TestView(id: 'view-2', text: 'View 2')
@ -26,7 +26,7 @@ describe "Pane", ->
container.setRoot(pane)
afterEach ->
unregisterDeserializer(TestView)
atom.deserializers.remove(TestView)
describe ".initialize(items...)", ->
it "displays the first item in the pane", ->
@ -678,12 +678,12 @@ describe "Pane", ->
describe "serialization", ->
it "can serialize and deserialize the pane and all its items", ->
newPane = deserialize(pane.serialize())
newPane = atom.deserializers.deserialize(pane.serialize())
expect(newPane.getItems()).toEqual [view1, editor1, view2, editor2]
it "restores the active item on deserialization", ->
pane.showItem(editor2)
newPane = deserialize(pane.serialize())
newPane = atom.deserializers.deserialize(pane.serialize())
expect(newPane.activeItem).toEqual editor2
it "does not show items that cannot be deserialized", ->
@ -693,7 +693,7 @@ describe "Pane", ->
paneState = pane.serialize()
paneState.get('items').set(pane.items.indexOf(view2), {deserializer: 'Bogus'}) # nuke serialized state of active item
newPane = deserialize(paneState)
newPane = atom.deserializers.deserialize(paneState)
expect(newPane.activeItem).toEqual pane.items[0]
expect(newPane.items.length).toBe pane.items.length - 1
@ -704,7 +704,7 @@ describe "Pane", ->
container.remove()
project.destroy()
window.project = projectReplica
container = deserialize(containerState)
container = atom.deserializers.deserialize(containerState)
pane = container.getRoot()
container.attachToDom()

View File

@ -25,7 +25,7 @@ describe "RootView", ->
rootView.remove()
project.destroy()
window.project = project2
window.rootView = deserialize(rootViewState)
window.rootView = atom.deserializers.deserialize(rootViewState)
rootView.attachToDom()
describe "when the serialized RootView has an unsaved buffer", ->

View File

@ -15,7 +15,7 @@ describe "the `syntax` global", ->
filePath = '/foo/bar/file.js'
expect(atom.syntax.selectGrammar(filePath).name).not.toBe 'Ruby'
atom.syntax.setGrammarOverrideForPath(filePath, 'source.ruby')
syntax2 = deserialize(atom.syntax.serialize())
syntax2 = atom.deserializers.deserialize(atom.syntax.serialize())
syntax2.addGrammar(grammar) for grammar in atom.syntax.grammars when grammar isnt atom.syntax.nullGrammar
expect(syntax2.selectGrammar(filePath).name).toBe 'Ruby'

View File

@ -22,7 +22,7 @@ describe "TokenizedBuffer", ->
it "constructs a tokenized buffer with the same buffer and tabLength setting", ->
buffer = project.bufferForPathSync('sample.js')
tokenizedBuffer1 = new TokenizedBuffer(buffer: buffer, tabLength: 4)
tokenizedBuffer2 = deserialize(tokenizedBuffer1.serialize())
tokenizedBuffer2 = atom.deserializers.deserialize(tokenizedBuffer1.serialize())
expect(tokenizedBuffer2.buffer).toBe tokenizedBuffer1.buffer
expect(tokenizedBuffer2.getTabLength()).toBe tokenizedBuffer1.getTabLength()

View File

@ -18,7 +18,7 @@ class DisplayBuffer
_.extend @prototype, ConfigObserver
@acceptsDocuments: true
registerDeserializer(this)
atom.deserializers.add(this)
@version: 2
@deserialize: (state) -> new this(state)

View File

@ -42,7 +42,7 @@ class Editor
@acceptsDocuments: true
registerDeserializer(this)
atom.deserializers.add(this)
@version: 5

View File

@ -5,7 +5,7 @@ telepath = require 'telepath'
# Private: Manages the list of panes within a {RootView}
module.exports =
class PaneContainer extends View
registerDeserializer(this)
atom.deserializers.add(this)
### Internal ###
@acceptsDocuments: true

View File

@ -11,7 +11,7 @@ module.exports =
class Syntax
Emitter.includeInto(this)
registerDeserializer(this)
atom.deserializers.add(this)
@deserialize: ({grammarOverridesByPath}) ->
syntax = new Syntax()

View File

@ -21,7 +21,7 @@ class TokenizedBuffer
visible: false
@acceptsDocuments: true
registerDeserializer(this)
atom.deserializers.add(this)
@deserialize: (state) ->
new this(state)

View File

@ -93,16 +93,6 @@ window.deserializeEditorWindow = ->
window.onerror = ->
atom.openDevTools()
#TODO remove once all packages use the atom global
window.registerDeserializer = (args...) ->
atom.deserializers.add(args...)
window.unregisterDeserializer = (args...) ->
atom.deserializers.remove(args...)
window.deserialize = (args...) ->
atom.deserializers.deserialize(args...)
window.requireWithGlobals = (args...) ->
atom.requireWithGlobals(args...)
# Public: Measure how long a function takes to run.
#
# * description: