Merge branch 'master' into as-display-buffer-logical-coordinates

# Conflicts:
#	src/display-buffer.coffee
This commit is contained in:
Antonio Scandurra 2015-09-23 18:46:16 +02:00
commit 91ef57ed29
49 changed files with 254 additions and 1829 deletions

View File

@ -90,10 +90,6 @@ module.exports = (grunt) ->
path.join('snippets', 'node_modules', 'pegjs')
path.join('snippets', 'node_modules', '.bin', 'pegjs')
# These aren't needed since WeakMap is built-in
path.join('emissary', 'node_modules', 'es6-weak-map')
path.join('property-accessors', 'node_modules', 'es6-weak-map')
'.DS_Store'
'.jshintrc'
'.npmignore'

View File

@ -2,7 +2,6 @@ TextBuffer = require 'text-buffer'
{Point, Range} = TextBuffer
{File, Directory} = require 'pathwatcher'
{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
{includeDeprecatedAPIs, deprecate} = require 'grim'
module.exports =
BufferedNodeProcess: require '../src/buffered-node-process'
@ -23,8 +22,3 @@ module.exports =
unless process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE
module.exports.Task = require '../src/task'
module.exports.TextEditor = require '../src/text-editor'
if includeDeprecatedAPIs
Object.defineProperty module.exports, 'Git', get: ->
deprecate "Please require `GitRepository` instead of `Git`: `{GitRepository} = require 'atom'`"
module.exports.GitRepository

View File

@ -21,8 +21,6 @@
"clear-cut": "^2.0.1",
"coffee-script": "1.8.0",
"color": "^0.7.3",
"delegato": "^1",
"emissary": "^1.3.3",
"event-kit": "^1.3.0",
"first-mate": "^5.0.0",
"fs-plus": "^2.8.0",
@ -35,12 +33,10 @@
"jquery": "^2.1.1",
"less-cache": "0.22",
"marked": "^0.3.4",
"mixto": "^1",
"normalize-package-data": "^2.0.0",
"nslog": "^2.0.0",
"oniguruma": "^4.2.4",
"pathwatcher": "^5.0.0",
"property-accessors": "^1.1.3",
"random-words": "0.0.1",
"runas": "2.0.0",
"scandal": "2.1.2",
@ -48,13 +44,11 @@
"scrollbar-style": "^3.1",
"season": "^5.3",
"semver": "^4.3.3",
"serializable": "^1",
"service-hub": "^0.6.2",
"source-map-support": "^0.3.2",
"stacktrace-parser": "0.1.1",
"temp": "0.8.1",
"text-buffer": "7.0.3",
"theorist": "^1.0.2",
"typescript-simple": "1.0.0",
"underscore-plus": "^1.6.6",
"yargs": "^3.23.0"
@ -66,10 +60,10 @@
"atom-light-ui": "0.43.0",
"base16-tomorrow-dark-theme": "0.27.0",
"base16-tomorrow-light-theme": "0.9.0",
"one-dark-ui": "1.1.3",
"one-dark-ui": "1.1.4",
"one-dark-syntax": "1.1.0",
"one-light-syntax": "1.1.0",
"one-light-ui": "1.1.3",
"one-light-ui": "1.1.4",
"solarized-dark-syntax": "0.38.1",
"solarized-light-syntax": "0.22.1",
"about": "1.1.0",
@ -99,7 +93,7 @@
"keybinding-resolver": "0.33.0",
"line-ending-selector": "0.0.5",
"link": "0.30.0",
"markdown-preview": "0.152.0",
"markdown-preview": "0.154.0",
"metrics": "0.51.0",
"notifications": "0.59.0",
"open-on-github": "0.38.0",

View File

@ -2,7 +2,6 @@ path = require 'path'
temp = require 'temp'
CSON = require 'season'
fs = require 'fs-plus'
Grim = require 'grim'
describe "Config", ->
dotAtomPath = null
@ -364,16 +363,6 @@ describe "Config", ->
expect(atom.config.save).not.toHaveBeenCalled()
expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee'])).toBe 55
it "deprecates passing a scope selector as the first argument", ->
atom.config.setDefaults("foo", bar: baz: 10)
atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee')
spyOn(Grim, 'deprecate')
atom.config.unset('.source.coffee', 'foo.bar.baz')
expect(Grim.deprecate).toHaveBeenCalled()
expect(atom.config.get('foo.bar.baz', scope: ['.source.coffee'])).toBe 10
describe ".onDidChange(keyPath, {scope})", ->
[observeHandler, observeSubscription] = []
@ -458,15 +447,6 @@ describe "Config", ->
expect(changeSpy).toHaveBeenCalledWith({oldValue: 12, newValue: undefined})
changeSpy.reset()
it 'deprecates using a scope descriptor as an optional first argument', ->
keyPath = "foo.bar.baz"
spyOn(Grim, 'deprecate')
atom.config.onDidChange [".source.coffee", ".string.quoted.double.coffee"], keyPath, changeSpy = jasmine.createSpy()
expect(Grim.deprecate).toHaveBeenCalled()
atom.config.set("foo.bar.baz", 12)
expect(changeSpy).toHaveBeenCalledWith({oldValue: undefined, newValue: 12})
describe ".observe(keyPath, {scope})", ->
[observeHandler, observeSubscription] = []
@ -535,16 +515,6 @@ describe "Config", ->
expect(observeHandler).toHaveBeenCalledWith("value 2")
expect(otherHandler).not.toHaveBeenCalledWith("value 2")
it "deprecates using a scope descriptor as the first argument", ->
spyOn(Grim, 'deprecate')
atom.config.observe([".some.scope"], "foo.bar.baz", observeHandler)
atom.config.observe([".another.scope"], "foo.bar.baz", otherHandler)
expect(Grim.deprecate).toHaveBeenCalled()
atom.config.set('foo.bar.baz', "value 2", scopeSelector: ".some")
expect(observeHandler).toHaveBeenCalledWith("value 2")
expect(otherHandler).not.toHaveBeenCalledWith("value 2")
it 'calls the callback when properties with more specific selectors are removed', ->
changeSpy = jasmine.createSpy()
atom.config.observe("foo.bar.baz", scope: [".source.coffee", ".string.quoted.double.coffee"], changeSpy)
@ -1629,135 +1599,3 @@ describe "Config", ->
expect(atom.config.set('foo.bar.arr', ['two', 'three'])).toBe true
expect(atom.config.get('foo.bar.arr')).toEqual ['two', 'three']
describe "Deprecated Methods", ->
describe ".getDefault(keyPath)", ->
it "returns a clone of the default value", ->
atom.config.setDefaults("foo", same: 1, changes: 1)
spyOn(Grim, 'deprecate')
expect(atom.config.getDefault('foo.same')).toBe 1
expect(atom.config.getDefault('foo.changes')).toBe 1
expect(Grim.deprecate.callCount).toBe 2
atom.config.set('foo.same', 2)
atom.config.set('foo.changes', 3)
expect(atom.config.getDefault('foo.same')).toBe 1
expect(atom.config.getDefault('foo.changes')).toBe 1
expect(Grim.deprecate.callCount).toBe 4
initialDefaultValue = [1, 2, 3]
atom.config.setDefaults("foo", bar: initialDefaultValue)
expect(atom.config.getDefault('foo.bar')).toEqual initialDefaultValue
expect(atom.config.getDefault('foo.bar')).not.toBe initialDefaultValue
expect(Grim.deprecate.callCount).toBe 6
describe "when scoped settings are used", ->
it "returns the global default when no scoped default set", ->
atom.config.setDefaults("foo", bar: baz: 10)
spyOn(Grim, 'deprecate')
expect(atom.config.getDefault('.source.coffee', 'foo.bar.baz')).toBe 10
expect(Grim.deprecate).toHaveBeenCalled()
it "returns the scoped settings not including the user's config file", ->
atom.config.setDefaults("foo", bar: baz: 10)
atom.config.set("foo.bar.baz", 42, scopeSelector: ".source.coffee", source: "some-source")
spyOn(Grim, 'deprecate')
expect(atom.config.getDefault('.source.coffee', 'foo.bar.baz')).toBe 42
expect(Grim.deprecate.callCount).toBe 1
atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee')
expect(atom.config.getDefault('.source.coffee', 'foo.bar.baz')).toBe 42
expect(Grim.deprecate.callCount).toBe 2
describe ".isDefault(keyPath)", ->
it "returns true when the value of the key path is its default value", ->
atom.config.setDefaults("foo", same: 1, changes: 1)
spyOn(Grim, 'deprecate')
expect(atom.config.isDefault('foo.same')).toBe true
expect(atom.config.isDefault('foo.changes')).toBe true
expect(Grim.deprecate.callCount).toBe 2
atom.config.set('foo.same', 2)
atom.config.set('foo.changes', 3)
expect(atom.config.isDefault('foo.same')).toBe false
expect(atom.config.isDefault('foo.changes')).toBe false
expect(Grim.deprecate.callCount).toBe 4
describe "when scoped settings are used", ->
it "returns false when a scoped setting was set by the user", ->
spyOn(Grim, 'deprecate')
expect(atom.config.isDefault('.source.coffee', 'foo.bar.baz')).toBe true
expect(Grim.deprecate.callCount).toBe 1
atom.config.set("foo.bar.baz", 42, scopeSelector: ".source.coffee", source: "something-else")
expect(atom.config.isDefault('.source.coffee', 'foo.bar.baz')).toBe true
expect(Grim.deprecate.callCount).toBe 2
atom.config.set('foo.bar.baz', 55, scopeSelector: '.source.coffee')
expect(atom.config.isDefault('.source.coffee', 'foo.bar.baz')).toBe false
expect(Grim.deprecate.callCount).toBe 3
describe ".toggle(keyPath)", ->
beforeEach ->
jasmine.snapshotDeprecations()
afterEach ->
jasmine.restoreDeprecationsSnapshot()
it "negates the boolean value of the current key path value", ->
atom.config.set('foo.a', 1)
atom.config.toggle('foo.a')
expect(atom.config.get('foo.a')).toBe false
atom.config.set('foo.a', '')
atom.config.toggle('foo.a')
expect(atom.config.get('foo.a')).toBe true
atom.config.set('foo.a', null)
atom.config.toggle('foo.a')
expect(atom.config.get('foo.a')).toBe true
atom.config.set('foo.a', true)
atom.config.toggle('foo.a')
expect(atom.config.get('foo.a')).toBe false
describe ".getSettings()", ->
it "returns all settings including defaults", ->
atom.config.setDefaults("foo", bar: baz: 10)
atom.config.set("foo.ok", 12)
jasmine.snapshotDeprecations()
expect(atom.config.getSettings().foo).toEqual
ok: 12
bar:
baz: 10
jasmine.restoreDeprecationsSnapshot()
describe ".getPositiveInt(keyPath, defaultValue)", ->
beforeEach ->
jasmine.snapshotDeprecations()
afterEach ->
jasmine.restoreDeprecationsSnapshot()
it "returns the proper coerced value", ->
atom.config.set('editor.preferredLineLength', 0)
expect(atom.config.getPositiveInt('editor.preferredLineLength', 80)).toBe 1
it "returns the proper coerced value", ->
atom.config.set('editor.preferredLineLength', -1234)
expect(atom.config.getPositiveInt('editor.preferredLineLength', 80)).toBe 1
it "returns the default value when a string is passed in", ->
atom.config.set('editor.preferredLineLength', 'abcd')
expect(atom.config.getPositiveInt('editor.preferredLineLength', 80)).toBe 80
it "returns the default value when null is passed in", ->
atom.config.set('editor.preferredLineLength', null)
expect(atom.config.getPositiveInt('editor.preferredLineLength', 80)).toBe 80

View File

@ -156,32 +156,3 @@ describe "ContextMenuManager", ->
catch error
addError = error
expect(addError.message).toContain('<>')
describe "when the menus are specified in a legacy format", ->
beforeEach ->
jasmine.snapshotDeprecations()
afterEach ->
jasmine.restoreDeprecationsSnapshot()
it "allows items to be specified in the legacy format for now", ->
contextMenu.add '.parent':
'A': 'a'
'Separator 1': '-'
'B':
'C': 'c'
'Separator 2': '-'
'D': 'd'
expect(contextMenu.templateForElement(parent)).toEqual [
{label: 'A', command: 'a'}
{type: 'separator'}
{
label: 'B'
submenu: [
{label: 'C', command: 'c'}
{type: 'separator'}
{label: 'D', command: 'd'}
]
}
]

View File

@ -232,7 +232,8 @@ describe "DisplayBuffer", ->
describe "when a newline is inserted, deleted, and re-inserted at the end of a wrapped line (regression)", ->
it "correctly renders the original wrapped line", ->
buffer = atom.project.buildBufferSync(null, '')
displayBuffer = new DisplayBuffer({buffer, tabLength, editorWidthInChars: 30, softWrapped: true})
displayBuffer = new DisplayBuffer({buffer, tabLength, editorWidthInChars: 30})
displayBuffer.setSoftWrapped(true)
buffer.insert([0, 0], "the quick brown fox jumps over the lazy dog.")
buffer.insert([0, Infinity], '\n')

View File

@ -1,3 +1,4 @@
{Git} = require 'atom'
{deprecate} = require 'grim'
deprecate('Fake task deprecation')
module.exports = ->

View File

@ -3,6 +3,7 @@ GitRepository = require '../src/git-repository'
fs = require 'fs-plus'
path = require 'path'
Task = require '../src/task'
Project = require '../src/project'
copyRepository = ->
workingDirPath = temp.mkdirSync('atom-working-dir')
@ -276,7 +277,7 @@ describe "GitRepository", ->
atom.workspace.open('file.txt')
runs ->
project2 = atom.project.testSerialization()
project2 = Project.deserialize(atom.project.serialize())
buffer = project2.getBuffers()[0]
waitsFor ->

View File

@ -52,7 +52,7 @@ describe "MenuManager", ->
it "sends the current menu template and associated key bindings to the browser process", ->
spyOn(menu, 'sendToBrowserProcess')
menu.add [{label: "A", submenu: [{label: "B", command: "b"}]}]
atom.keymap.add 'test', 'atom-workspace': 'ctrl-b': 'b'
atom.keymaps.add 'test', 'atom-workspace': 'ctrl-b': 'b'
menu.update()
waits 1
@ -64,8 +64,8 @@ describe "MenuManager", ->
# more dynamic interaction between the currently focused element and the menu
spyOn(menu, 'sendToBrowserProcess')
menu.add [{label: "A", submenu: [{label: "B", command: "b"}]}]
atom.keymap.add 'test', 'atom-workspace': 'ctrl-b': 'b'
atom.keymap.add 'test', 'atom-text-editor': 'ctrl-b': 'unset!'
atom.keymaps.add 'test', 'atom-workspace': 'ctrl-b': 'b'
atom.keymaps.add 'test', 'atom-text-editor': 'ctrl-b': 'unset!'
waits 1

View File

@ -62,17 +62,7 @@ describe "PackageManager", ->
expect(console.warn.argsForCall[0][0]).toContain("Could not resolve")
describe "when the package is deprecated", ->
grim = require 'grim'
includeDeprecatedAPIs = null
beforeEach ->
{includeDeprecatedAPIs} = grim
afterEach ->
grim.includeDeprecatedAPIs = includeDeprecatedAPIs
it "returns null", ->
grim.includeDeprecatedAPIs = false
expect(atom.packages.loadPackage(path.join(__dirname, 'fixtures', 'packages', 'wordcount'))).toBeNull()
expect(atom.packages.isDeprecatedPackage('wordcount', '2.1.9')).toBe true
expect(atom.packages.isDeprecatedPackage('wordcount', '2.2.0')).toBe true
@ -174,24 +164,6 @@ describe "PackageManager", ->
expect(atom.config.set('package-with-config-schema.numbers.one', '10')).toBe true
expect(atom.config.get('package-with-config-schema.numbers.one')).toBe 10
describe "when a package has configDefaults", ->
beforeEach ->
jasmine.snapshotDeprecations()
afterEach ->
jasmine.restoreDeprecationsSnapshot()
it "still assigns configDefaults from the module though deprecated", ->
expect(atom.config.get('package-with-config-defaults.numbers.one')).toBeUndefined()
waitsForPromise ->
atom.packages.activatePackage('package-with-config-defaults')
runs ->
expect(atom.config.get('package-with-config-defaults.numbers.one')).toBe 1
expect(atom.config.get('package-with-config-defaults.numbers.two')).toBe 2
describe "when the package metadata includes `activationCommands`", ->
[mainModule, promise, workspaceCommandListener, registration] = []
@ -914,66 +886,3 @@ describe "PackageManager", ->
expect(atom.config.get('core.themes')).not.toContain packageName
expect(atom.config.get('core.themes')).not.toContain packageName
expect(atom.config.get('core.disabledPackages')).not.toContain packageName
describe "deleting non-bundled autocomplete packages", ->
[autocompleteCSSPath, autocompletePlusPath] = []
fs = require 'fs-plus'
path = require 'path'
beforeEach ->
fixturePath = path.resolve(__dirname, './fixtures/packages')
autocompleteCSSPath = path.join(fixturePath, 'autocomplete-css')
autocompletePlusPath = path.join(fixturePath, 'autocomplete-plus')
try
fs.mkdirSync(autocompleteCSSPath)
fs.writeFileSync(path.join(autocompleteCSSPath, 'package.json'), '{}')
fs.symlinkSync(path.join(fixturePath, 'package-with-main'), autocompletePlusPath, 'dir')
expect(fs.isDirectorySync(autocompleteCSSPath)).toBe true
expect(fs.isSymbolicLinkSync(autocompletePlusPath)).toBe true
jasmine.unspy(atom.packages, 'uninstallAutocompletePlus')
afterEach ->
try
fs.unlink autocompletePlusPath, ->
it "removes the packages", ->
atom.packages.loadPackages()
waitsFor ->
not fs.isDirectorySync(autocompleteCSSPath)
runs ->
expect(fs.isDirectorySync(autocompleteCSSPath)).toBe false
expect(fs.isSymbolicLinkSync(autocompletePlusPath)).toBe true
describe "when the deprecated sublime-tabs package is installed", ->
grim = require 'grim'
includeDeprecatedAPIs = null
beforeEach ->
{includeDeprecatedAPIs} = grim
grim.includeDeprecatedAPIs = false
afterEach ->
grim.includeDeprecatedAPIs = includeDeprecatedAPIs
it "enables the tree-view and tabs package", ->
atom.config.pushAtKeyPath('core.disabledPackages', 'tree-view')
atom.config.pushAtKeyPath('core.disabledPackages', 'tabs')
spyOn(atom.packages, 'getAvailablePackagePaths').andReturn [
path.join(__dirname, 'fixtures', 'packages', 'sublime-tabs')
path.resolve(__dirname, '..', 'node_modules', 'tree-view')
path.resolve(__dirname, '..', 'node_modules', 'tabs')
]
atom.packages.loadPackages()
waitsFor ->
not atom.packages.isPackageDisabled('tree-view') and not atom.packages.isPackageDisabled('tabs')
runs ->
expect(atom.packages.isPackageLoaded('tree-view')).toBe true
expect(atom.packages.isPackageLoaded('tabs')).toBe true

View File

@ -21,7 +21,7 @@ describe "PaneContainer", ->
it "preserves the focused pane across serialization", ->
expect(pane3A.focused).toBe true
containerB = containerA.testSerialization()
containerB = PaneContainer.deserialize(containerA.serialize())
[pane1B, pane2B, pane3B] = containerB.getPanes()
expect(pane3B.focused).toBe true
@ -29,7 +29,7 @@ describe "PaneContainer", ->
pane3A.activate()
expect(containerA.getActivePane()).toBe pane3A
containerB = containerA.testSerialization()
containerB = PaneContainer.deserialize(containerA.serialize())
[pane1B, pane2B, pane3B] = containerB.getPanes()
expect(containerB.getActivePane()).toBe pane3B

View File

@ -1,4 +1,4 @@
{Model} = require 'theorist'
{Emitter} = require 'event-kit'
Pane = require '../src/pane'
PaneAxis = require '../src/pane-axis'
PaneContainer = require '../src/pane-container'
@ -6,13 +6,17 @@ PaneContainer = require '../src/pane-container'
describe "Pane", ->
deserializerDisposable = null
class Item extends Model
class Item
@deserialize: ({name, uri}) -> new this(name, uri)
constructor: (@name, @uri) ->
constructor: (@name, @uri) -> @emitter = new Emitter
destroyed: false
getURI: -> @uri
getPath: -> @path
serialize: -> {deserializer: 'Item', @name, @uri}
isEqual: (other) -> @name is other?.name
onDidDestroy: (fn) -> @emitter.on('did-destroy', fn)
destroy: -> @destroyed = true; @emitter.emit('did-destroy')
isDestroyed: -> @destroyed
beforeEach ->
deserializerDisposable = atom.deserializers.add(Item)
@ -728,12 +732,12 @@ describe "Pane", ->
pane = new Pane(params)
it "can serialize and deserialize the pane and all its items", ->
newPane = pane.testSerialization()
newPane = Pane.deserialize(pane.serialize())
expect(newPane.getItems()).toEqual pane.getItems()
it "restores the active item on deserialization", ->
pane.activateItemAtIndex(1)
newPane = pane.testSerialization()
newPane = Pane.deserialize(pane.serialize())
expect(newPane.getActiveItem()).toEqual newPane.itemAtIndex(1)
it "does not include items that cannot be deserialized", ->
@ -741,11 +745,11 @@ describe "Pane", ->
unserializable = {}
pane.activateItem(unserializable)
newPane = pane.testSerialization()
newPane = Pane.deserialize(pane.serialize())
expect(newPane.getActiveItem()).toEqual pane.itemAtIndex(0)
expect(newPane.getItems().length).toBe pane.getItems().length - 1
it "includes the pane's focus state in the serialized state", ->
pane.focus()
newPane = pane.testSerialization()
newPane = Pane.deserialize(pane.serialize())
expect(newPane.focused).toBe true

View File

@ -66,7 +66,7 @@ describe "Project", ->
runs ->
expect(atom.project.getBuffers().length).toBe 1
deserializedProject = atom.project.testSerialization()
deserializedProject = Project.deserialize(atom.project.serialize())
expect(deserializedProject.getBuffers().length).toBe 0
it "listens for destroyed events on deserialized buffers and removes them when they are destroyed", ->
@ -75,7 +75,7 @@ describe "Project", ->
runs ->
expect(atom.project.getBuffers().length).toBe 1
deserializedProject = atom.project.testSerialization()
deserializedProject = Project.deserialize(atom.project.serialize())
expect(deserializedProject.getBuffers().length).toBe 1
deserializedProject.getBuffers()[0].destroy()
@ -91,7 +91,7 @@ describe "Project", ->
runs ->
expect(atom.project.getBuffers().length).toBe 1
fs.mkdirSync(pathToOpen)
deserializedProject = atom.project.testSerialization()
deserializedProject = Project.deserialize(atom.project.serialize())
expect(deserializedProject.getBuffers().length).toBe 0
it "does not deserialize buffers when their path is inaccessible", ->
@ -104,7 +104,7 @@ describe "Project", ->
runs ->
expect(atom.project.getBuffers().length).toBe 1
fs.chmodSync(pathToOpen, '000')
deserializedProject = atom.project.testSerialization()
deserializedProject = Project.deserialize(atom.project.serialize())
expect(deserializedProject.getBuffers().length).toBe 0
describe "when an editor is saved and the project has no path", ->
@ -508,36 +508,3 @@ describe "Project", ->
randomPath = path.join("some", "random", "path")
expect(atom.project.contains(randomPath)).toBe false
describe ".eachBuffer(callback)", ->
beforeEach ->
jasmine.snapshotDeprecations()
atom.project.bufferForPathSync('a')
afterEach ->
jasmine.restoreDeprecationsSnapshot()
it "invokes the callback for existing buffer", ->
count = 0
count = 0
callbackBuffer = null
callback = (buffer) ->
callbackBuffer = buffer
count++
atom.project.eachBuffer(callback)
expect(count).toBe 1
expect(callbackBuffer).toBe atom.project.getBuffers()[0]
it "invokes the callback for new buffers", ->
count = 0
callbackBuffer = null
callback = (buffer) ->
callbackBuffer = buffer
count++
atom.project.eachBuffer(callback)
count = 0
callbackBuffer = null
atom.project.bufferForPathSync(require.resolve('./fixtures/sample.txt'))
expect(count).toBe 1
expect(callbackBuffer).toBe atom.project.getBuffers()[1]

View File

@ -156,8 +156,6 @@ beforeEach ->
spyOn(clipboard, 'writeText').andCallFake (text) -> clipboardContent = text
spyOn(clipboard, 'readText').andCallFake -> clipboardContent
spyOn(atom.packages, 'uninstallAutocompletePlus')
addCustomMatchers(this)
afterEach ->

View File

@ -1336,15 +1336,13 @@ describe "TextEditorComponent", ->
expect(lineAndLineNumberHaveClass(6, 'a')).toBe true
expect(lineAndLineNumberHaveClass(7, 'a')).toBe false
it "remove decoration classes and unsubscribes from markers decorations are removed", ->
expect(marker.getSubscriptionCount('changed'))
it "remove decoration classes when decorations are removed", ->
decoration.destroy()
nextAnimationFrame()
expect(lineNumberHasClass(1, 'a')).toBe false
expect(lineNumberHasClass(2, 'a')).toBe false
expect(lineNumberHasClass(3, 'a')).toBe false
expect(lineNumberHasClass(4, 'a')).toBe false
expect(marker.getSubscriptionCount('changed')).toBe 0
it "removes decorations when their marker is invalidated", ->
editor.getBuffer().insert([3, 2], 'n')

View File

@ -31,7 +31,7 @@ describe "TextEditor", ->
runs ->
fs.mkdirSync(pathToOpen)
expect(editor1.testSerialization()).toBeUndefined()
expect(TextEditor.deserialize(editor1.serialize())).toBeUndefined()
it "restores selections and folds based on markers in the buffer", ->
editor.setSelectedBufferRange([[1, 2], [3, 4]])
@ -39,7 +39,7 @@ describe "TextEditor", ->
editor.foldBufferRow(4)
expect(editor.isFoldedAtBufferRow(4)).toBeTruthy()
editor2 = editor.testSerialization()
editor2 = TextEditor.deserialize(editor.serialize())
expect(editor2.id).toBe editor.id
expect(editor2.getBuffer().getPath()).toBe editor.getBuffer().getPath()
@ -52,7 +52,7 @@ describe "TextEditor", ->
atom.config.set('editor.showInvisibles', true)
previousInvisibles = editor.tokenizedLineForScreenRow(0).invisibles
editor2 = editor.testSerialization()
editor2 = TextEditor.deserialize(editor.serialize())
expect(previousInvisibles).toBeDefined()
expect(editor2.displayBuffer.tokenizedLineForScreenRow(0).invisibles).toEqual previousInvisibles
@ -4787,18 +4787,6 @@ describe "TextEditor", ->
beforeEach ->
marker = editor.markBufferRange([[1, 0], [1, 0]])
it "casts 'gutter' type to 'line-number' unless a gutter name is specified.", ->
jasmine.snapshotDeprecations()
lineNumberDecoration = editor.decorateMarker(marker, {type: 'gutter'})
customGutterDecoration = editor.decorateMarker(marker, {type: 'gutter', gutterName: 'custom'})
expect(lineNumberDecoration.getProperties().type).toBe 'line-number'
expect(lineNumberDecoration.getProperties().gutterName).toBe 'line-number'
expect(customGutterDecoration.getProperties().type).toBe 'gutter'
expect(customGutterDecoration.getProperties().gutterName).toBe 'custom'
jasmine.restoreDeprecationsSnapshot()
it 'reflects an added decoration when one of its custom gutters is decorated.', ->
gutter = editor.addGutter {'name': 'custom-gutter'}
decoration = gutter.decorateMarker marker, {class: 'custom-class'}

View File

@ -2,19 +2,17 @@ path = require 'path'
fs = require 'fs-plus'
temp = require 'temp'
ThemeManager = require '../src/theme-manager'
Package = require '../src/package'
describe "ThemeManager", ->
themeManager = null
describe "atom.themes", ->
resourcePath = atom.getLoadSettings().resourcePath
configDirPath = atom.getConfigDirPath()
beforeEach ->
themeManager = new ThemeManager({packageManager: atom.packages, resourcePath, configDirPath})
spyOn(console, 'warn')
afterEach ->
themeManager.deactivateThemes()
atom.themes.deactivateThemes()
describe "theme getters and setters", ->
beforeEach ->
@ -26,17 +24,17 @@ describe "ThemeManager", ->
describe 'getLoadedThemes', ->
it 'gets all the loaded themes', ->
themes = themeManager.getLoadedThemes()
themes = atom.themes.getLoadedThemes()
expect(themes.length).toBeGreaterThan(2)
describe "getActiveThemes", ->
it 'gets all the active themes', ->
waitsForPromise -> themeManager.activateThemes()
waitsForPromise -> atom.themes.activateThemes()
runs ->
names = atom.config.get('core.themes')
expect(names.length).toBeGreaterThan(0)
themes = themeManager.getActiveThemes()
themes = atom.themes.getActiveThemes()
expect(themes).toHaveLength(names.length)
describe "when the core.themes config value contains invalid entry", ->
@ -53,13 +51,13 @@ describe "ThemeManager", ->
'atom-dark-ui'
]
expect(themeManager.getEnabledThemeNames()).toEqual ['atom-dark-ui', 'atom-light-ui']
expect(atom.themes.getEnabledThemeNames()).toEqual ['atom-dark-ui', 'atom-light-ui']
describe "::getImportPaths()", ->
it "returns the theme directories before the themes are loaded", ->
atom.config.set('core.themes', ['theme-with-index-less', 'atom-dark-ui', 'atom-light-ui'])
paths = themeManager.getImportPaths()
paths = atom.themes.getImportPaths()
# syntax theme is not a dir at this time, so only two.
expect(paths.length).toBe 2
@ -68,21 +66,21 @@ describe "ThemeManager", ->
it "ignores themes that cannot be resolved to a directory", ->
atom.config.set('core.themes', ['definitely-not-a-theme'])
expect(-> themeManager.getImportPaths()).not.toThrow()
expect(-> atom.themes.getImportPaths()).not.toThrow()
describe "when the core.themes config value changes", ->
it "add/removes stylesheets to reflect the new config value", ->
themeManager.onDidChangeActiveThemes didChangeActiveThemesHandler = jasmine.createSpy()
atom.themes.onDidChangeActiveThemes didChangeActiveThemesHandler = jasmine.createSpy()
spyOn(atom.styles, 'getUserStyleSheetPath').andCallFake -> null
waitsForPromise ->
themeManager.activateThemes()
atom.themes.activateThemes()
runs ->
didChangeActiveThemesHandler.reset()
atom.config.set('core.themes', [])
waitsFor ->
waitsFor 'a', ->
didChangeActiveThemesHandler.callCount is 1
runs ->
@ -90,7 +88,7 @@ describe "ThemeManager", ->
expect(document.querySelectorAll('style.theme')).toHaveLength 0
atom.config.set('core.themes', ['atom-dark-ui'])
waitsFor ->
waitsFor 'b', ->
didChangeActiveThemesHandler.callCount is 1
runs ->
@ -99,7 +97,7 @@ describe "ThemeManager", ->
expect(document.querySelector('style[priority="1"]').getAttribute('source-path')).toMatch /atom-dark-ui/
atom.config.set('core.themes', ['atom-light-ui', 'atom-dark-ui'])
waitsFor ->
waitsFor 'c', ->
didChangeActiveThemesHandler.callCount is 1
runs ->
@ -123,22 +121,22 @@ describe "ThemeManager", ->
runs ->
expect(document.querySelectorAll('style[priority="1"]')).toHaveLength 2
importPaths = themeManager.getImportPaths()
importPaths = atom.themes.getImportPaths()
expect(importPaths.length).toBe 1
expect(importPaths[0]).toContain 'atom-dark-ui'
it 'adds theme-* classes to the workspace for each active theme', ->
atom.config.set('core.themes', ['atom-dark-ui', 'atom-dark-syntax'])
workspaceElement = atom.views.getView(atom.workspace)
themeManager.onDidChangeActiveThemes didChangeActiveThemesHandler = jasmine.createSpy()
atom.themes.onDidChangeActiveThemes didChangeActiveThemesHandler = jasmine.createSpy()
waitsForPromise ->
themeManager.activateThemes()
atom.themes.activateThemes()
runs ->
expect(workspaceElement).toHaveClass 'theme-atom-dark-ui'
themeManager.onDidChangeActiveThemes didChangeActiveThemesHandler = jasmine.createSpy()
atom.themes.onDidChangeActiveThemes didChangeActiveThemesHandler = jasmine.createSpy()
atom.config.set('core.themes', ['theme-with-ui-variables', 'theme-with-syntax-variables'])
waitsFor ->
@ -153,8 +151,8 @@ describe "ThemeManager", ->
describe "when a theme fails to load", ->
it "logs a warning", ->
spyOn(console, 'warn')
atom.packages.activatePackage('a-theme-that-will-not-be-found')
console.warn.reset()
atom.packages.activatePackage('a-theme-that-will-not-be-found').then((->), (->))
expect(console.warn.callCount).toBe 1
expect(console.warn.argsForCall[0][0]).toContain "Could not resolve 'a-theme-that-will-not-be-found'"
@ -167,27 +165,22 @@ describe "ThemeManager", ->
it "synchronously loads css at the given path and installs a style tag for it in the head", ->
atom.styles.onDidAddStyleElement styleElementAddedHandler = jasmine.createSpy("styleElementAddedHandler")
themeManager.onDidChangeStylesheets stylesheetsChangedHandler = jasmine.createSpy("stylesheetsChangedHandler")
themeManager.onDidAddStylesheet stylesheetAddedHandler = jasmine.createSpy("stylesheetAddedHandler")
cssPath = atom.project.getDirectories()[0]?.resolve('css.css')
lengthBefore = document.querySelectorAll('head style').length
themeManager.requireStylesheet(cssPath)
atom.themes.requireStylesheet(cssPath)
expect(document.querySelectorAll('head style').length).toBe lengthBefore + 1
expect(styleElementAddedHandler).toHaveBeenCalled()
expect(stylesheetAddedHandler).toHaveBeenCalled()
expect(stylesheetsChangedHandler).toHaveBeenCalled()
element = document.querySelector('head style[source-path*="css.css"]')
expect(element.getAttribute('source-path')).toBe themeManager.stringToId(cssPath)
expect(element.getAttribute('source-path')).toBe atom.themes.stringToId(cssPath)
expect(element.textContent).toBe fs.readFileSync(cssPath, 'utf8')
expect(element.sheet).toBe stylesheetAddedHandler.argsForCall[0][0]
# doesn't append twice
styleElementAddedHandler.reset()
themeManager.requireStylesheet(cssPath)
atom.themes.requireStylesheet(cssPath)
expect(document.querySelectorAll('head style').length).toBe lengthBefore + 1
expect(styleElementAddedHandler).not.toHaveBeenCalled()
@ -197,11 +190,11 @@ describe "ThemeManager", ->
it "synchronously loads and parses less files at the given path and installs a style tag for it in the head", ->
lessPath = atom.project.getDirectories()[0]?.resolve('sample.less')
lengthBefore = document.querySelectorAll('head style').length
themeManager.requireStylesheet(lessPath)
atom.themes.requireStylesheet(lessPath)
expect(document.querySelectorAll('head style').length).toBe lengthBefore + 1
element = document.querySelector('head style[source-path*="sample.less"]')
expect(element.getAttribute('source-path')).toBe themeManager.stringToId(lessPath)
expect(element.getAttribute('source-path')).toBe atom.themes.stringToId(lessPath)
expect(element.textContent).toBe """
#header {
color: #4d926f;
@ -213,16 +206,16 @@ describe "ThemeManager", ->
"""
# doesn't append twice
themeManager.requireStylesheet(lessPath)
atom.themes.requireStylesheet(lessPath)
expect(document.querySelectorAll('head style').length).toBe lengthBefore + 1
for styleElement in document.querySelectorAll('head style[id*="sample.less"]')
styleElement.remove()
it "supports requiring css and less stylesheets without an explicit extension", ->
themeManager.requireStylesheet path.join(__dirname, 'fixtures', 'css')
expect(document.querySelector('head style[source-path*="css.css"]').getAttribute('source-path')).toBe themeManager.stringToId(atom.project.getDirectories()[0]?.resolve('css.css'))
themeManager.requireStylesheet path.join(__dirname, 'fixtures', 'sample')
expect(document.querySelector('head style[source-path*="sample.less"]').getAttribute('source-path')).toBe themeManager.stringToId(atom.project.getDirectories()[0]?.resolve('sample.less'))
atom.themes.requireStylesheet path.join(__dirname, 'fixtures', 'css')
expect(document.querySelector('head style[source-path*="css.css"]').getAttribute('source-path')).toBe atom.themes.stringToId(atom.project.getDirectories()[0]?.resolve('css.css'))
atom.themes.requireStylesheet path.join(__dirname, 'fixtures', 'sample')
expect(document.querySelector('head style[source-path*="sample.less"]').getAttribute('source-path')).toBe atom.themes.stringToId(atom.project.getDirectories()[0]?.resolve('sample.less'))
document.querySelector('head style[source-path*="css.css"]').remove()
document.querySelector('head style[source-path*="sample.less"]').remove()
@ -231,24 +224,17 @@ describe "ThemeManager", ->
cssPath = require.resolve('./fixtures/css.css')
expect(getComputedStyle(document.body).fontWeight).not.toBe("bold")
disposable = themeManager.requireStylesheet(cssPath)
disposable = atom.themes.requireStylesheet(cssPath)
expect(getComputedStyle(document.body).fontWeight).toBe("bold")
atom.styles.onDidRemoveStyleElement styleElementRemovedHandler = jasmine.createSpy("styleElementRemovedHandler")
themeManager.onDidRemoveStylesheet stylesheetRemovedHandler = jasmine.createSpy("stylesheetRemovedHandler")
themeManager.onDidChangeStylesheets stylesheetsChangedHandler = jasmine.createSpy("stylesheetsChangedHandler")
disposable.dispose()
expect(getComputedStyle(document.body).fontWeight).not.toBe("bold")
expect(styleElementRemovedHandler).toHaveBeenCalled()
expect(stylesheetRemovedHandler).toHaveBeenCalled()
stylesheet = stylesheetRemovedHandler.argsForCall[0][0]
expect(stylesheet instanceof CSSStyleSheet).toBe true
expect(stylesheet.cssRules[0].selectorText).toBe 'body'
expect(stylesheetsChangedHandler).toHaveBeenCalled()
describe "base style sheet loading", ->
workspaceElement = null
@ -258,10 +244,10 @@ describe "ThemeManager", ->
workspaceElement.appendChild document.createElement('atom-text-editor')
waitsForPromise ->
themeManager.activateThemes()
atom.themes.activateThemes()
it "loads the correct values from the theme's ui-variables file", ->
themeManager.onDidChangeActiveThemes didChangeActiveThemesHandler = jasmine.createSpy()
atom.themes.onDidChangeActiveThemes didChangeActiveThemesHandler = jasmine.createSpy()
atom.config.set('core.themes', ['theme-with-ui-variables', 'theme-with-syntax-variables'])
waitsFor ->
@ -278,7 +264,7 @@ describe "ThemeManager", ->
describe "when there is a theme with incomplete variables", ->
it "loads the correct values from the fallback ui-variables", ->
themeManager.onDidChangeActiveThemes didChangeActiveThemesHandler = jasmine.createSpy()
atom.themes.onDidChangeActiveThemes didChangeActiveThemesHandler = jasmine.createSpy()
atom.config.set('core.themes', ['theme-with-incomplete-ui-variables', 'theme-with-syntax-variables'])
waitsFor ->
@ -307,67 +293,52 @@ describe "ThemeManager", ->
it "reloads it", ->
[styleElementAddedHandler, styleElementRemovedHandler] = []
[stylesheetRemovedHandler, stylesheetAddedHandler, stylesheetsChangedHandler] = []
waitsForPromise ->
themeManager.activateThemes()
atom.themes.activateThemes()
runs ->
atom.styles.onDidRemoveStyleElement styleElementRemovedHandler = jasmine.createSpy("styleElementRemovedHandler")
atom.styles.onDidAddStyleElement styleElementAddedHandler = jasmine.createSpy("styleElementAddedHandler")
themeManager.onDidChangeStylesheets stylesheetsChangedHandler = jasmine.createSpy("stylesheetsChangedHandler")
themeManager.onDidRemoveStylesheet stylesheetRemovedHandler = jasmine.createSpy("stylesheetRemovedHandler")
themeManager.onDidAddStylesheet stylesheetAddedHandler = jasmine.createSpy("stylesheetAddedHandler")
spyOn(themeManager, 'loadUserStylesheet').andCallThrough()
spyOn(atom.themes, 'loadUserStylesheet').andCallThrough()
expect(getComputedStyle(document.body).borderStyle).toBe 'dotted'
fs.writeFileSync(userStylesheetPath, 'body {border-style: dashed}')
waitsFor ->
themeManager.loadUserStylesheet.callCount is 1
atom.themes.loadUserStylesheet.callCount is 1
runs ->
expect(getComputedStyle(document.body).borderStyle).toBe 'dashed'
expect(styleElementRemovedHandler).toHaveBeenCalled()
expect(styleElementRemovedHandler.argsForCall[0][0].textContent).toContain 'dotted'
expect(stylesheetRemovedHandler).toHaveBeenCalled()
expect(stylesheetRemovedHandler.argsForCall[0][0].cssRules[0].style.border).toBe 'dotted'
expect(styleElementAddedHandler).toHaveBeenCalled()
expect(styleElementAddedHandler.argsForCall[0][0].textContent).toContain 'dashed'
expect(stylesheetAddedHandler).toHaveBeenCalled()
expect(stylesheetAddedHandler.argsForCall[0][0].cssRules[0].style.border).toBe 'dashed'
expect(stylesheetsChangedHandler).toHaveBeenCalled()
styleElementRemovedHandler.reset()
stylesheetRemovedHandler.reset()
stylesheetsChangedHandler.reset()
fs.removeSync(userStylesheetPath)
waitsFor ->
themeManager.loadUserStylesheet.callCount is 2
atom.themes.loadUserStylesheet.callCount is 2
runs ->
expect(styleElementRemovedHandler).toHaveBeenCalled()
expect(styleElementRemovedHandler.argsForCall[0][0].textContent).toContain 'dashed'
expect(stylesheetRemovedHandler).toHaveBeenCalled()
expect(stylesheetRemovedHandler.argsForCall[0][0].cssRules[0].style.border).toBe 'dashed'
expect(getComputedStyle(document.body).borderStyle).toBe 'none'
expect(stylesheetsChangedHandler).toHaveBeenCalled()
describe "when there is an error reading the stylesheet", ->
addErrorHandler = null
beforeEach ->
themeManager.loadUserStylesheet()
spyOn(themeManager.lessCache, 'cssForFile').andCallFake ->
atom.themes.loadUserStylesheet()
spyOn(atom.themes.lessCache, 'cssForFile').andCallFake ->
throw new Error('EACCES permission denied "styles.less"')
atom.notifications.onDidAddNotification addErrorHandler = jasmine.createSpy()
it "creates an error notification and does not add the stylesheet", ->
themeManager.loadUserStylesheet()
atom.themes.loadUserStylesheet()
expect(addErrorHandler).toHaveBeenCalled()
note = addErrorHandler.mostRecentCall.args[0]
expect(note.getType()).toBe 'error'
@ -381,11 +352,11 @@ describe "ThemeManager", ->
spyOn(File::, 'on').andCallFake (event) ->
if event.indexOf('contents-changed') > -1
throw new Error('Unable to watch path')
spyOn(themeManager, 'loadStylesheet').andReturn ''
spyOn(atom.themes, 'loadStylesheet').andReturn ''
atom.notifications.onDidAddNotification addErrorHandler = jasmine.createSpy()
it "creates an error notification", ->
themeManager.loadUserStylesheet()
atom.themes.loadUserStylesheet()
expect(addErrorHandler).toHaveBeenCalled()
note = addErrorHandler.mostRecentCall.args[0]
expect(note.getType()).toBe 'error'
@ -394,38 +365,35 @@ describe "ThemeManager", ->
it "adds a notification when a theme's stylesheet is invalid", ->
addErrorHandler = jasmine.createSpy()
atom.notifications.onDidAddNotification(addErrorHandler)
expect(-> atom.packages.activatePackage('theme-with-invalid-styles')).not.toThrow()
expect(-> atom.packages.activatePackage('theme-with-invalid-styles').then((->), (->))).not.toThrow()
expect(addErrorHandler.callCount).toBe 2
expect(addErrorHandler.argsForCall[1][0].message).toContain("Failed to activate the theme-with-invalid-styles theme")
describe "when a non-existent theme is present in the config", ->
beforeEach ->
spyOn(console, 'warn')
console.warn.reset()
atom.config.set('core.themes', ['non-existent-dark-ui', 'non-existent-dark-syntax'])
waitsForPromise ->
themeManager.activateThemes()
atom.themes.activateThemes()
it 'uses the default dark UI and syntax themes and logs a warning', ->
activeThemeNames = themeManager.getActiveThemeNames()
activeThemeNames = atom.themes.getActiveThemeNames()
expect(console.warn.callCount).toBe 2
expect(activeThemeNames.length).toBe(2)
expect(activeThemeNames).toContain('atom-dark-ui')
expect(activeThemeNames).toContain('atom-dark-syntax')
describe "when in safe mode", ->
beforeEach ->
themeManager = new ThemeManager({packageManager: atom.packages, resourcePath, configDirPath, safeMode: true})
describe 'when the enabled UI and syntax themes are bundled with Atom', ->
beforeEach ->
atom.config.set('core.themes', ['atom-light-ui', 'atom-dark-syntax'])
waitsForPromise ->
themeManager.activateThemes()
atom.themes.activateThemes()
it 'uses the enabled themes', ->
activeThemeNames = themeManager.getActiveThemeNames()
activeThemeNames = atom.themes.getActiveThemeNames()
expect(activeThemeNames.length).toBe(2)
expect(activeThemeNames).toContain('atom-light-ui')
expect(activeThemeNames).toContain('atom-dark-syntax')
@ -435,10 +403,10 @@ describe "ThemeManager", ->
atom.config.set('core.themes', ['installed-dark-ui', 'installed-dark-syntax'])
waitsForPromise ->
themeManager.activateThemes()
atom.themes.activateThemes()
it 'uses the default dark UI and syntax themes', ->
activeThemeNames = themeManager.getActiveThemeNames()
activeThemeNames = atom.themes.getActiveThemeNames()
expect(activeThemeNames.length).toBe(2)
expect(activeThemeNames).toContain('atom-dark-ui')
expect(activeThemeNames).toContain('atom-dark-syntax')
@ -448,10 +416,10 @@ describe "ThemeManager", ->
atom.config.set('core.themes', ['installed-dark-ui', 'atom-light-syntax'])
waitsForPromise ->
themeManager.activateThemes()
atom.themes.activateThemes()
it 'uses the default dark UI theme', ->
activeThemeNames = themeManager.getActiveThemeNames()
activeThemeNames = atom.themes.getActiveThemeNames()
expect(activeThemeNames.length).toBe(2)
expect(activeThemeNames).toContain('atom-dark-ui')
expect(activeThemeNames).toContain('atom-light-syntax')
@ -461,10 +429,10 @@ describe "ThemeManager", ->
atom.config.set('core.themes', ['atom-light-ui', 'installed-dark-syntax'])
waitsForPromise ->
themeManager.activateThemes()
atom.themes.activateThemes()
it 'uses the default dark syntax theme', ->
activeThemeNames = themeManager.getActiveThemeNames()
activeThemeNames = atom.themes.getActiveThemeNames()
expect(activeThemeNames.length).toBe(2)
expect(activeThemeNames).toContain('atom-light-ui')
expect(activeThemeNames).toContain('atom-dark-syntax')

View File

@ -6,7 +6,6 @@ platform = require './spec-helper-platform'
_ = require 'underscore-plus'
fstream = require 'fstream'
fs = require 'fs-plus'
Grim = require 'grim'
describe "Workspace", ->
workspace = null
@ -383,21 +382,6 @@ describe "Workspace", ->
runs ->
expect(newEditorHandler.argsForCall[0][0].textEditor).toBe editor
it "records a deprecation warning on the appropriate package if the item has a ::getUri method instead of ::getURI", ->
jasmine.snapshotDeprecations()
waitsForPromise -> atom.packages.activatePackage('package-with-deprecated-pane-item-method')
waitsForPromise ->
atom.workspace.open("test")
runs ->
deprecations = Grim.getDeprecations()
expect(deprecations.length).toBe 1
expect(deprecations[0].message).toBe "Pane item with class `TestItem` should implement `::getURI` instead of `::getUri`."
expect(deprecations[0].getStacks()[0].metadata.packageName).toBe "package-with-deprecated-pane-item-method"
jasmine.restoreDeprecationsSnapshot()
describe "when there is an error opening the file", ->
notificationSpy = null
beforeEach ->
@ -682,7 +666,7 @@ describe "Workspace", ->
it "updates the title to contain the project's path", ->
document.title = null
workspace2 = atom.workspace.testSerialization()
workspace2 = Workspace.deserialize(atom.workspace.serialize())
item = atom.workspace.getActivePaneItem()
expect(document.title).toBe "#{item.getTitle()} - #{atom.project.getPaths()[0]} - Atom"
workspace2.destroy()

View File

@ -6,7 +6,7 @@ remote = require 'remote'
shell = require 'shell'
_ = require 'underscore-plus'
{deprecate, includeDeprecatedAPIs} = require 'grim'
{deprecate} = require 'grim'
{CompositeDisposable, Emitter} = require 'event-kit'
fs = require 'fs-plus'
{mapSourcePosition} = require 'source-map-support'
@ -32,22 +32,6 @@ class Atom extends Model
startTime = Date.now()
atom = @deserialize(@loadState(mode)) ? new this({mode, @version})
atom.deserializeTimings.atom = Date.now() - startTime
if includeDeprecatedAPIs
serviceHubDeprecationMessage = """
atom.services is no longer available. To register service providers and
consumers, use the `providedServices` and `consumedServices` fields in
your package's package.json.
"""
Object.defineProperty atom, 'services',
get: ->
deprecate(serviceHubDeprecationMessage)
atom.packages.serviceHub
set: (newValue) ->
deprecate(serviceHubDeprecationMessage)
atom.packages.serviceHub = newValue
atom
# Deserializes the Atom environment from a state object
@ -196,7 +180,6 @@ class Atom extends Model
@openDevTools()
@executeJavaScriptInDevTools('DevToolsAPI.showConsole()')
@emit 'uncaught-error', arguments... if includeDeprecatedAPIs
@emitter.emit 'did-throw-error', {message, url, line, column, originalError}
@disposables?.dispose()
@ -235,10 +218,6 @@ class Atom extends Model
@config = new Config({configDirPath, resourcePath})
@keymaps = new KeymapManager({configDirPath, resourcePath})
if includeDeprecatedAPIs
@keymap = @keymaps # Deprecated
@keymaps.subscribeToFileReadFailure()
@tooltips = new TooltipManager
@notifications = new NotificationManager
@ -252,14 +231,7 @@ class Atom extends Model
@contextMenu = new ContextMenuManager({resourcePath, devMode})
@menu = new MenuManager({resourcePath})
@clipboard = new Clipboard()
@grammars = @deserializers.deserialize(@state.grammars ? @state.syntax) ? new GrammarRegistry()
if includeDeprecatedAPIs
Object.defineProperty this, 'syntax', get: ->
deprecate "The atom.syntax global is deprecated. Use atom.grammars instead."
@grammars
@disposables.add @packages.onDidActivateInitialPackages => @watchThemes()
Project = require './project'
@ -485,10 +457,6 @@ class Atom extends Model
isMaximized: ->
@getCurrentWindow().isMaximized()
isMaximixed: ->
deprecate "Use atom.isMaximized() instead"
@isMaximized()
maximize: ->
ipc.send('call-window-method', 'maximize')
@ -748,11 +716,9 @@ class Atom extends Model
startTime = Date.now()
@workspace = Workspace.deserialize(@state.workspace) ? new Workspace
workspaceElement = @views.getView(@workspace)
@deserializeTimings.workspace = Date.now() - startTime
workspaceElement = @views.getView(@workspace)
@keymaps.defaultTarget = workspaceElement
document.querySelector(@workspaceParentSelectorctor).appendChild(workspaceElement)
@ -877,12 +843,3 @@ class Atom extends Model
Promise.prototype.done = (callback) ->
deprecate("Atom now uses ES6 Promises instead of Q. Call promise.then instead of promise.done")
@then(callback)
if includeDeprecatedAPIs
# Deprecated: Callers should be converted to use atom.deserializers
Atom::registerRepresentationClass = ->
deprecate("Callers should be converted to use atom.deserializers")
# Deprecated: Callers should be converted to use atom.deserializers
Atom::registerRepresentationClasses = ->
deprecate("Callers should be converted to use atom.deserializers")

View File

@ -5,7 +5,6 @@ CSON = require 'season'
path = require 'path'
async = require 'async'
pathWatcher = require 'pathwatcher'
Grim = require 'grim'
Color = require './color'
ScopedPropertyStore = require 'scoped-property-store'
@ -387,21 +386,9 @@ class Config
observe: ->
if arguments.length is 2
[keyPath, callback] = arguments
else if Grim.includeDeprecatedAPIs and arguments.length is 3 and (_.isArray(arguments[0]) or arguments[0] instanceof ScopeDescriptor)
Grim.deprecate """
Passing a scope descriptor as the first argument to Config::observe is deprecated.
Pass a `scope` in an options hash as the third argument instead.
"""
[scopeDescriptor, keyPath, callback] = arguments
else if arguments.length is 3 and (_.isString(arguments[0]) and _.isObject(arguments[1]))
[keyPath, options, callback] = arguments
scopeDescriptor = options.scope
if Grim.includeDeprecatedAPIs and options.callNow?
Grim.deprecate """
Config::observe no longer takes a `callNow` option. Use ::onDidChange instead.
Note that ::onDidChange passes its callback different arguments.
See https://atom.io/docs/api/latest/Config
"""
else
console.error 'An unsupported form of Config::observe is being used. See https://atom.io/docs/api/latest/Config for details'
return
@ -435,12 +422,6 @@ class Config
[callback] = arguments
else if arguments.length is 2
[keyPath, callback] = arguments
else if Grim.includeDeprecatedAPIs and _.isArray(arguments[0]) or arguments[0] instanceof ScopeDescriptor
Grim.deprecate """
Passing a scope descriptor as the first argument to Config::onDidChange is deprecated.
Pass a `scope` in an options hash as the third argument instead.
"""
[scopeDescriptor, keyPath, callback] = arguments
else
[keyPath, options, callback] = arguments
scopeDescriptor = options.scope
@ -514,12 +495,6 @@ class Config
if typeof arguments[0] is 'string' or not arguments[0]?
[keyPath, options] = arguments
{scope} = options
else if Grim.includeDeprecatedAPIs
Grim.deprecate """
Passing a scope descriptor as the first argument to Config::get is deprecated.
Pass a `scope` in an options hash as the final argument instead.
"""
[scope, keyPath] = arguments
else
[keyPath] = arguments
@ -594,18 +569,10 @@ class Config
# * `true` if the value was set.
# * `false` if the value was not able to be coerced to the type specified in the setting's schema.
set: ->
if Grim.includeDeprecatedAPIs and arguments[0]?[0] is '.'
Grim.deprecate """
Passing a scope selector as the first argument to Config::set is deprecated.
Pass a `scopeSelector` in an options hash as the final argument instead.
"""
[scopeSelector, keyPath, value] = arguments
shouldSave = true
else
[keyPath, value, options] = arguments
scopeSelector = options?.scopeSelector
source = options?.source
shouldSave = options?.save ? true
[keyPath, value, options] = arguments
scopeSelector = options?.scopeSelector
source = options?.source
shouldSave = options?.save ? true
if source and not scopeSelector
throw new Error("::set with a 'source' and no 'sourceSelector' is not yet implemented!")
@ -633,16 +600,7 @@ class Config
# * `scopeSelector` (optional) {String}. See {::set}
# * `source` (optional) {String}. See {::set}
unset: (keyPath, options) ->
if Grim.includeDeprecatedAPIs and typeof options is 'string'
Grim.deprecate """
Passing a scope selector as the first argument to Config::unset is deprecated.
Pass a `scopeSelector` in an options hash as the second argument instead.
"""
scopeSelector = keyPath
keyPath = options
else
{scopeSelector, source} = options ? {}
{scopeSelector, source} = options ? {}
source ?= @getUserConfigPath()
if scopeSelector?
@ -1206,71 +1164,3 @@ withoutEmptyObjects = (object) ->
else
resultObject = object
resultObject
# TODO remove in 1.0 API
Config::unobserve = (keyPath) ->
Grim.deprecate 'Config::unobserve no longer does anything. Call `.dispose()` on the object returned by Config::observe instead.'
if Grim.includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
EmitterMixin.includeInto(Config)
Config::restoreDefault = (scopeSelector, keyPath) ->
Grim.deprecate("Use ::unset instead.")
@unset(scopeSelector, keyPath)
@get(keyPath)
Config::getDefault = ->
Grim.deprecate("Use `::get(keyPath, {scope, excludeSources: [atom.config.getUserConfigPath()]})` instead")
if arguments.length is 1
[keyPath] = arguments
else
[scopeSelector, keyPath] = arguments
scope = [scopeSelector]
@get(keyPath, {scope, excludeSources: [@getUserConfigPath()]})
Config::isDefault = ->
Grim.deprecate("Use `not ::get(keyPath, {scope, sources: [atom.config.getUserConfigPath()]})?` instead")
if arguments.length is 1
[keyPath] = arguments
else
[scopeSelector, keyPath] = arguments
scope = [scopeSelector]
not @get(keyPath, {scope, sources: [@getUserConfigPath()]})?
Config::getSettings = ->
Grim.deprecate "Use ::get(keyPath) instead"
_.deepExtend({}, @settings, @defaultSettings)
Config::getInt = (keyPath) ->
Grim.deprecate '''Config::getInt is no longer necessary. Use ::get instead.
Make sure the config option you are accessing has specified an `integer`
schema. See the schema section of
https://atom.io/docs/api/latest/Config for more info.'''
parseInt(@get(keyPath))
Config::getPositiveInt = (keyPath, defaultValue=0) ->
Grim.deprecate '''Config::getPositiveInt is no longer necessary. Use ::get instead.
Make sure the config option you are accessing has specified an `integer`
schema with `minimum: 1`. See the schema section of
https://atom.io/docs/api/latest/Config for more info.'''
Math.max(@getInt(keyPath), 0) or defaultValue
Config::toggle = (keyPath) ->
Grim.deprecate 'Config::toggle is no longer supported. Please remove from your code.'
@set(keyPath, not @get(keyPath))
Config::addScopedSettings = (source, selector, value, options) ->
Grim.deprecate("Use ::set instead")
settingsBySelector = {}
settingsBySelector[selector] = value
disposable = @scopedSettingsStore.addProperties(source, settingsBySelector, options)
@emitChangeEvent()
new Disposable =>
disposable.dispose()
@emitChangeEvent()
Config::settingsForScopeDescriptor = (scopeDescriptor, keyPath) ->
Grim.deprecate("Use Config::getAll instead")
entries = @getAll(null, scope: scopeDescriptor)
value for {value} in entries when _.valueForKeyPath(value, keyPath)?

View File

@ -4,7 +4,6 @@ CSON = require 'season'
fs = require 'fs-plus'
{calculateSpecificity, validateSelector} = require 'clear-cut'
{Disposable} = require 'event-kit'
Grim = require 'grim'
MenuHelpers = require './menu-helpers'
platformContextMenu = require('../package.json')?._atomMenu?['context-menu']
@ -109,27 +108,6 @@ class ContextMenuManager
# Returns a {Disposable} on which `.dispose()` can be called to remove the
# added menu items.
add: (itemsBySelector) ->
if Grim.includeDeprecatedAPIs
# Detect deprecated file path as first argument
if itemsBySelector? and typeof itemsBySelector isnt 'object'
Grim.deprecate """
`ContextMenuManager::add` has changed to take a single object as its
argument. Please see
https://atom.io/docs/api/latest/ContextMenuManager#context-menu-cson-format for more info.
"""
itemsBySelector = arguments[1]
devMode = arguments[2]?.devMode
# Detect deprecated format for items object
for key, value of itemsBySelector
unless _.isArray(value)
Grim.deprecate """
`ContextMenuManager::add` has changed to take a single object as its
argument. Please see
https://atom.io/docs/api/latest/ContextMenuManager#context-menu-cson-format for more info.
"""
itemsBySelector = @convertLegacyItemsBySelector(itemsBySelector, devMode)
addedItemSets = []
for selector, items of itemsBySelector

View File

@ -1,7 +1,6 @@
{Point, Range} = require 'text-buffer'
{Emitter} = require 'event-kit'
_ = require 'underscore-plus'
Grim = require 'grim'
Model = require './model'
# Extended: The `Cursor` class represents the little blinking line identifying
@ -62,18 +61,6 @@ class Cursor extends Model
onDidChangeVisibility: (callback) ->
@emitter.on 'did-change-visibility', callback
on: (eventName) ->
return unless Grim.includeDeprecatedAPIs
switch eventName
when 'moved'
Grim.deprecate("Use Cursor::onDidChangePosition instead")
when 'destroyed'
Grim.deprecate("Use Cursor::onDidDestroy instead")
else
Grim.deprecate("::on is no longer supported. Use the event subscription methods instead")
super
###
Section: Managing Cursor Position
###
@ -578,7 +565,6 @@ class Cursor extends Model
setVisible: (visible) ->
if @visible isnt visible
@visible = visible
@emit 'visibility-changed', @visible if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-visibility', @visible
# Public: Returns the visibility of the cursor.
@ -698,12 +684,3 @@ class Cursor extends Model
position = range.start
stop()
position
if Grim.includeDeprecatedAPIs
Cursor::getScopes = ->
Grim.deprecate 'Use Cursor::getScopeDescriptor() instead'
@getScopeDescriptor().getScopesArray()
Cursor::getMoveNextWordBoundaryBufferPosition = (options) ->
Grim.deprecate 'Use `::getNextWordBoundaryBufferPosition(options)` instead'
@getNextWordBoundaryBufferPosition(options)

View File

@ -1,6 +1,5 @@
_ = require 'underscore-plus'
{Emitter} = require 'event-kit'
Grim = require 'grim'
idCounter = 0
nextId = -> idCounter++
@ -82,7 +81,6 @@ class Decoration
@markerDestroyDisposable.dispose()
@markerDestroyDisposable = null
@destroyed = true
@emit 'destroyed' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-destroy'
@emitter.dispose()
@ -155,7 +153,6 @@ class Decoration
@properties.id = @id
if newProperties.type?
@displayBuffer.decorationDidChangeType(this)
@emit 'updated', {oldParams: oldProperties, newParams: newProperties} if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-properties', {oldProperties, newProperties}
###
@ -175,34 +172,8 @@ class Decoration
flashObject = {class: klass, duration}
@flashQueue ?= []
@flashQueue.push(flashObject)
@emit 'flash' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-flash'
consumeNextFlash: ->
return @flashQueue.shift() if @flashQueue?.length > 0
null
if Grim.includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
EmitterMixin.includeInto(Decoration)
Decoration::on = (eventName) ->
switch eventName
when 'updated'
Grim.deprecate 'Use Decoration::onDidChangeProperties instead'
when 'destroyed'
Grim.deprecate 'Use Decoration::onDidDestroy instead'
when 'flash'
Grim.deprecate 'Use Decoration::onDidFlash instead'
else
Grim.deprecate 'Decoration::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)
Decoration::getParams = ->
Grim.deprecate 'Use Decoration::getProperties instead'
@getProperties()
Decoration::update = (newProperties) ->
Grim.deprecate 'Use Decoration::setProperties instead'
@setProperties(newProperties)

View File

@ -5,7 +5,7 @@ function listen (element, eventName, selector, handler) {
var innerHandler = function (event) {
if (selector) {
var currentTarget = event.target
while (true) {
while (currentTarget) {
if (currentTarget.matches && currentTarget.matches(selector)) {
handler({
type: event.type,

View File

@ -1,5 +1,4 @@
{Disposable} = require 'event-kit'
Grim = require 'grim'
# Extended: Manages the deserializers used for serialized state
#
@ -60,9 +59,3 @@ class DeserializerManager
name = state.get?('deserializer') ? state.deserializer
@deserializers[name]
if Grim.includeDeprecatedAPIs
DeserializerManager::remove = (classes...) ->
Grim.deprecate("Call .dispose() on the Disposable return from ::add instead")
delete @deserializers[name] for {name} in classes
return

View File

@ -1,8 +1,6 @@
_ = require 'underscore-plus'
Serializable = require 'serializable'
{CompositeDisposable, Emitter} = require 'event-kit'
{Point, Range} = require 'text-buffer'
Grim = require 'grim'
TokenizedBuffer = require './tokenized-buffer'
RowMap = require './row-map'
Fold = require './fold'
@ -18,12 +16,25 @@ class BufferToScreenConversionError extends Error
module.exports =
class DisplayBuffer extends Model
Serializable.includeInto(this)
verticalScrollMargin: 2
horizontalScrollMargin: 6
scopedCharacterWidthsChangeCount: 0
changeCount: 0
softWrapped: null
editorWidthInChars: null
lineHeightInPixels: null
defaultCharWidth: null
height: null
width: null
scrollTop: 0
scrollLeft: 0
scrollWidth: 0
verticalScrollbarWidth: 15
horizontalScrollbarHeight: 15
@deserialize: (state) ->
state.tokenizedBuffer = TokenizedBuffer.deserialize(state.tokenizedBuffer)
new this(state)
constructor: ({tabLength, @editorWidthInChars, @tokenizedBuffer, buffer, ignoreInvisibles, @largeFileMode}={}) ->
super
@ -83,7 +94,8 @@ class DisplayBuffer extends Model
@updateWrappedScreenLines() if oldConfigSettings? and not _.isEqual(oldConfigSettings, @configSettings)
serializeParams: ->
serialize: ->
deserializer: 'DisplayBuffer'
id: @id
softWrapped: @isSoftWrapped()
editorWidthInChars: @editorWidthInChars
@ -92,10 +104,6 @@ class DisplayBuffer extends Model
tokenizedBuffer: @tokenizedBuffer.serialize()
largeFileMode: @largeFileMode
deserializeParams: (params) ->
params.tokenizedBuffer = TokenizedBuffer.deserialize(params.tokenizedBuffer)
params
copy: ->
newDisplayBuffer = new DisplayBuffer({@buffer, tabLength: @getTabLength(), @largeFileMode})
@ -158,11 +166,9 @@ class DisplayBuffer extends Model
@emitter.on 'did-update-markers', callback
emitDidChange: (eventProperties, refreshMarkers=true) ->
@emit 'changed', eventProperties if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change', eventProperties
if refreshMarkers
@refreshMarkerScreenPositions()
@emit 'markers-updated' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-update-markers'
updateWrappedScreenLines: ->
@ -247,7 +253,6 @@ class DisplayBuffer extends Model
@characterWidthsChanged() unless @batchingCharacterMeasurement
characterWidthsChanged: ->
@emit 'character-widths-changed', @scopedCharacterWidthsChangeCount if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-character-widths', @scopedCharacterWidthsChangeCount
clearScopedCharWidths: ->
@ -286,7 +291,6 @@ class DisplayBuffer extends Model
@softWrapped = softWrapped
@updateWrappedScreenLines()
softWrapped = @isSoftWrapped()
@emit 'soft-wrap-changed', softWrapped if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-soft-wrapped', softWrapped
softWrapped
else
@ -847,7 +851,6 @@ class DisplayBuffer extends Model
@decorationsByMarkerId[marker.id].push(decoration)
@overlayDecorationsById[decoration.id] = decoration if decoration.isType('overlay')
@decorationsById[decoration.id] = decoration
@emit 'decoration-added', decoration if Grim.includeDeprecatedAPIs
@emitter.emit 'did-add-decoration', decoration
decoration
@ -859,7 +862,6 @@ class DisplayBuffer extends Model
if index > -1
decorations.splice(index, 1)
delete @decorationsById[decoration.id]
@emit 'decoration-removed', decoration if Grim.includeDeprecatedAPIs
@emitter.emit 'did-remove-decoration', decoration
delete @decorationsByMarkerId[marker.id] if decorations.length is 0
delete @overlayDecorationsById[decoration.id]
@ -1150,7 +1152,6 @@ class DisplayBuffer extends Model
if marker = @getMarker(textBufferMarker.id)
# The marker might have been removed in some other handler called before
# this one. Only emit when the marker still exists.
@emit 'marker-created', marker if Grim.includeDeprecatedAPIs
@emitter.emit 'did-create-marker', marker
# TODO: serialize state in TextEditorElement, rather than saving scroll
@ -1197,58 +1198,3 @@ class DisplayBuffer extends Model
atom.assert screenLinesCount is bufferLinesCount, "Display buffer line count out of sync with buffer", (error) ->
error.metadata = {screenLinesCount, tokenizedLinesCount, bufferLinesCount}
if Grim.includeDeprecatedAPIs
DisplayBuffer.properties
softWrapped: null
editorWidthInChars: null
lineHeightInPixels: null
defaultCharWidth: null
height: null
width: null
scrollTop: 0
scrollLeft: 0
scrollWidth: 0
verticalScrollbarWidth: 15
horizontalScrollbarHeight: 15
EmitterMixin = require('emissary').Emitter
DisplayBuffer::on = (eventName) ->
switch eventName
when 'changed'
Grim.deprecate("Use DisplayBuffer::onDidChange instead")
when 'grammar-changed'
Grim.deprecate("Use DisplayBuffer::onDidChangeGrammar instead")
when 'soft-wrap-changed'
Grim.deprecate("Use DisplayBuffer::onDidChangeSoftWrap instead")
when 'character-widths-changed'
Grim.deprecate("Use DisplayBuffer::onDidChangeCharacterWidths instead")
when 'decoration-added'
Grim.deprecate("Use DisplayBuffer::onDidAddDecoration instead")
when 'decoration-removed'
Grim.deprecate("Use DisplayBuffer::onDidRemoveDecoration instead")
when 'decoration-changed'
Grim.deprecate("Use decoration.getMarker().onDidChange() instead")
when 'decoration-updated'
Grim.deprecate("Use Decoration::onDidChangeProperties instead")
when 'marker-created'
Grim.deprecate("Use Decoration::onDidCreateMarker instead")
when 'markers-updated'
Grim.deprecate("Use Decoration::onDidUpdateMarkers instead")
else
Grim.deprecate("DisplayBuffer::on is deprecated. Use event subscription methods instead.")
EmitterMixin::on.apply(this, arguments)
else
DisplayBuffer::softWrapped = null
DisplayBuffer::editorWidthInChars = null
DisplayBuffer::lineHeightInPixels = null
DisplayBuffer::defaultCharWidth = null
DisplayBuffer::height = null
DisplayBuffer::width = null
DisplayBuffer::scrollTop = 0
DisplayBuffer::scrollLeft = 0
DisplayBuffer::scrollWidth = 0
DisplayBuffer::verticalScrollbarWidth = 15
DisplayBuffer::horizontalScrollbarHeight = 15

View File

@ -4,7 +4,6 @@ _ = require 'underscore-plus'
{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
fs = require 'fs-plus'
GitUtils = require 'git-utils'
{includeDeprecatedAPIs, deprecate} = require 'grim'
Task = require './task'
@ -327,7 +326,6 @@ class GitRepository
else
delete @statuses[relativePath]
if currentPathStatus isnt pathStatus
@emit 'status-changed', path, pathStatus if includeDeprecatedAPIs
@emitter.emit 'did-change-status', {path, pathStatus}
pathStatus
@ -496,23 +494,4 @@ class GitRepository
submoduleRepo.upstream = submodules[submodulePath]?.upstream ? {ahead: 0, behind: 0}
unless statusesUnchanged
@emit 'statuses-changed' if includeDeprecatedAPIs
@emitter.emit 'did-change-statuses'
if includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
EmitterMixin.includeInto(GitRepository)
GitRepository::on = (eventName) ->
switch eventName
when 'status-changed'
deprecate 'Use GitRepository::onDidChangeStatus instead'
when 'statuses-changed'
deprecate 'Use GitRepository::onDidChangeStatuses instead'
else
deprecate 'GitRepository::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)
GitRepository::getOriginUrl = (path) ->
deprecate 'Use ::getOriginURL instead.'
@getOriginURL(path)

View File

@ -1,6 +1,5 @@
_ = require 'underscore-plus'
{Emitter} = require 'event-kit'
{includeDeprecatedAPIs, deprecate} = require 'grim'
FirstMate = require 'first-mate'
Token = require './token'
fs = require 'fs-plus'
@ -136,37 +135,4 @@ class GrammarRegistry extends FirstMate.GrammarRegistry
undefined
clearObservers: ->
@off() if includeDeprecatedAPIs
@emitter = new Emitter
if includeDeprecatedAPIs
PropertyAccessors = require 'property-accessors'
PropertyAccessors.includeInto(GrammarRegistry)
{Subscriber} = require 'emissary'
Subscriber.includeInto(GrammarRegistry)
# Support old serialization
atom.deserializers.add(name: 'Syntax', deserialize: GrammarRegistry.deserialize)
# Deprecated: Used by settings-view to display snippets for packages
GrammarRegistry::accessor 'propertyStore', ->
deprecate("Do not use this. Use a public method on Config")
atom.config.scopedSettingsStore
GrammarRegistry::addProperties = (args...) ->
args.unshift(null) if args.length is 2
deprecate 'Consider using atom.config.set() instead. A direct (but private) replacement is available at atom.config.addScopedSettings().'
atom.config.addScopedSettings(args...)
GrammarRegistry::removeProperties = (name) ->
deprecate 'atom.config.addScopedSettings() now returns a disposable you can call .dispose() on'
atom.config.scopedSettingsStore.removeProperties(name)
GrammarRegistry::getProperty = (scope, keyPath) ->
deprecate 'A direct (but private) replacement is available at atom.config.getRawScopedValue().'
atom.config.getRawScopedValue(scope, keyPath)
GrammarRegistry::propertiesForScope = (scope, keyPath) ->
deprecate 'Use atom.config.getAll instead.'
atom.config.settingsForScopeDescriptor(scope, keyPath)

View File

@ -2,7 +2,6 @@ fs = require 'fs-plus'
path = require 'path'
KeymapManager = require 'atom-keymap'
CSON = require 'season'
Grim = require 'grim'
bundledKeymaps = require('../package.json')?._atomKeymaps

View File

@ -1,6 +1,5 @@
_ = require 'underscore-plus'
{CompositeDisposable, Emitter} = require 'event-kit'
Grim = require 'grim'
# Essential: Represents a buffer annotation that remains logically stationary
# even as the buffer changes. This is used to represent cursors, folds, snippet
@ -335,7 +334,6 @@ class Marker
destroyed: ->
delete @displayBuffer.markers[@id]
@emit 'destroyed' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-destroy'
@emitter.dispose()
@ -369,35 +367,7 @@ class Marker
@oldTailScreenPosition = newTailScreenPosition
@wasValid = isValid
@emit 'changed', changeEvent if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change', changeEvent
getPixelRange: ->
@displayBuffer.pixelRangeForScreenRange(@getScreenRange(), false)
if Grim.includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
EmitterMixin.includeInto(Marker)
Marker::on = (eventName) ->
switch eventName
when 'changed'
Grim.deprecate("Use Marker::onDidChange instead")
when 'destroyed'
Grim.deprecate("Use Marker::onDidDestroy instead")
else
Grim.deprecate("Marker::on is deprecated. Use documented event subscription methods instead.")
EmitterMixin::on.apply(this, arguments)
Marker::getAttributes = ->
Grim.deprecate 'Use Marker::getProperties instead'
@getProperties()
Marker::setAttributes = (properties) ->
Grim.deprecate 'Use Marker::setProperties instead'
@setProperties(properties)
Marker::matchesAttributes = (attributes) ->
Grim.deprecate 'Use Marker::matchesProperties instead'
@matchesProperties(attributes)

View File

@ -1,16 +1,7 @@
Grim = require 'grim'
if Grim.includeDeprecatedAPIs
module.exports = require('theorist').Model
return
PropertyAccessors = require 'property-accessors'
nextInstanceId = 1
module.exports =
class Model
PropertyAccessors.includeInto(this)
@resetNextInstanceId: -> nextInstanceId = 1
alive: true
@ -20,9 +11,7 @@ class Model
assignId: (id) ->
@id ?= id ? nextInstanceId++
@::advisedAccessor 'id',
set: (id) -> nextInstanceId = id + 1 if id >= nextInstanceId
nextInstanceId = id + 1 if id >= nextInstanceId
destroy: ->
return unless @isAlive()

View File

@ -3,7 +3,6 @@ path = require 'path'
_ = require 'underscore-plus'
{Emitter} = require 'event-kit'
fs = require 'fs-plus'
Grim = require 'grim'
ServiceHub = require 'service-hub'
Package = require './package'
@ -327,18 +326,10 @@ class PackageManager
# of the first package isn't skewed by being the first to require atom
require '../exports/atom'
# TODO: remove after a few atom versions.
@uninstallAutocompletePlus()
packagePaths = @getAvailablePackagePaths()
# TODO: remove after a few atom versions.
@migrateSublimeTabsSettings(packagePaths)
packagePaths = packagePaths.filter (packagePath) => not @isPackageDisabled(path.basename(packagePath))
packagePaths = _.uniq packagePaths, (packagePath) -> path.basename(packagePath)
@loadPackage(packagePath) for packagePath in packagePaths
@emit 'loaded' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-load-initial-packages'
loadPackage: (nameOrPath) ->
@ -354,7 +345,7 @@ class PackageManager
@handleMetadataError(error, packagePath)
return null
unless @isBundledPackage(metadata.name) or Grim.includeDeprecatedAPIs
unless @isBundledPackage(metadata.name)
if @isDeprecatedPackage(metadata.name, metadata.version)
console.warn "Could not load #{metadata.name}@#{metadata.version} because it uses deprecated APIs that have been removed."
return null
@ -392,7 +383,6 @@ class PackageManager
packages = @getLoadedPackagesForTypes(types)
promises = promises.concat(activator.activatePackages(packages))
Promise.all(promises).then =>
@emit 'activated' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-activate-initial-packages'
# another type of package manager can handle other package types.
@ -455,35 +445,6 @@ class PackageManager
message = "Failed to load the #{path.basename(packagePath)} package"
atom.notifications.addError(message, {stack, detail, dismissable: true})
# TODO: remove these autocomplete-plus specific helpers after a few versions.
uninstallAutocompletePlus: ->
packageDir = null
devDir = path.join("dev", "packages")
for packageDirPath in @packageDirPaths
if not packageDirPath.endsWith(devDir)
packageDir = packageDirPath
break
if packageDir?
dirsToRemove = [
path.join(packageDir, 'autocomplete-plus')
path.join(packageDir, 'autocomplete-atom-api')
path.join(packageDir, 'autocomplete-css')
path.join(packageDir, 'autocomplete-html')
path.join(packageDir, 'autocomplete-snippets')
]
for dirToRemove in dirsToRemove
@uninstallDirectory(dirToRemove)
return
# TODO: remove this after a few versions
migrateSublimeTabsSettings: (packagePaths) ->
return if Grim.includeDeprecatedAPIs
for packagePath in packagePaths when path.basename(packagePath) is 'sublime-tabs'
atom.config.removeAtKeyPath('core.disabledPackages', 'tree-view')
atom.config.removeAtKeyPath('core.disabledPackages', 'tabs')
return
uninstallDirectory: (directory) ->
symlinkPromise = new Promise (resolve) ->
fs.isSymbolicLink directory, (isSymLink) -> resolve(isSymLink)
@ -495,25 +456,3 @@ class PackageManager
[isSymLink, isDir] = values
if not isSymLink and isDir
fs.remove directory, ->
if Grim.includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
EmitterMixin.includeInto(PackageManager)
PackageManager::on = (eventName) ->
switch eventName
when 'loaded'
Grim.deprecate 'Use PackageManager::onDidLoadInitialPackages instead'
when 'activated'
Grim.deprecate 'Use PackageManager::onDidActivateInitialPackages instead'
else
Grim.deprecate 'PackageManager::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)
PackageManager::onDidLoadAll = (callback) ->
Grim.deprecate("Use `::onDidLoadInitialPackages` instead.")
@onDidLoadInitialPackages(callback)
PackageManager::onDidActivateAll = (callback) ->
Grim.deprecate("Use `::onDidActivateInitialPackages` instead.")
@onDidActivateInitialPackages(callback)

View File

@ -6,7 +6,6 @@ async = require 'async'
CSON = require 'season'
fs = require 'fs-plus'
{Emitter, CompositeDisposable} = require 'event-kit'
{includeDeprecatedAPIs, deprecate} = require 'grim'
ModuleCache = require './module-cache'
ScopedProperties = require './scoped-properties'
@ -48,14 +47,6 @@ class Package
unless typeof metadata.name is 'string' and metadata.name.length > 0
metadata.name = packageName
if includeDeprecatedAPIs and metadata.stylesheetMain?
deprecate("Use the `mainStyleSheet` key instead of `stylesheetMain` in the `package.json` of `#{packageName}`", {packageName})
metadata.mainStyleSheet = metadata.stylesheetMain
if includeDeprecatedAPIs and metadata.stylesheets?
deprecate("Use the `styleSheets` key instead of `stylesheets` in the `package.json` of `#{packageName}`", {packageName})
metadata.styleSheets = metadata.stylesheets
metadata
keymaps: null
@ -174,11 +165,6 @@ class Package
if @mainModule?
if @mainModule.config? and typeof @mainModule.config is 'object'
atom.config.setSchema @name, {type: 'object', properties: @mainModule.config}
else if @mainModule.configDefaults? and typeof @mainModule.configDefaults is 'object'
deprecate("""Use a config schema instead. See the configuration section
of https://atom.io/docs/latest/hacking-atom-package-word-count and
https://atom.io/docs/api/latest/Config for more details""", {packageName: @name})
atom.config.setDefaults(@name, @mainModule.configDefaults)
@mainModule.activateConfig?()
@configActivated = true
@ -211,17 +197,6 @@ class Package
for [menuPath, map] in @menus when map['context-menu']?
try
itemsBySelector = map['context-menu']
# Detect deprecated format for items object
for key, value of itemsBySelector
unless _.isArray(value)
deprecate("""
The context menu CSON format has changed. Please see
https://atom.io/docs/api/latest/ContextMenuManager#context-menu-cson-format
for more info.
""", {packageName: @name})
itemsBySelector = atom.contextMenu.convertLegacyItemsBySelector(itemsBySelector)
@activationDisposables.add(atom.contextMenu.add(itemsBySelector))
catch error
if error.code is 'EBADSELECTOR'
@ -309,11 +284,7 @@ class Package
[stylesheetPath, atom.themes.loadStylesheet(stylesheetPath, true)]
getStylesheetsPath: ->
if fs.isDirectorySync(path.join(@path, 'stylesheets'))
deprecate("Store package style sheets in the `styles/` directory instead of `stylesheets/` in the `#{@name}` package", packageName: @name)
path.join(@path, 'stylesheets')
else
path.join(@path, 'styles')
path.join(@path, 'styles')
getStylesheetPaths: ->
stylesheetDirPath = @getStylesheetsPath()
@ -383,11 +354,7 @@ class Package
callback()
new Promise (resolve) =>
if fs.isDirectorySync(path.join(@path, 'scoped-properties'))
settingsDirPath = path.join(@path, 'scoped-properties')
deprecate("Store package settings files in the `settings/` directory instead of `scoped-properties/`", packageName: @name)
else
settingsDirPath = path.join(@path, 'settings')
settingsDirPath = path.join(@path, 'settings')
fs.exists settingsDirPath, (settingsDirExists) ->
return resolve() unless settingsDirExists
@ -417,7 +384,6 @@ class Package
@mainActivated = false
catch e
console.error "Error deactivating package '#{@name}'", e.stack
@emit 'deactivated' if includeDeprecatedAPIs
@emitter.emit 'did-deactivate'
deactivateConfig: ->
@ -533,31 +499,6 @@ class Package
else if _.isArray(commands)
@activationCommands[selector].push(commands...)
if @metadata.activationEvents?
deprecate("""
Use `activationCommands` instead of `activationEvents` in your package.json
Commands should be grouped by selector as follows:
```json
"activationCommands": {
"atom-workspace": ["foo:bar", "foo:baz"],
"atom-text-editor": ["foo:quux"]
}
```
""", {packageName: @name})
if _.isArray(@metadata.activationEvents)
for eventName in @metadata.activationEvents
@activationCommands['atom-workspace'] ?= []
@activationCommands['atom-workspace'].push(eventName)
else if _.isString(@metadata.activationEvents)
eventName = @metadata.activationEvents
@activationCommands['atom-workspace'] ?= []
@activationCommands['atom-workspace'].push(eventName)
else
for eventName, selector of @metadata.activationEvents
selector ?= 'atom-workspace'
@activationCommands[selector] ?= []
@activationCommands[selector].push(eventName)
@activationCommands
subscribeToActivationHooks: ->
@ -726,15 +667,3 @@ class Package
stack = error.stack ? error
atom.notifications.addFatalError(message, {stack, detail, dismissable: true})
if includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
EmitterMixin.includeInto(Package)
Package::on = (eventName) ->
switch eventName
when 'deactivated'
deprecate 'Use Package::onDidDeactivate instead'
else
deprecate 'Package::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)

View File

@ -1,17 +1,21 @@
{Emitter, CompositeDisposable} = require 'event-kit'
{flatten} = require 'underscore-plus'
Serializable = require 'serializable'
Model = require './model'
module.exports =
class PaneAxis extends Model
atom.deserializers.add(this)
Serializable.includeInto(this)
parent: null
container: null
orientation: null
@deserialize: (state, params) ->
container = params?.container
state.container = container
state.children = state.children.map (childState) -> atom.deserializers.deserialize(childState, {container})
new this(state)
constructor: ({@container, @orientation, children, flexScale}={}) ->
@emitter = new Emitter
@subscriptionsByChild = new WeakMap
@ -21,12 +25,8 @@ class PaneAxis extends Model
@addChild(child) for child in children
@flexScale = flexScale ? 1
deserializeParams: (params) ->
{container} = params
params.children = params.children.map (childState) -> atom.deserializers.deserialize(childState, {container})
params
serializeParams: ->
serialize: ->
deserializer: 'PaneAxis'
children: @children.map (child) -> child.serialize()
orientation: @orientation
flexScale: @flexScale

View File

@ -1,5 +1,4 @@
{CompositeDisposable} = require 'event-kit'
Grim = require 'grim'
_ = require 'underscore-plus'
module.exports =

View File

@ -1,7 +1,5 @@
{find, flatten} = require 'underscore-plus'
Grim = require 'grim'
{Emitter, CompositeDisposable} = require 'event-kit'
Serializable = require 'serializable'
Gutter = require './gutter'
Model = require './model'
Pane = require './pane'
@ -10,17 +8,23 @@ ItemRegistry = require './item-registry'
module.exports =
class PaneContainer extends Model
atom.deserializers.add(this)
Serializable.includeInto(this)
@version: 1
root: null
@deserialize: (state) ->
container = Object.create(@prototype) # allows us to pass a self reference to our child before invoking constructor
state.root = atom.deserializers.deserialize(state.root, {container})
state.destroyEmptyPanes = atom.config.get('core.destroyEmptyPanes')
state.activePane = find state.root.getPanes(), (pane) -> pane.id is state.activePaneId
@call(container, state) # run constructor
container
constructor: (params) ->
super
unless Grim.includeDeprecatedAPIs
@activePane = params?.activePane
@activePane = params?.activePane
@emitter = new Emitter
@subscriptions = new CompositeDisposable
@ -35,13 +39,9 @@ class PaneContainer extends Model
@monitorActivePaneItem()
@monitorPaneItems()
deserializeParams: (params) ->
params.root = atom.deserializers.deserialize(params.root, container: this)
params.destroyEmptyPanes = atom.config.get('core.destroyEmptyPanes')
params.activePane = find params.root.getPanes(), (pane) -> pane.id is params.activePaneId
params
serializeParams: (params) ->
serialize: (params) ->
deserializer: 'PaneContainer'
version: @constructor.version
root: @root?.serialize()
activePaneId: @activePane.id
@ -222,12 +222,3 @@ class PaneContainer extends Model
removedPaneItem: (item) ->
@itemRegistry.removeItem(item)
if Grim.includeDeprecatedAPIs
PaneContainer.properties
activePane: null
PaneContainer.behavior 'activePaneItem', ->
@$activePane
.switch((activePane) -> activePane?.$activeItem)
.distinctUntilChanged()

View File

@ -1,6 +1,5 @@
path = require 'path'
{CompositeDisposable} = require 'event-kit'
Grim = require 'grim'
class PaneElement extends HTMLElement
attached: false

View File

@ -1,7 +1,5 @@
{find, compact, extend, last} = require 'underscore-plus'
{Emitter} = require 'event-kit'
Serializable = require 'serializable'
Grim = require 'grim'
Model = require './model'
PaneAxis = require './pane-axis'
TextEditor = require './text-editor'
@ -13,14 +11,29 @@ TextEditor = require './text-editor'
module.exports =
class Pane extends Model
atom.deserializers.add(this)
Serializable.includeInto(this)
container: undefined
activeItem: undefined
focused: false
@deserialize: (state, params) ->
{items, activeItemURI, activeItemUri} = state
state.container = params?.container
activeItemURI ?= activeItemUri
state.items = compact(items.map (itemState) -> atom.deserializers.deserialize(itemState))
state.activeItem = find state.items, (item) ->
if typeof item.getURI is 'function'
itemURI = item.getURI()
itemURI is activeItemURI
new this(state)
constructor: (params) ->
super
unless Grim.includeDeprecatedAPIs
@container = params?.container
@activeItem = params?.activeItem
@container = params?.container
@activeItem = params?.activeItem
@focused = params?.focused
@emitter = new Emitter
@itemSubscriptions = new WeakMap
@ -30,33 +43,17 @@ class Pane extends Model
@setActiveItem(@items[0]) unless @getActiveItem()?
@setFlexScale(params?.flexScale ? 1)
# Called by the Serializable mixin during serialization.
serializeParams: ->
serialize: ->
if typeof @activeItem?.getURI is 'function'
activeItemURI = @activeItem.getURI()
else if Grim.includeDeprecatedAPIs and typeof @activeItem?.getUri is 'function'
activeItemURI = @activeItem.getUri()
deserializer: 'Pane'
id: @id
items: compact(@items.map((item) -> item.serialize?()))
activeItemURI: activeItemURI
focused: @focused
flexScale: @flexScale
# Called by the Serializable mixin during deserialization.
deserializeParams: (params) ->
{items, activeItemURI, activeItemUri} = params
activeItemURI ?= activeItemUri
params.items = compact(items.map (itemState) -> atom.deserializers.deserialize(itemState))
params.activeItem = find params.items, (item) ->
if typeof item.getURI is 'function'
itemURI = item.getURI()
else if Grim.includeDeprecatedAPIs and typeof item.getUri is 'function'
itemURI = item.getUri()
itemURI is activeItemURI
params
getParent: -> @parent
setParent: (@parent) -> @parent
@ -361,11 +358,8 @@ class Pane extends Model
if typeof item.onDidDestroy is 'function'
@itemSubscriptions.set item, item.onDidDestroy => @removeItem(item, true)
else if Grim.includeDeprecatedAPIs and typeof item.on is 'function'
@subscribe item, 'destroyed', => @removeItem(item, true)
@items.splice(index, 0, item)
@emit 'item-added', item, index if Grim.includeDeprecatedAPIs
@emitter.emit 'did-add-item', {item, index}
@setActiveItem(item) unless @getActiveItem()?
item
@ -389,9 +383,6 @@ class Pane extends Model
return if index is -1
@emitter.emit 'will-remove-item', {item, index, destroyed}
if Grim.includeDeprecatedAPIs and typeof item.on is 'function'
@unsubscribe item
@unsubscribeFromItem(item)
if item is @activeItem
@ -402,7 +393,6 @@ class Pane extends Model
else
@activatePreviousItem()
@items.splice(index, 1)
@emit 'item-removed', item, index, destroyed if Grim.includeDeprecatedAPIs
@emitter.emit 'did-remove-item', {item, index, destroyed}
@container?.didDestroyPaneItem({item, index, pane: this}) if destroyed
@destroy() if @items.length is 0 and atom.config.get('core.destroyEmptyPanes')
@ -415,7 +405,6 @@ class Pane extends Model
oldIndex = @items.indexOf(item)
@items.splice(oldIndex, 1)
@items.splice(newIndex, 0, item)
@emit 'item-moved', item, newIndex if Grim.includeDeprecatedAPIs
@emitter.emit 'did-move-item', {item, oldIndex, newIndex}
# Public: Move the given item to the given index on another pane.
@ -443,7 +432,6 @@ class Pane extends Model
destroyItem: (item) ->
index = @items.indexOf(item)
if index isnt -1
@emit 'before-item-destroyed', item if Grim.includeDeprecatedAPIs
@emitter.emit 'will-destroy-item', {item, index}
@container?.willDestroyPaneItem({item, index, pane: this})
if @promptToSaveItem(item)
@ -583,7 +571,6 @@ class Pane extends Model
throw new Error("Pane has been destroyed") if @isDestroyed()
@container?.setActivePane(this)
@emit 'activated' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-activate'
# Public: Close the pane and destroy all its items.
@ -732,60 +719,3 @@ class Pane extends Model
atom.notifications.addWarning("Unable to save file: A directory in the path '#{fileName}' could not be written to")
else
throw error
if Grim.includeDeprecatedAPIs
Pane.properties
container: undefined
activeItem: undefined
focused: false
Pane.behavior 'active', ->
@$container
.switch((container) -> container?.$activePane)
.map((activePane) => activePane is this)
.distinctUntilChanged()
Pane::on = (eventName) ->
switch eventName
when 'activated'
Grim.deprecate("Use Pane::onDidActivate instead")
when 'destroyed'
Grim.deprecate("Use Pane::onDidDestroy instead")
when 'item-added'
Grim.deprecate("Use Pane::onDidAddItem instead")
when 'item-removed'
Grim.deprecate("Use Pane::onDidRemoveItem instead")
when 'item-moved'
Grim.deprecate("Use Pane::onDidMoveItem instead")
when 'before-item-destroyed'
Grim.deprecate("Use Pane::onWillDestroyItem instead")
else
Grim.deprecate("Subscribing via ::on is deprecated. Use documented event subscription methods instead.")
super
Pane::behavior = (behaviorName) ->
switch behaviorName
when 'active'
Grim.deprecate("The $active behavior property is deprecated. Use ::observeActive or ::onDidChangeActive instead.")
when 'container'
Grim.deprecate("The $container behavior property is deprecated.")
when 'activeItem'
Grim.deprecate("The $activeItem behavior property is deprecated. Use ::observeActiveItem or ::onDidChangeActiveItem instead.")
when 'focused'
Grim.deprecate("The $focused behavior property is deprecated.")
else
Grim.deprecate("Pane::behavior is deprecated. Use event subscription methods instead.")
super
Pane::itemForUri = (uri) ->
Grim.deprecate("Use `::itemForURI` instead.")
@itemForURI(uri)
Pane::activateItemForUri = (uri) ->
Grim.deprecate("Use `::activateItemForURI` instead.")
@activateItemForURI(uri)
else
Pane::container = undefined
Pane::activeItem = undefined
Pane::focused = undefined

View File

@ -3,11 +3,8 @@ url = require 'url'
_ = require 'underscore-plus'
fs = require 'fs-plus'
{includeDeprecatedAPIs, deprecate} = require 'grim'
{Emitter} = require 'event-kit'
Serializable = require 'serializable'
TextBuffer = require 'text-buffer'
Grim = require 'grim'
DefaultDirectoryProvider = require './default-directory-provider'
Model = require './model'
@ -21,12 +18,25 @@ GitRepositoryProvider = require './git-repository-provider'
module.exports =
class Project extends Model
atom.deserializers.add(this)
Serializable.includeInto(this)
###
Section: Construction and Destruction
###
@deserialize: (state) ->
state.buffers = _.compact state.buffers.map (bufferState) ->
# Check that buffer's file path is accessible
return if fs.isDirectorySync(bufferState.filePath)
if bufferState.filePath
try
fs.closeSync(fs.openSync(bufferState.filePath, 'r'))
catch error
return unless error.code is 'ENOENT'
atom.deserializers.deserialize(bufferState)
new this(state)
constructor: ({path, paths, @buffers}={}) ->
@emitter = new Emitter
@buffers ?= []
@ -62,9 +72,6 @@ class Project extends Model
@subscribeToBuffer(buffer) for buffer in @buffers
if Grim.includeDeprecatedAPIs and path?
Grim.deprecate("Pass 'paths' array instead of 'path' to project constructor")
paths ?= _.compact([path])
@setPaths(paths)
@ -80,23 +87,11 @@ class Project extends Model
Section: Serialization
###
serializeParams: ->
serialize: ->
deserializer: 'Project'
paths: @getPaths()
buffers: _.compact(@buffers.map (buffer) -> buffer.serialize() if buffer.isRetained())
deserializeParams: (params) ->
params.buffers = _.compact params.buffers.map (bufferState) ->
# Check that buffer's file path is accessible
return if fs.isDirectorySync(bufferState.filePath)
if bufferState.filePath
try
fs.closeSync(fs.openSync(bufferState.filePath, 'r'))
catch error
return unless error.code is 'ENOENT'
atom.deserializers.deserialize(bufferState)
params
###
Section: Event Subscription
###
@ -166,16 +161,12 @@ class Project extends Model
#
# * `projectPaths` {Array} of {String} paths.
setPaths: (projectPaths) ->
if includeDeprecatedAPIs
rootDirectory.off() for rootDirectory in @rootDirectories
repository?.destroy() for repository in @repositories
@rootDirectories = []
@repositories = []
@addPath(projectPath, emitEvent: false) for projectPath in projectPaths
@emit "path-changed" if includeDeprecatedAPIs
@emitter.emit 'did-change-paths', projectPaths
# Public: Add a path to the project's list of root paths
@ -200,7 +191,6 @@ class Project extends Model
@repositories.push(repo ? null)
unless options?.emitEvent is false
@emit "path-changed" if includeDeprecatedAPIs
@emitter.emit 'did-change-paths', @getPaths()
# Public: remove a path from the project's list of root paths.
@ -220,9 +210,7 @@ class Project extends Model
if indexToRemove?
[removedDirectory] = @rootDirectories.splice(indexToRemove, 1)
[removedRepository] = @repositories.splice(indexToRemove, 1)
removedDirectory.off() if includeDeprecatedAPIs
removedRepository?.destroy() unless removedRepository in @repositories
@emit "path-changed" if includeDeprecatedAPIs
@emitter.emit "did-change-paths", @getPaths()
true
else
@ -402,7 +390,6 @@ class Project extends Model
addBufferAtIndex: (buffer, index, options={}) ->
@buffers.splice(index, 0, buffer)
@subscribeToBuffer(buffer)
@emit 'buffer-created', buffer if includeDeprecatedAPIs
@emitter.emit 'did-add-buffer', buffer
buffer
@ -442,66 +429,3 @@ class Project extends Model
""",
detail: error.message
dismissable: true
if includeDeprecatedAPIs
Project.pathForRepositoryUrl = (repoUrl) ->
deprecate '::pathForRepositoryUrl will be removed. Please remove from your code.'
[repoName] = url.parse(repoUrl).path.split('/')[-1..]
repoName = repoName.replace(/\.git$/, '')
path.join(atom.config.get('core.projectHome'), repoName)
Project::registerOpener = (opener) ->
deprecate("Use Workspace::addOpener instead")
atom.workspace.addOpener(opener)
Project::unregisterOpener = (opener) ->
deprecate("Call .dispose() on the Disposable returned from ::addOpener instead")
atom.workspace.unregisterOpener(opener)
Project::eachEditor = (callback) ->
deprecate("Use Workspace::observeTextEditors instead")
atom.workspace.observeTextEditors(callback)
Project::getEditors = ->
deprecate("Use Workspace::getTextEditors instead")
atom.workspace.getTextEditors()
Project::on = (eventName) ->
if eventName is 'path-changed'
Grim.deprecate("Use Project::onDidChangePaths instead")
else
Grim.deprecate("Project::on is deprecated. Use documented event subscription methods instead.")
super
Project::getRepo = ->
Grim.deprecate("Use ::getRepositories instead")
@getRepositories()[0]
Project::getPath = ->
Grim.deprecate("Use ::getPaths instead")
@getPaths()[0]
Project::setPath = (path) ->
Grim.deprecate("Use ::setPaths instead")
@setPaths([path])
Project::getRootDirectory = ->
Grim.deprecate("Use ::getDirectories instead")
@getDirectories()[0]
Project::resolve = (uri) ->
Grim.deprecate("Use `Project::getDirectories()[0]?.resolve()` instead")
@resolvePath(uri)
Project::scan = (regex, options={}, iterator) ->
Grim.deprecate("Use atom.workspace.scan instead of atom.project.scan")
atom.workspace.scan(regex, options, iterator)
Project::replace = (regex, replacementText, filePaths, iterator) ->
Grim.deprecate("Use atom.workspace.replace instead of atom.project.replace")
atom.workspace.replace(regex, replacementText, filePaths, iterator)
Project::openSync = (filePath, options={}) ->
deprecate("Use Project::open instead")
filePath = @resolvePath(filePath)
@buildEditorForBuffer(@bufferForPathSync(filePath), options)

View File

@ -1,7 +1,6 @@
{Point, Range} = require 'text-buffer'
{pick} = _ = require 'underscore-plus'
{Emitter} = require 'event-kit'
Grim = require 'grim'
Model = require './model'
NonWhitespaceRegExp = /\S/
@ -836,25 +835,3 @@ class Selection extends Model
getGoalScreenRange: ->
if goalScreenRange = @marker.getProperties().goalScreenRange
Range.fromObject(goalScreenRange)
if Grim.includeDeprecatedAPIs
Selection::on = (eventName) ->
switch eventName
when 'screen-range-changed'
Grim.deprecate("Use Selection::onDidChangeRange instead. Call ::getScreenRange() yourself in your callback if you need the range.")
when 'destroyed'
Grim.deprecate("Use Selection::onDidDestroy instead.")
else
Grim.deprecate("Selection::on is deprecated. Use documented event subscription methods instead.")
super
# Deprecated: Use {::deleteToBeginningOfWord} instead.
Selection::backspaceToBeginningOfWord = ->
deprecate("Use Selection::deleteToBeginningOfWord() instead")
@deleteToBeginningOfWord()
# Deprecated: Use {::deleteToBeginningOfLine} instead.
Selection::backspaceToBeginningOfLine = ->
deprecate("Use Selection::deleteToBeginningOfLine() instead")
@deleteToBeginningOfLine()

View File

@ -1,4 +0,0 @@
{Subscriber} = require 'emissary'
SubscriberMixin = componentDidUnmount: -> @unsubscribe()
Subscriber.extend(SubscriberMixin)
module.exports = SubscriberMixin

View File

@ -1,6 +1,6 @@
_ = require 'underscore-plus'
ChildProcess = require 'child_process'
{Emitter} = require 'emissary'
{Emitter} = require 'event-kit'
Grim = require 'grim'
# Extended: Run a node script in a separate process.
@ -38,8 +38,6 @@ Grim = require 'grim'
# ```
module.exports =
class Task
Emitter.includeInto(this)
# Public: A helper method to easily launch and run a task once.
#
# * `taskPath` The {String} path to the CoffeeScript/JavaScript file which
@ -66,6 +64,8 @@ class Task
# * `taskPath` The {String} path to the CoffeeScript/JavaScript file that
# exports a single {Function} to execute.
constructor: (taskPath) ->
@emitter = new Emitter
compileCacheRequire = "require('#{require.resolve('./compile-cache')}')"
compileCachePath = require('./compile-cache').getCacheDirectory()
taskBootstrapRequire = "require('#{require.resolve('./task-bootstrap')}');"
@ -95,7 +95,7 @@ class Task
handleEvents: ->
@childProcess.removeAllListeners()
@childProcess.on 'message', ({event, args}) =>
@emit(event, args...) if @childProcess?
@emitter.emit(event, args) if @childProcess?
# Catch the errors that happened before task-bootstrap.
if @childProcess.stdout?
@ -143,7 +143,12 @@ class Task
# * `callback` The {Function} to call when the event is emitted.
#
# Returns a {Disposable} that can be used to stop listening for the event.
on: (eventName, callback) -> Emitter::on.call(this, eventName, callback)
on: (eventName, callback) -> @emitter.on eventName, (args) -> callback(args...)
once: (eventName, callback) ->
disposable = @on eventName, (args...) ->
disposable.dispose()
callback(args...)
# Public: Forcefully stop the running task.
#
@ -162,5 +167,5 @@ class Task
cancel: ->
didForcefullyTerminate = @terminate()
if didForcefullyTerminate
@emit('task:cancelled')
@emitter.emit('task:cancelled')
didForcefullyTerminate

View File

@ -1,7 +1,6 @@
_ = require 'underscore-plus'
scrollbarStyle = require 'scrollbar-style'
{Range, Point} = require 'text-buffer'
grim = require 'grim'
{CompositeDisposable} = require 'event-kit'
ipc = require 'ipc'
@ -835,12 +834,3 @@ class TextEditorComponent
updateParentViewMiniClass: ->
@hostElement.classList.toggle('mini', @editor.isMini())
@rootElement.classList.toggle('mini', @editor.isMini())
if grim.includeDeprecatedAPIs
TextEditorComponent::setInvisibles = (invisibles={}) ->
grim.deprecate "Use config.set('editor.invisibles', invisibles) instead"
atom.config.set('editor.invisibles', invisibles)
TextEditorComponent::setShowInvisibles = (showInvisibles) ->
grim.deprecate "Use config.set('editor.showInvisibles', showInvisibles) instead"
atom.config.set('editor.showInvisibles', showInvisibles)

View File

@ -2,7 +2,6 @@
Path = require 'path'
{defaults} = require 'underscore-plus'
TextBuffer = require 'text-buffer'
Grim = require 'grim'
TextEditor = require './text-editor'
TextEditorComponent = require './text-editor-component'

View File

@ -1,8 +1,6 @@
_ = require 'underscore-plus'
path = require 'path'
Serializable = require 'serializable'
Delegator = require 'delegato'
{includeDeprecatedAPIs, deprecate} = require 'grim'
Grim = require 'grim'
{CompositeDisposable, Emitter} = require 'event-kit'
{Point, Range} = TextBuffer = require 'text-buffer'
LanguageMode = require './language-mode'
@ -56,11 +54,8 @@ GutterContainer = require './gutter-container'
# soft wraps and folds to ensure your code interacts with them correctly.
module.exports =
class TextEditor extends Model
Serializable.includeInto(this)
atom.deserializers.add(this)
Delegator.includeInto(this)
deserializing: false
callDisplayBufferCreatedHook: false
registerEditor: false
buffer: null
@ -72,9 +67,18 @@ class TextEditor extends Model
selectionFlashDuration: 500
gutterContainer: null
@delegatesMethods 'suggestedIndentForBufferRow', 'autoIndentBufferRow', 'autoIndentBufferRows',
'autoDecreaseIndentForBufferRow', 'toggleLineCommentForBufferRow', 'toggleLineCommentsForBufferRows',
toProperty: 'languageMode'
@deserialize: (state) ->
try
displayBuffer = DisplayBuffer.deserialize(state.displayBuffer)
catch error
if error.syscall is 'read'
return # Error reading the file, don't deserialize an editor for it
else
throw error
state.displayBuffer = displayBuffer
state.registerEditor = true
new this(state)
constructor: ({@softTabs, initialLine, initialColumn, tabLength, softWrapped, @displayBuffer, buffer, registerEditor, suppressCursorCreation, @mini, @placeholderText, lineNumberGutterVisible, largeFileMode}={}) ->
super
@ -106,11 +110,9 @@ class TextEditor extends Model
@setEncoding(atom.config.get('core.fileEncoding', scope: @getRootScopeDescriptor()))
@disposables.add @displayBuffer.onDidChangeScrollTop (scrollTop) =>
@emit 'scroll-top-changed', scrollTop if includeDeprecatedAPIs
@emitter.emit 'did-change-scroll-top', scrollTop
@disposables.add @displayBuffer.onDidChangeScrollLeft (scrollLeft) =>
@emit 'scroll-left-changed', scrollLeft if includeDeprecatedAPIs
@emitter.emit 'did-change-scroll-left', scrollLeft
@gutterContainer = new GutterContainer(this)
@ -121,45 +123,25 @@ class TextEditor extends Model
atom.workspace?.editorAdded(this) if registerEditor
serializeParams: ->
serialize: ->
deserializer: 'TextEditor'
id: @id
softTabs: @softTabs
scrollTop: @scrollTop
scrollLeft: @scrollLeft
displayBuffer: @displayBuffer.serialize()
deserializeParams: (params) ->
try
displayBuffer = DisplayBuffer.deserialize(params.displayBuffer)
catch error
if error.syscall is 'read'
return # Error reading the file, don't deserialize an editor for it
else
throw error
params.displayBuffer = displayBuffer
params.registerEditor = true
params
subscribeToBuffer: ->
@buffer.retain()
@disposables.add @buffer.onDidChangePath =>
unless atom.project.getPaths().length > 0
atom.project.setPaths([path.dirname(@getPath())])
@emit "title-changed" if includeDeprecatedAPIs
@emitter.emit 'did-change-title', @getTitle()
@emit "path-changed" if includeDeprecatedAPIs
@emitter.emit 'did-change-path', @getPath()
@disposables.add @buffer.onDidChangeEncoding =>
@emitter.emit 'did-change-encoding', @getEncoding()
@disposables.add @buffer.onDidDestroy => @destroy()
# TODO: remove these when we remove the deprecations. They are old events.
if includeDeprecatedAPIs
@subscribe @buffer.onDidStopChanging => @emit "contents-modified"
@subscribe @buffer.onDidConflict => @emit "contents-conflicted"
@subscribe @buffer.onDidChangeModified => @emit "modified-status-changed"
@preserveCursorPositionOnBufferReload()
subscribeToDisplayBuffer: ->
@ -168,22 +150,14 @@ class TextEditor extends Model
@disposables.add @displayBuffer.onDidTokenize => @handleTokenization()
@disposables.add @displayBuffer.onDidChange (e) =>
@mergeIntersectingSelections()
@emit 'screen-lines-changed', e if includeDeprecatedAPIs
@emitter.emit 'did-change', e
# TODO: remove these when we remove the deprecations. Though, no one is likely using them
if includeDeprecatedAPIs
@subscribe @displayBuffer.onDidChangeSoftWrapped (softWrapped) => @emit 'soft-wrap-changed', softWrapped
@subscribe @displayBuffer.onDidAddDecoration (decoration) => @emit 'decoration-added', decoration
@subscribe @displayBuffer.onDidRemoveDecoration (decoration) => @emit 'decoration-removed', decoration
subscribeToTabTypeConfig: ->
@tabTypeSubscription?.dispose()
@tabTypeSubscription = atom.config.observe 'editor.tabType', scope: @getRootScopeDescriptor(), =>
@softTabs = @shouldUseSoftTabs(defaultValue: @softTabs)
destroyed: ->
@unsubscribe() if includeDeprecatedAPIs
@disposables.dispose()
@tabTypeSubscription.dispose()
selection.destroy() for selection in @selections.slice()
@ -786,7 +760,6 @@ class TextEditor extends Model
(selection) =>
range = selection.insertText(text, options)
didInsertEvent = {text, range}
@emit('did-insert-text', didInsertEvent) if includeDeprecatedAPIs
@emitter.emit 'did-insert-text', didInsertEvent
range
, groupingInterval
@ -1138,10 +1111,14 @@ class TextEditor extends Model
@buffer.transact(groupingInterval, fn)
# Deprecated: Start an open-ended transaction.
beginTransaction: (groupingInterval) -> @buffer.beginTransaction(groupingInterval)
beginTransaction: (groupingInterval) ->
Grim.deprecate('Transactions should be performed via TextEditor::transact only')
@buffer.beginTransaction(groupingInterval)
# Deprecated: Commit an open-ended transaction started with {::beginTransaction}.
commitTransaction: -> @buffer.commitTransaction()
commitTransaction: ->
Grim.deprecate('Transactions should be performed via TextEditor::transact only')
@buffer.commitTransaction()
# Extended: Abort an open transaction, undoing any operations performed so far
# within the transaction.
@ -1333,9 +1310,6 @@ class TextEditor extends Model
#
# Returns a {Decoration} object
decorateMarker: (marker, decorationParams) ->
if includeDeprecatedAPIs and decorationParams.type is 'gutter' and not decorationParams.gutterName
deprecate("Decorations of `type: 'gutter'` have been renamed to `type: 'line-number'`.")
decorationParams.type = 'line-number'
@displayBuffer.decorateMarker(marker, decorationParams)
# Essential: Get all the decorations within a screen row range.
@ -1765,7 +1739,6 @@ class TextEditor extends Model
@decorateMarker(marker, type: 'line-number', class: 'cursor-line')
@decorateMarker(marker, type: 'line-number', class: 'cursor-line-no-selection', onlyHead: true, onlyEmpty: true)
@decorateMarker(marker, type: 'line', class: 'cursor-line', onlyEmpty: true)
@emit 'cursor-added', cursor if includeDeprecatedAPIs
@emitter.emit 'did-add-cursor', cursor
cursor
@ -2254,7 +2227,6 @@ class TextEditor extends Model
if selection.intersectsBufferRange(selectionBufferRange)
return selection
else
@emit 'selection-added', selection if includeDeprecatedAPIs
@emitter.emit 'did-add-selection', selection
selection
@ -2668,7 +2640,6 @@ class TextEditor extends Model
range = selection.insertText(text, options)
didInsertEvent = {text, range}
@emit('did-insert-text', didInsertEvent) if includeDeprecatedAPIs
@emitter.emit 'did-insert-text', didInsertEvent
# Essential: For each selection, if the selection is empty, cut all characters
@ -2976,17 +2947,17 @@ class TextEditor extends Model
getLastVisibleScreenRow: (suppressDeprecation) ->
unless suppressDeprecation
deprecate("This is now a view method. Call TextEditorElement::getLastVisibleScreenRow instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::getLastVisibleScreenRow instead.")
@getVisibleRowRange()[1]
pixelPositionForBufferPosition: (bufferPosition, suppressDeprecation) ->
unless suppressDeprecation
deprecate("This method is deprecated on the model layer. Use `TextEditorElement::pixelPositionForBufferPosition` instead")
Grim.deprecate("This method is deprecated on the model layer. Use `TextEditorElement::pixelPositionForBufferPosition` instead")
@displayBuffer.pixelPositionForBufferPosition(bufferPosition)
pixelPositionForScreenPosition: (screenPosition, suppressDeprecation) ->
unless suppressDeprecation
deprecate("This method is deprecated on the model layer. Use `TextEditorElement::pixelPositionForScreenPosition` instead")
Grim.deprecate("This method is deprecated on the model layer. Use `TextEditorElement::pixelPositionForScreenPosition` instead")
@displayBuffer.pixelPositionForScreenPosition(screenPosition)
getSelectionMarkerAttributes: ->
@ -3053,232 +3024,21 @@ class TextEditor extends Model
result = true
cancel = -> result = false
willInsertEvent = {cancel, text}
@emit('will-insert-text', willInsertEvent) if includeDeprecatedAPIs
@emitter.emit 'will-insert-text', willInsertEvent
result
if includeDeprecatedAPIs
TextEditor.delegatesProperties '$lineHeightInPixels', '$defaultCharWidth', '$height', '$width',
'$verticalScrollbarWidth', '$horizontalScrollbarHeight', '$scrollTop', '$scrollLeft',
toProperty: 'displayBuffer'
###
Section: Language Mode Delegated Methods
###
TextEditor::joinLine = ->
deprecate("Use TextEditor::joinLines() instead")
@joinLines()
suggestedIndentForBufferRow: (bufferRow, options) -> @languageMode.suggestedIndentForBufferRow(bufferRow, options)
TextEditor::scopesAtCursor = ->
deprecate 'Use editor.getLastCursor().getScopeDescriptor() instead'
@getLastCursor().getScopeDescriptor().getScopesArray()
autoIndentBufferRow: (bufferRow, options) -> @languageMode.autoIndentBufferRow(bufferRow, options)
TextEditor::getCursorScopes = ->
deprecate 'Use editor.getLastCursor().getScopeDescriptor() instead'
@scopesAtCursor()
autoIndentBufferRows: (startRow, endRow) -> @languageMode.autoIndentBufferRows(startRow, endRow)
TextEditor::getUri = ->
deprecate("Use `::getURI` instead")
@getURI()
autoDecreaseIndentForBufferRow: (bufferRow) -> @languageMode.autoDecreaseIndentForBufferRow(bufferRow)
TextEditor::lineForBufferRow = (bufferRow) ->
deprecate 'Use TextEditor::lineTextForBufferRow(bufferRow) instead'
@lineTextForBufferRow(bufferRow)
toggleLineCommentForBufferRow: (row) -> @languageMode.toggleLineCommentsForBufferRow(row)
TextEditor::lineForScreenRow = (screenRow) ->
deprecate "TextEditor::tokenizedLineForScreenRow(bufferRow) is the new name. But it's private. Try to use TextEditor::lineTextForScreenRow instead"
@tokenizedLineForScreenRow(screenRow)
TextEditor::linesForScreenRows = (start, end) ->
deprecate "Use TextEditor::tokenizedLinesForScreenRows instead"
@tokenizedLinesForScreenRows(start, end)
TextEditor::lineLengthForBufferRow = (row) ->
deprecate "Use editor.lineTextForBufferRow(row).length instead"
@lineTextForBufferRow(row).length
TextEditor::duplicateLine = ->
deprecate("Use TextEditor::duplicateLines() instead")
@duplicateLines()
TextEditor::scopesForBufferPosition = (bufferPosition) ->
deprecate 'Use ::scopeDescriptorForBufferPosition instead. The return value has changed! It now returns a `ScopeDescriptor`'
@scopeDescriptorForBufferPosition(bufferPosition).getScopesArray()
TextEditor::toggleSoftWrap = ->
deprecate("Use TextEditor::toggleSoftWrapped instead")
@toggleSoftWrapped()
TextEditor::setSoftWrap = (softWrapped) ->
deprecate("Use TextEditor::setSoftWrapped instead")
@setSoftWrapped(softWrapped)
TextEditor::backspaceToBeginningOfWord = ->
deprecate("Use TextEditor::deleteToBeginningOfWord() instead")
@deleteToBeginningOfWord()
TextEditor::backspaceToBeginningOfLine = ->
deprecate("Use TextEditor::deleteToBeginningOfLine() instead")
@deleteToBeginningOfLine()
TextEditor::getGutterDecorations = (propertyFilter) ->
deprecate("Use ::getLineNumberDecorations instead")
@getLineNumberDecorations(propertyFilter)
TextEditor::getCursorScreenRow = ->
deprecate('Use `editor.getCursorScreenPosition().row` instead')
@getCursorScreenPosition().row
TextEditor::moveCursorUp = (lineCount) ->
deprecate("Use TextEditor::moveUp() instead")
@moveUp(lineCount)
TextEditor::moveCursorDown = (lineCount) ->
deprecate("Use TextEditor::moveDown() instead")
@moveDown(lineCount)
TextEditor::moveCursorLeft = ->
deprecate("Use TextEditor::moveLeft() instead")
@moveLeft()
TextEditor::moveCursorRight = ->
deprecate("Use TextEditor::moveRight() instead")
@moveRight()
TextEditor::moveCursorToBeginningOfLine = ->
deprecate("Use TextEditor::moveToBeginningOfLine() instead")
@moveToBeginningOfLine()
TextEditor::moveCursorToBeginningOfScreenLine = ->
deprecate("Use TextEditor::moveToBeginningOfScreenLine() instead")
@moveToBeginningOfScreenLine()
TextEditor::moveCursorToFirstCharacterOfLine = ->
deprecate("Use TextEditor::moveToFirstCharacterOfLine() instead")
@moveToFirstCharacterOfLine()
TextEditor::moveCursorToEndOfLine = ->
deprecate("Use TextEditor::moveToEndOfLine() instead")
@moveToEndOfLine()
TextEditor::moveCursorToEndOfScreenLine = ->
deprecate("Use TextEditor::moveToEndOfScreenLine() instead")
@moveToEndOfScreenLine()
TextEditor::moveCursorToBeginningOfWord = ->
deprecate("Use TextEditor::moveToBeginningOfWord() instead")
@moveToBeginningOfWord()
TextEditor::moveCursorToEndOfWord = ->
deprecate("Use TextEditor::moveToEndOfWord() instead")
@moveToEndOfWord()
TextEditor::moveCursorToTop = ->
deprecate("Use TextEditor::moveToTop() instead")
@moveToTop()
TextEditor::moveCursorToBottom = ->
deprecate("Use TextEditor::moveToBottom() instead")
@moveToBottom()
TextEditor::moveCursorToBeginningOfNextWord = ->
deprecate("Use TextEditor::moveToBeginningOfNextWord() instead")
@moveToBeginningOfNextWord()
TextEditor::moveCursorToPreviousWordBoundary = ->
deprecate("Use TextEditor::moveToPreviousWordBoundary() instead")
@moveToPreviousWordBoundary()
TextEditor::moveCursorToNextWordBoundary = ->
deprecate("Use TextEditor::moveToNextWordBoundary() instead")
@moveToNextWordBoundary()
TextEditor::moveCursorToBeginningOfNextParagraph = ->
deprecate("Use TextEditor::moveToBeginningOfNextParagraph() instead")
@moveToBeginningOfNextParagraph()
TextEditor::moveCursorToBeginningOfPreviousParagraph = ->
deprecate("Use TextEditor::moveToBeginningOfPreviousParagraph() instead")
@moveToBeginningOfPreviousParagraph()
TextEditor::getCursor = ->
deprecate("Use TextEditor::getLastCursor() instead")
@getLastCursor()
TextEditor::selectLine = ->
deprecate('Use TextEditor::selectLinesContainingCursors instead')
@selectLinesContainingCursors()
TextEditor::selectWord = ->
deprecate('Use TextEditor::selectWordsContainingCursors instead')
@selectWordsContainingCursors()
TextEditor::getSelection = (index) ->
if index?
deprecate("Use TextEditor::getSelections()[index] instead when getting a specific selection")
@getSelections()[index]
else
deprecate("Use TextEditor::getLastSelection() instead")
@getLastSelection()
TextEditor::getSoftWrapped = ->
deprecate("Use TextEditor::isSoftWrapped instead")
@displayBuffer.isSoftWrapped()
EmitterMixin = require('emissary').Emitter
TextEditor::on = (eventName) ->
switch eventName
when 'title-changed'
deprecate("Use TextEditor::onDidChangeTitle instead")
when 'path-changed'
deprecate("Use TextEditor::onDidChangePath instead")
when 'modified-status-changed'
deprecate("Use TextEditor::onDidChangeModified instead")
when 'soft-wrap-changed'
deprecate("Use TextEditor::onDidChangeSoftWrapped instead")
when 'grammar-changed'
deprecate("Use TextEditor::onDidChangeGrammar instead")
when 'character-widths-changed'
deprecate("Use TextEditor::onDidChangeCharacterWidths instead")
when 'contents-modified'
deprecate("Use TextEditor::onDidStopChanging instead")
when 'contents-conflicted'
deprecate("Use TextEditor::onDidConflict instead")
when 'will-insert-text'
deprecate("Use TextEditor::onWillInsertText instead")
when 'did-insert-text'
deprecate("Use TextEditor::onDidInsertText instead")
when 'cursor-added'
deprecate("Use TextEditor::onDidAddCursor instead")
when 'cursor-removed'
deprecate("Use TextEditor::onDidRemoveCursor instead")
when 'cursor-moved'
deprecate("Use TextEditor::onDidChangeCursorPosition instead")
when 'selection-added'
deprecate("Use TextEditor::onDidAddSelection instead")
when 'selection-removed'
deprecate("Use TextEditor::onDidRemoveSelection instead")
when 'selection-screen-range-changed'
deprecate("Use TextEditor::onDidChangeSelectionRange instead")
when 'decoration-added'
deprecate("Use TextEditor::onDidAddDecoration instead")
when 'decoration-removed'
deprecate("Use TextEditor::onDidRemoveDecoration instead")
when 'decoration-updated'
deprecate("Use Decoration::onDidChangeProperties instead. You will get the decoration back from `TextEditor::decorateMarker()`")
when 'decoration-changed'
deprecate("Use Marker::onDidChange instead. e.g. `editor::decorateMarker(...).getMarker().onDidChange()`")
when 'screen-lines-changed'
deprecate("Use TextEditor::onDidChange instead")
when 'scroll-top-changed'
deprecate("Use TextEditor::onDidChangeScrollTop instead")
when 'scroll-left-changed'
deprecate("Use TextEditor::onDidChangeScrollLeft instead")
else
deprecate("TextEditor::on is deprecated. Use documented event subscription methods instead.")
EmitterMixin::on.apply(this, arguments)
toggleLineCommentsForBufferRows: (start, end) -> @languageMode.toggleLineCommentsForBufferRows(start, end)

View File

@ -3,7 +3,6 @@ _ = require 'underscore-plus'
{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
{File} = require 'pathwatcher'
fs = require 'fs-plus'
Grim = require 'grim'
# Extended: Handles loading and activating available themes.
#
@ -16,35 +15,6 @@ class ThemeManager
@lessCache = null
@initialLoadComplete = false
@packageManager.registerPackageActivator(this, ['theme'])
@sheetsByStyleElement = new WeakMap
stylesElement = document.head.querySelector('atom-styles')
stylesElement.onDidAddStyleElement @styleElementAdded.bind(this)
stylesElement.onDidRemoveStyleElement @styleElementRemoved.bind(this)
stylesElement.onDidUpdateStyleElement @styleElementUpdated.bind(this)
styleElementAdded: (styleElement) ->
{sheet} = styleElement
@sheetsByStyleElement.set(styleElement, sheet)
@emit 'stylesheet-added', sheet if Grim.includeDeprecatedAPIs
@emitter.emit 'did-add-stylesheet', sheet
@emit 'stylesheets-changed' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-stylesheets'
styleElementRemoved: (styleElement) ->
sheet = @sheetsByStyleElement.get(styleElement)
@emit 'stylesheet-removed', sheet if Grim.includeDeprecatedAPIs
@emitter.emit 'did-remove-stylesheet', sheet
@emit 'stylesheets-changed' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-stylesheets'
styleElementUpdated: ({sheet}) ->
@emit 'stylesheet-removed', sheet if Grim.includeDeprecatedAPIs
@emitter.emit 'did-remove-stylesheet', sheet
@emit 'stylesheet-added', sheet if Grim.includeDeprecatedAPIs
@emitter.emit 'did-add-stylesheet', sheet
@emit 'stylesheets-changed' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-stylesheets'
###
Section: Event Subscription
@ -56,7 +26,6 @@ class ThemeManager
# * `callback` {Function}
onDidChangeActiveThemes: (callback) ->
@emitter.on 'did-change-active-themes', callback
@emitter.on 'did-reload-all', callback # TODO: Remove once deprecated pre-1.0 APIs are gone
###
Section: Accessing Available Themes
@ -96,6 +65,13 @@ class ThemeManager
Section: Managing Enabled Themes
###
warnForNonExistentThemes: ->
themeNames = atom.config.get('core.themes') ? []
themeNames = [themeNames] unless _.isArray(themeNames)
for themeName in themeNames
unless themeName and typeof themeName is 'string' and atom.packages.resolvePackagePath(themeName)
console.warn("Enabled theme '#{themeName}' is not installed.")
# Public: Get the enabled theme names from the config.
#
# Returns an array of theme names in the order that they should be activated.
@ -105,7 +81,6 @@ class ThemeManager
themeNames = themeNames.filter (themeName) ->
if themeName and typeof themeName is 'string'
return true if atom.packages.resolvePackagePath(themeName)
console.warn("Enabled theme '#{themeName}' is not installed.")
false
# Use a built-in syntax and UI theme any time the configured themes are not
@ -264,6 +239,8 @@ class ThemeManager
atom.config.observe 'core.themes', =>
@deactivateThemes()
@warnForNonExistentThemes()
@refreshLessCache() # Update cache for packages in core.themes config
promises = []
@ -279,7 +256,6 @@ class ThemeManager
@loadUserStylesheet()
@reloadBaseStylesheets()
@initialLoadComplete = true
@emit 'reloaded' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change-active-themes'
resolve()
@ -292,10 +268,10 @@ class ThemeManager
isInitialLoadComplete: -> @initialLoadComplete
addActiveThemeClasses: ->
workspaceElement = atom.views.getView(atom.workspace)
for pack in @getActiveThemes()
workspaceElement.classList.add("theme-#{pack.name}")
return
if workspaceElement = atom.views.getView(atom.workspace)
for pack in @getActiveThemes()
workspaceElement.classList.add("theme-#{pack.name}")
return
removeActiveThemeClasses: ->
workspaceElement = atom.views.getView(atom.workspace)
@ -321,59 +297,3 @@ class ThemeManager
themePaths.push(path.join(themePath, 'styles'))
themePaths.filter (themePath) -> fs.isDirectorySync(themePath)
if Grim.includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
EmitterMixin.includeInto(ThemeManager)
ThemeManager::on = (eventName) ->
switch eventName
when 'reloaded'
Grim.deprecate 'Use ThemeManager::onDidChangeActiveThemes instead'
when 'stylesheet-added'
Grim.deprecate 'Use ThemeManager::onDidAddStylesheet instead'
when 'stylesheet-removed'
Grim.deprecate 'Use ThemeManager::onDidRemoveStylesheet instead'
when 'stylesheet-updated'
Grim.deprecate 'Use ThemeManager::onDidUpdateStylesheet instead'
when 'stylesheets-changed'
Grim.deprecate 'Use ThemeManager::onDidChangeStylesheets instead'
else
Grim.deprecate 'ThemeManager::on is deprecated. Use event subscription methods instead.'
EmitterMixin::on.apply(this, arguments)
ThemeManager::onDidReloadAll = (callback) ->
Grim.deprecate("Use `::onDidChangeActiveThemes` instead.")
@onDidChangeActiveThemes(callback)
ThemeManager::onDidAddStylesheet = (callback) ->
Grim.deprecate("Use atom.styles.onDidAddStyleElement instead")
@emitter.on 'did-add-stylesheet', callback
ThemeManager::onDidRemoveStylesheet = (callback) ->
Grim.deprecate("Use atom.styles.onDidRemoveStyleElement instead")
@emitter.on 'did-remove-stylesheet', callback
ThemeManager::onDidUpdateStylesheet = (callback) ->
Grim.deprecate("Use atom.styles.onDidUpdateStyleElement instead")
@emitter.on 'did-update-stylesheet', callback
ThemeManager::onDidChangeStylesheets = (callback) ->
Grim.deprecate("Use atom.styles.onDidAdd/RemoveStyleElement instead")
@emitter.on 'did-change-stylesheets', callback
ThemeManager::getUserStylesheetPath = ->
Grim.deprecate("Call atom.styles.getUserStyleSheetPath() instead")
atom.styles.getUserStyleSheetPath()
ThemeManager::getLoadedNames = ->
Grim.deprecate("Use `::getLoadedThemeNames` instead.")
@getLoadedThemeNames()
ThemeManager::getActiveNames = ->
Grim.deprecate("Use `::getActiveThemeNames` instead.")
@getActiveThemeNames()
ThemeManager::setEnabledThemes = (enabledThemeNames) ->
Grim.deprecate("Use `atom.config.set('core.themes', arrayOfThemeNames)` instead")
atom.config.set('core.themes', enabledThemeNames)

View File

@ -2,18 +2,14 @@ _ = require 'underscore-plus'
{CompositeDisposable, Emitter} = require 'event-kit'
{Point, Range} = require 'text-buffer'
{ScopeSelector} = require 'first-mate'
Serializable = require 'serializable'
Model = require './model'
TokenizedLine = require './tokenized-line'
TokenIterator = require './token-iterator'
Token = require './token'
ScopeDescriptor = require './scope-descriptor'
Grim = require 'grim'
module.exports =
class TokenizedBuffer extends Model
Serializable.includeInto(this)
grammar: null
currentGrammarScore: null
buffer: null
@ -25,6 +21,10 @@ class TokenizedBuffer extends Model
configSettings: null
changeCount: 0
@deserialize: (state) ->
state.buffer = atom.project.bufferForPathSync(state.bufferPath)
new this(state)
constructor: ({@buffer, @tabLength, @ignoreInvisibles, @largeFileMode}) ->
@emitter = new Emitter
@disposables = new CompositeDisposable
@ -41,16 +41,13 @@ class TokenizedBuffer extends Model
destroyed: ->
@disposables.dispose()
serializeParams: ->
serialize: ->
deserializer: 'TokenizedBuffer'
bufferPath: @buffer.getPath()
tabLength: @tabLength
ignoreInvisibles: @ignoreInvisibles
largeFileMode: @largeFileMode
deserializeParams: (params) ->
params.buffer = atom.project.bufferForPathSync(params.bufferPath)
params
observeGrammar: (callback) ->
callback(@grammar)
@onDidChangeGrammar(callback)
@ -128,7 +125,6 @@ class TokenizedBuffer extends Model
@invalidateRow(0)
@fullyTokenized = false
event = {start: 0, end: lastRow, delta: 0}
@emit 'changed', event if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change', event
setVisible: (@visible) ->
@ -191,7 +187,6 @@ class TokenizedBuffer extends Model
[startRow, endRow] = @updateFoldableStatus(startRow, endRow)
event = {start: startRow, end: endRow, delta: 0}
@emit 'changed', event if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change', event
if @firstInvalidRow()?
@ -201,7 +196,6 @@ class TokenizedBuffer extends Model
markTokenizationComplete: ->
unless @fullyTokenized
@emit 'tokenized' if Grim.includeDeprecatedAPIs
@emitter.emit 'did-tokenize'
@fullyTokenized = true
@ -255,7 +249,6 @@ class TokenizedBuffer extends Model
end -= delta
event = {start, end, delta, bufferChange: e}
@emit 'changed', event if Grim.includeDeprecatedAPIs
@emitter.emit 'did-change', event
retokenizeWhitespaceRowsIfIndentLevelChanged: (row, increment) ->
@ -539,22 +532,6 @@ class TokenizedBuffer extends Model
console.log row, line, line.length
return
if Grim.includeDeprecatedAPIs
EmitterMixin = require('emissary').Emitter
TokenizedBuffer::on = (eventName) ->
switch eventName
when 'changed'
Grim.deprecate("Use TokenizedBuffer::onDidChange instead")
when 'grammar-changed'
Grim.deprecate("Use TokenizedBuffer::onDidChangeGrammar instead")
when 'tokenized'
Grim.deprecate("Use TokenizedBuffer::onDidTokenize instead")
else
Grim.deprecate("TokenizedBuffer::on is deprecated. Use event subscription methods instead.")
EmitterMixin::on.apply(this, arguments)
selectorMatchesAnyScope = (selector, scopes) ->
targetClasses = selector.replace(/^\./, '').split('.')
_.any scopes, (scope) ->

View File

@ -1,10 +1,7 @@
{includeDeprecatedAPIs, deprecate} = require 'grim'
_ = require 'underscore-plus'
path = require 'path'
{join} = path
Serializable = require 'serializable'
{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
Grim = require 'grim'
fs = require 'fs-plus'
DefaultDirectorySearcher = require './default-directory-searcher'
Model = require './model'
@ -30,15 +27,22 @@ Task = require './task'
module.exports =
class Workspace extends Model
atom.deserializers.add(this)
Serializable.includeInto(this)
@deserialize: (state) ->
return unless state?
for packageName in state.packagesWithActiveGrammars ? []
atom.packages.getLoadedPackage(packageName)?.loadGrammarsSync()
state.paneContainer = PaneContainer.deserialize(state.paneContainer)
new this(state)
constructor: (params) ->
super
unless Grim.includeDeprecatedAPIs
@paneContainer = params?.paneContainer
@fullScreen = params?.fullScreen ? false
@destroyedItemURIs = params?.destroyedItemURIs ? []
@paneContainer = params?.paneContainer
@fullScreen = params?.fullScreen ? false
@destroyedItemURIs = params?.destroyedItemURIs ? []
@emitter = new Emitter
@openers = []
@ -84,16 +88,9 @@ class Workspace extends Model
@subscribeToFontSize()
# Called by the Serializable mixin during deserialization
deserializeParams: (params) ->
for packageName in params.packagesWithActiveGrammars ? []
atom.packages.getLoadedPackage(packageName)?.loadGrammarsSync()
params.paneContainer = PaneContainer.deserialize(params.paneContainer)
params
# Called by the Serializable mixin during serialization.
serializeParams: ->
serialize: ->
deserializer: 'Workspace'
paneContainer: @paneContainer.serialize()
fullScreen: atom.isFullScreen()
packagesWithActiveGrammars: @getPackageNamesWithActiveGrammars()
@ -120,7 +117,6 @@ class Workspace extends Model
_.uniq(packageNames)
editorAdded: (editor) ->
@emit 'editor-created', editor if includeDeprecatedAPIs
installShellCommands: ->
require('./command-installer').installShellCommandsInteractively()
@ -409,12 +405,6 @@ class Workspace extends Model
# * `activatePane` A {Boolean} indicating whether to call {Pane::activate} on
# the containing pane. Defaults to `true`.
openSync: (uri='', options={}) ->
# TODO: Remove deprecated changeFocus option
if includeDeprecatedAPIs and options.changeFocus?
deprecate("The `changeFocus` option has been renamed to `activatePane`")
options.activatePane = options.changeFocus
delete options.changeFocus
{initialLine, initialColumn} = options
activatePane = options.activatePane ? true
@ -430,12 +420,6 @@ class Workspace extends Model
item
openURIInPane: (uri, pane, options={}) ->
# TODO: Remove deprecated changeFocus option
if includeDeprecatedAPIs and options.changeFocus?
deprecate("The `changeFocus` option has been renamed to `activatePane`")
options.activatePane = options.changeFocus
delete options.changeFocus
activatePane = options.activatePane ? true
if uri?
@ -475,7 +459,6 @@ class Workspace extends Model
item.setCursorBufferPosition?([initialLine, initialColumn])
index = pane.getActiveItemIndex()
@emit "uri-opened" if includeDeprecatedAPIs
@emitter.emit 'did-open', {uri, pane, item, index}
item
@ -515,24 +498,8 @@ class Workspace extends Model
# {Workspace::open} on the URI `quux-preview://foo/bar/baz.quux`. Then your opener
# can check the protocol for quux-preview and only handle those URIs that match.
addOpener: (opener) ->
if includeDeprecatedAPIs
packageName = @getCallingPackageName()
wrappedOpener = (uri, options) ->
item = opener(uri, options)
if item? and typeof item.getUri is 'function' and typeof item.getURI isnt 'function'
Grim.deprecate("Pane item with class `#{item.constructor.name}` should implement `::getURI` instead of `::getUri`.", {packageName})
if item? and typeof item.on is 'function' and typeof item.onDidChangeTitle isnt 'function'
Grim.deprecate("If you would like your pane item with class `#{item.constructor.name}` to support title change behavior, please implement a `::onDidChangeTitle()` method. `::on` methods for items are no longer supported. If not, ignore this message.", {packageName})
if item? and typeof item.on is 'function' and typeof item.onDidChangeModified isnt 'function'
Grim.deprecate("If you would like your pane item with class `#{item.constructor.name}` to support modified behavior, please implement a `::onDidChangeModified()` method. If not, ignore this message. `::on` methods for items are no longer supported.", {packageName})
item
@openers.push(wrappedOpener)
new Disposable => _.remove(@openers, wrappedOpener)
else
@openers.push(opener)
new Disposable => _.remove(@openers, opener)
@openers.push(opener)
new Disposable => _.remove(@openers, opener)
getOpeners: ->
@openers
@ -960,96 +927,3 @@ class Workspace extends Model
inProcessFinished = true
checkFinished()
if includeDeprecatedAPIs
Workspace.properties
paneContainer: null
fullScreen: false
destroyedItemURIs: -> []
Object.defineProperty Workspace::, 'activePaneItem',
get: ->
Grim.deprecate "Use ::getActivePaneItem() instead of the ::activePaneItem property"
@getActivePaneItem()
Object.defineProperty Workspace::, 'activePane',
get: ->
Grim.deprecate "Use ::getActivePane() instead of the ::activePane property"
@getActivePane()
StackTraceParser = require 'stacktrace-parser'
Workspace::getCallingPackageName = ->
error = new Error
Error.captureStackTrace(error)
stack = StackTraceParser.parse(error.stack)
packagePaths = @getPackagePathsByPackageName()
for i in [0...stack.length]
stackFramePath = stack[i].file
# Empty when it was run from the dev console
return unless stackFramePath
for packageName, packagePath of packagePaths
continue if stackFramePath is 'node.js'
relativePath = path.relative(packagePath, stackFramePath)
return packageName unless /^\.\./.test(relativePath)
return
Workspace::getPackagePathsByPackageName = ->
packagePathsByPackageName = {}
for pack in atom.packages.getLoadedPackages()
packagePath = pack.path
if packagePath.indexOf('.atom/dev/packages') > -1 or packagePath.indexOf('.atom/packages') > -1
packagePath = fs.realpathSync(packagePath)
packagePathsByPackageName[pack.name] = packagePath
packagePathsByPackageName
Workspace::eachEditor = (callback) ->
deprecate("Use Workspace::observeTextEditors instead")
callback(editor) for editor in @getEditors()
@subscribe this, 'editor-created', (editor) -> callback(editor)
Workspace::getEditors = ->
deprecate("Use Workspace::getTextEditors instead")
editors = []
for pane in @paneContainer.getPanes()
editors.push(item) for item in pane.getItems() when item instanceof TextEditor
editors
Workspace::on = (eventName) ->
switch eventName
when 'editor-created'
deprecate("Use Workspace::onDidAddTextEditor or Workspace::observeTextEditors instead.")
when 'uri-opened'
deprecate("Use Workspace::onDidOpen or Workspace::onDidAddPaneItem instead. https://atom.io/docs/api/latest/Workspace#instance-onDidOpen")
else
deprecate("Subscribing via ::on is deprecated. Use documented event subscription methods instead.")
super
Workspace::reopenItemSync = ->
deprecate("Use Workspace::reopenItem instead")
if uri = @destroyedItemURIs.pop()
@openSync(uri)
Workspace::registerOpener = (opener) ->
Grim.deprecate("Call Workspace::addOpener instead")
@addOpener(opener)
Workspace::unregisterOpener = (opener) ->
Grim.deprecate("Call .dispose() on the Disposable returned from ::addOpener instead")
_.remove(@openers, opener)
Workspace::getActiveEditor = ->
Grim.deprecate "Call ::getActiveTextEditor instead"
@getActivePane()?.getActiveEditor()
Workspace::paneForUri = (uri) ->
deprecate("Use ::paneForURI instead.")
@paneForURI(uri)

View File

@ -64,9 +64,6 @@
ModuleCache.register(loadSettings)
ModuleCache.add(loadSettings.resourcePath)
// Only include deprecated APIs when running core spec
require('grim').includeDeprecatedAPIs = isRunningCoreSpecs(loadSettings)
// Start the crash reporter before anything else.
require('crash-reporter').start({
productName: 'Atom',
@ -184,14 +181,6 @@
}, false)
}
function isRunningCoreSpecs (loadSettings) {
return !!(loadSettings &&
loadSettings.isSpec &&
loadSettings.specDirectory &&
loadSettings.resourcePath &&
path.dirname(loadSettings.specDirectory) === loadSettings.resourcePath)
}
parseLoadSettings()
setupWindowBackground()
})()