Merge pull request #8985 from atom/as-fix-deprecations

Fix deprecations
This commit is contained in:
Antonio Scandurra
2015-09-30 11:31:19 +02:00
8 changed files with 146 additions and 79 deletions

View File

@@ -85,7 +85,7 @@
"dev-live-reload": "0.47.0",
"encoding-selector": "0.21.0",
"exception-reporting": "0.37.0",
"find-and-replace": "0.182.0",
"find-and-replace": "0.183.0",
"fuzzy-finder": "0.90.0",
"git-diff": "0.56.0",
"go-to-line": "0.30.0",
@@ -106,14 +106,14 @@
"spell-check": "0.61.0",
"status-bar": "0.79.0",
"styleguide": "0.44.0",
"symbols-view": "0.108.0",
"symbols-view": "0.109.0",
"tabs": "0.84.0",
"timecop": "0.33.0",
"tree-view": "0.189.0",
"update-package-dependencies": "0.10.0",
"welcome": "0.30.0",
"whitespace": "0.31.0",
"wrap-guide": "0.36.0",
"wrap-guide": "0.37.0",
"language-c": "0.48.0",
"language-clojure": "0.17.0",
"language-coffee-script": "0.42.0",

View File

@@ -23,7 +23,7 @@ module.exports.runSpecSuite = (specSuite, logFile, logErrors=true) ->
log(str)
onComplete: (runner) ->
fs.closeSync(logStream) if logStream?
if process.env.JANKY_SHA1
if process.env.JANKY_SHA1 or process.env.CI
grim = require 'grim'
if grim.getDeprecationsLength() > 0

View File

@@ -243,3 +243,61 @@ describe "TextEditorElement", ->
expect(element.hasAttribute('mini')).toBe true
element.getModel().setMini(false)
expect(element.hasAttribute('mini')).toBe false
describe "events", ->
element = null
beforeEach ->
element = new TextEditorElement
element.getModel().setText("lorem\nipsum\ndolor\nsit\namet")
element.setUpdatedSynchronously(true)
element.setHeight(20)
element.setWidth(20)
describe "::onDidChangeScrollTop(callback)", ->
it "triggers even when subscribing before attaching the element", ->
positions = []
subscription1 = element.onDidChangeScrollTop (p) -> positions.push(p)
jasmine.attachToDOM(element)
subscription2 = element.onDidChangeScrollTop (p) -> positions.push(p)
positions.length = 0
element.setScrollTop(10)
expect(positions).toEqual([10, 10])
element.remove()
jasmine.attachToDOM(element)
positions.length = 0
element.setScrollTop(20)
expect(positions).toEqual([20, 20])
subscription1.dispose()
positions.length = 0
element.setScrollTop(30)
expect(positions).toEqual([30])
describe "::onDidChangeScrollLeft(callback)", ->
it "triggers even when subscribing before attaching the element", ->
positions = []
subscription1 = element.onDidChangeScrollLeft (p) -> positions.push(p)
jasmine.attachToDOM(element)
subscription2 = element.onDidChangeScrollLeft (p) -> positions.push(p)
positions.length = 0
element.setScrollLeft(10)
expect(positions).toEqual([10, 10])
element.remove()
jasmine.attachToDOM(element)
positions.length = 0
element.setScrollLeft(20)
expect(positions).toEqual([20, 20])
subscription1.dispose()
positions.length = 0
element.setScrollLeft(30)
expect(positions).toEqual([30])

View File

@@ -2026,6 +2026,24 @@ describe "TextEditorPresenter", ->
}
describe ".height", ->
it "updates model's rows per page when it changes", ->
presenter = buildPresenter(explicitHeight: 50, lineHeightInPixels: 10, horizontalScrollbarHeight: 10)
presenter.getState() # trigger state update
expect(editor.getRowsPerPage()).toBe(4)
presenter.setExplicitHeight(100)
presenter.getState() # trigger state update
expect(editor.getRowsPerPage()).toBe(9)
presenter.setHorizontalScrollbarHeight(0)
presenter.getState() # trigger state update
expect(editor.getRowsPerPage()).toBe(10)
presenter.setLineHeight(5)
presenter.getState() # trigger state update
expect(editor.getRowsPerPage()).toBe(20)
it "tracks the computed content height if ::autoHeight is true so the editor auto-expands vertically", ->
presenter = buildPresenter(explicitHeight: null, autoHeight: true)
expect(presenter.getState().height).toBe editor.getScreenLineCount() * 10

View File

@@ -4365,8 +4365,8 @@ describe "TextEditor", ->
describe ".pageUp/Down()", ->
it "moves the cursor down one page length", ->
editor.setLineHeightInPixels(10)
editor.setHeight(50, true)
editor.setRowsPerPage(5)
expect(editor.getCursorBufferPosition().row).toBe 0
editor.pageDown()
@@ -4383,8 +4383,8 @@ describe "TextEditor", ->
describe ".selectPageUp/Down()", ->
it "selects one screen height of text up or down", ->
editor.setLineHeightInPixels(10)
editor.setHeight(50, true)
editor.setRowsPerPage(5)
expect(editor.getCursorBufferPosition().row).toBe 0
editor.selectPageDown()

View File

@@ -1,4 +1,4 @@
{Emitter} = require 'event-kit'
{Emitter, CompositeDisposable} = require 'event-kit'
Path = require 'path'
{defaults} = require 'underscore-plus'
TextBuffer = require 'text-buffer'
@@ -15,9 +15,11 @@ class TextEditorElement extends HTMLElement
tileSize: null
focusOnAttach: false
hasTiledRendering: true
logicalDisplayBuffer: true
createdCallback: ->
@emitter = new Emitter
@subscriptions = new CompositeDisposable
@initializeContent()
@addEventListener 'focus', @focused.bind(this)
@addEventListener 'blur', @blurred.bind(this)
@@ -56,6 +58,7 @@ class TextEditorElement extends HTMLElement
@buildModel() unless @getModel()?
atom.assert(@model.isAlive(), "Attaching a view for a destroyed editor")
@mountComponent() unless @component?
@listenForComponentEvents()
@component.checkForVisibilityChange()
if this is document.activeElement
@focused()
@@ -63,8 +66,16 @@ class TextEditorElement extends HTMLElement
detachedCallback: ->
@unmountComponent()
@subscriptions.dispose()
@subscriptions = new CompositeDisposable
@emitter.emit("did-detach")
listenForComponentEvents: ->
@subscriptions.add @component.onDidChangeScrollTop =>
@emitter.emit("did-change-scroll-top", arguments...)
@subscriptions.add @component.onDidChangeScrollLeft =>
@emitter.emit("did-change-scroll-left", arguments...)
initialize: (model) ->
@setModel(model)
this
@@ -219,10 +230,10 @@ class TextEditorElement extends HTMLElement
@emitter.on("did-detach", callback)
onDidChangeScrollTop: (callback) ->
@component.onDidChangeScrollTop(callback)
@emitter.on("did-change-scroll-top", callback)
onDidChangeScrollLeft: (callback) ->
@component.onDidChangeScrollLeft(callback)
@emitter.on("did-change-scroll-left", callback)
setScrollLeft: (scrollLeft) ->
@component.setScrollLeft(scrollLeft)
@@ -245,31 +256,31 @@ class TextEditorElement extends HTMLElement
@setScrollBottom(Infinity)
getScrollTop: ->
@component.getScrollTop()
@component?.getScrollTop() or 0
getScrollLeft: ->
@component.getScrollLeft()
@component?.getScrollLeft() or 0
getScrollRight: ->
@component.getScrollRight()
@component?.getScrollRight() or 0
getScrollBottom: ->
@component.getScrollBottom()
@component?.getScrollBottom() or 0
getScrollHeight: ->
@component.getScrollHeight()
@component?.getScrollHeight() or 0
getScrollWidth: ->
@component.getScrollWidth()
@component?.getScrollWidth() or 0
getVerticalScrollbarWidth: ->
@component.getVerticalScrollbarWidth()
@component?.getVerticalScrollbarWidth() or 0
getHorizontalScrollbarHeight: ->
@component.getHorizontalScrollbarHeight()
@component?.getHorizontalScrollbarHeight() or 0
getVisibleRowRange: ->
@component.getVisibleRowRange()
@component?.getVisibleRowRange() or [0, 0]
intersectsVisibleRowRange: (startRow, endRow) ->
[visibleStart, visibleEnd] = @getVisibleRowRange()

View File

@@ -72,6 +72,7 @@ class TextEditorPresenter
@updateScrollPosition()
@updateStartRow()
@updateEndRow()
@updateRowsPerPage()
@updateCommonGutterState()
@updateReflowState()
@@ -641,6 +642,12 @@ class TextEditorPresenter
endRow = startRow + visibleLinesCount
@endRow = Math.min(@model.getScreenLineCount(), endRow)
updateRowsPerPage: ->
rowsPerPage = Math.floor(@getClientHeight() / @lineHeight)
if rowsPerPage isnt @rowsPerPage
@rowsPerPage = rowsPerPage
@model.setRowsPerPage(@rowsPerPage)
updateScrollWidth: ->
return unless @contentWidth? and @clientWidth?

View File

@@ -427,14 +427,12 @@ class TextEditor extends Model
@displayBuffer.onDidChangeCharacterWidths(callback)
onDidChangeScrollTop: (callback) ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::onDidChangeScrollTop instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::onDidChangeScrollTop instead.")
atom.views.getView(this).onDidChangeScrollTop(callback)
onDidChangeScrollLeft: (callback) ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::onDidChangeScrollLeft instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::onDidChangeScrollLeft instead.")
atom.views.getView(this).onDidChangeScrollLeft(callback)
@@ -2856,28 +2854,24 @@ class TextEditor extends Model
@displayBuffer.scrollToScreenPosition(screenPosition, options)
scrollToTop: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::scrollToTop instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::scrollToTop instead.")
atom.views.getView(this).scrollToTop()
scrollToBottom: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::scrollToTop instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::scrollToTop instead.")
atom.views.getView(this).scrollToBottom()
scrollToScreenRange: (screenRange, options) -> @displayBuffer.scrollToScreenRange(screenRange, options)
getHorizontalScrollbarHeight: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::getHorizontalScrollbarHeight instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::getHorizontalScrollbarHeight instead.")
atom.views.getView(this).getHorizontalScrollbarHeight()
getVerticalScrollbarWidth: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::getVerticalScrollbarWidth instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::getVerticalScrollbarWidth instead.")
atom.views.getView(this).getVerticalScrollbarWidth()
@@ -2895,7 +2889,9 @@ class TextEditor extends Model
# Returns the number of rows per page
getRowsPerPage: ->
Math.max(1, Math.floor(@getHeight() / @getLineHeightInPixels()))
Math.max(@rowsPerPage ? 1, 1)
setRowsPerPage: (@rowsPerPage) ->
###
Section: Config
@@ -2943,23 +2939,19 @@ class TextEditor extends Model
@emitter.emit 'did-change-placeholder-text', @placeholderText
getFirstVisibleScreenRow: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::getFirstVisibleScreenRow instead.")
deprecate("This is now a view method. Call TextEditorElement::getFirstVisibleScreenRow instead.")
atom.views.getView(this).getVisibleRowRange()[0]
getLastVisibleScreenRow: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::getLastVisibleScreenRow instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::getLastVisibleScreenRow instead.")
atom.views.getView(this).getVisibleRowRange()[1]
pixelPositionForBufferPosition: (bufferPosition) ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.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")
atom.views.getView(this).pixelPositionForBufferPosition(bufferPosition)
pixelPositionForScreenPosition: (screenPosition) ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.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")
atom.views.getView(this).pixelPositionForScreenPosition(screenPosition)
getSelectionMarkerAttributes: ->
@@ -2990,13 +2982,11 @@ class TextEditor extends Model
if reentrant
@displayBuffer.setHeight(height)
else
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::setHeight instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::setHeight instead.")
atom.views.getView(this).setHeight(height)
getHeight: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::getHeight instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::getHeight instead.")
@displayBuffer.getHeight()
getClientHeight: -> @displayBuffer.getClientHeight()
@@ -3005,13 +2995,11 @@ class TextEditor extends Model
if reentrant
@displayBuffer.setWidth(width)
else
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::setWidth instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::setWidth instead.")
atom.views.getView(this).setWidth(width)
getWidth: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::getWidth instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::getWidth instead.")
@displayBuffer.getWidth()
getScrollRow: -> @scrollRow
@@ -3021,92 +3009,77 @@ class TextEditor extends Model
setScrollColumn: (@scrollColumn) ->
getScrollTop: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollTop instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollTop instead.")
atom.views.getView(this).getScrollTop()
setScrollTop: (scrollTop) ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::setScrollTop instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::setScrollTop instead.")
atom.views.getView(this).setScrollTop(scrollTop)
getScrollBottom: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollBottom instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollBottom instead.")
atom.views.getView(this).getScrollBottom()
setScrollBottom: (scrollBottom) ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::setScrollBottom instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::setScrollBottom instead.")
atom.views.getView(this).setScrollBottom(scrollBottom)
getScrollLeft: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollLeft instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollLeft instead.")
atom.views.getView(this).getScrollLeft()
setScrollLeft: (scrollLeft) ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::setScrollLeft instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::setScrollLeft instead.")
atom.views.getView(this).setScrollLeft(scrollLeft)
getScrollRight: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollRight instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollRight instead.")
atom.views.getView(this).getScrollRight()
setScrollRight: (scrollRight) ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::setScrollRight instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::setScrollRight instead.")
atom.views.getView(this).setScrollRight(scrollRight)
getScrollHeight: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollHeight instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollHeight instead.")
atom.views.getView(this).getScrollHeight()
getScrollWidth: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollWidth instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::getScrollWidth instead.")
atom.views.getView(this).getScrollWidth()
getVisibleRowRange: ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::getVisibleRowRange instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::getVisibleRowRange instead.")
atom.views.getView(this).getVisibleRowRange()
intersectsVisibleRowRange: (startRow, endRow) ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::intersectsVisibleRowRange instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::intersectsVisibleRowRange instead.")
atom.views.getView(this).intersectsVisibleRowRange(startRow, endRow)
selectionIntersectsVisibleRowRange: (selection) ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::selectionIntersectsVisibleRowRange instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::selectionIntersectsVisibleRowRange instead.")
atom.views.getView(this).selectionIntersectsVisibleRowRange(selection)
screenPositionForPixelPosition: (pixelPosition) ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::screenPositionForPixelPosition instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::screenPositionForPixelPosition instead.")
atom.views.getView(this).screenPositionForPixelPosition(pixelPosition)
pixelRectForScreenRange: (screenRange) ->
# TODO: put back once core & bundled packages are updated not to use this.
# Grim.deprecate("This is now a view method. Call TextEditorElement::pixelRectForScreenRange instead.")
Grim.deprecate("This is now a view method. Call TextEditorElement::pixelRectForScreenRange instead.")
atom.views.getView(this).pixelRectForScreenRange(screenRange)