Deprecate s|getAttributes for s|getProperties

This commit is contained in:
Ben Ogle
2014-09-17 17:57:37 -07:00
parent bd19899dd8
commit cef8b95ef3
4 changed files with 16 additions and 10 deletions

View File

@@ -1020,8 +1020,8 @@ describe "DisplayBuffer", ->
marker2 = marker1.copy(b: 3)
expect(marker2.getBufferRange()).toEqual marker1.getBufferRange()
expect(displayBuffer.getMarkerCount()).toBe initialMarkerCount + 2
expect(marker1.getAttributes()).toEqual a: 1, b: 2
expect(marker2.getAttributes()).toEqual a: 1, b: 3
expect(marker1.getProperties()).toEqual a: 1, b: 2
expect(marker2.getProperties()).toEqual a: 1, b: 3
describe "DisplayBufferMarker::getPixelRange()", ->
it "returns the start and end positions of the marker based on the line height and character widths assigned to the DisplayBuffer", ->

View File

@@ -139,15 +139,21 @@ class DisplayBufferMarker
# Extended: Returns an {Object} containing any custom properties associated with
# the marker.
getAttributes: ->
getProperties: ->
@bufferMarker.getProperties()
getAttributes: ->
deprecate 'Use Marker::getProperties instead'
@getProperties()
# Extended: Merges an {Object} containing new properties into the marker's
# existing properties.
#
# * `properties` {Object}
setAttributes: (attributes) ->
@bufferMarker.setProperties(attributes)
setProperties: (properties) ->
@bufferMarker.setProperties(properties)
setAttributes: (properties) ->
deprecate 'Use Marker::getProperties instead'
@setProperties(properties)
matchesAttributes: (attributes) ->
attributes = @displayBuffer.translateToBufferMarkerParams(attributes)

View File

@@ -93,7 +93,7 @@ class Editor extends Model
@softTabs = @usesSoftTabs() ? @softTabs ? atom.config.get('editor.softTabs') ? true
for marker in @findMarkers(@getSelectionMarkerAttributes())
marker.setAttributes(preserveFolds: true)
marker.setProperties(preserveFolds: true)
@addSelection(marker)
@subscribeToBuffer()
@@ -2480,13 +2480,13 @@ class Editor extends Model
#
# Returns the new {Selection}.
addSelection: (marker, options={}) ->
unless marker.getAttributes().preserveFolds
unless marker.getProperties().preserveFolds
@destroyFoldsIntersectingBufferRange(marker.getBufferRange())
cursor = @addCursor(marker)
selection = new Selection(_.extend({editor: this, marker, cursor}, options))
@selections.push(selection)
selectionBufferRange = selection.getBufferRange()
@mergeIntersectingSelections(preserveFolds: marker.getAttributes().preserveFolds)
@mergeIntersectingSelections(preserveFolds: marker.getProperties().preserveFolds)
if selection.destroyed
for selection in @getSelections()
if selection.intersectsBufferRange(selectionBufferRange)

View File

@@ -176,7 +176,7 @@ class Selection extends Model
# Public: Clears the selection, moving the marker to the head.
clear: ->
@marker.setAttributes(goalBufferRange: null)
@marker.setProperties(goalBufferRange: null)
@marker.clearTail() unless @retainSelection
@finalize()
@@ -717,5 +717,5 @@ class Selection extends Model
@marker.plantTail()
getGoalBufferRange: ->
if goalBufferRange = @marker.getAttributes().goalBufferRange
if goalBufferRange = @marker.getProperties().goalBufferRange
Range.fromObject(goalBufferRange)