mirror of
https://github.com/atom/atom.git
synced 2026-02-19 02:44:29 -05:00
Return ScopeDescriptor objects
This commit is contained in:
@@ -216,7 +216,7 @@ class Cursor extends Model
|
||||
|
||||
# Public: Retrieves the scope descriptor for the cursor's current position.
|
||||
#
|
||||
# Returns an {Array} of {String}s.
|
||||
# Returns a {ScopeDescriptor}
|
||||
getScopeDescriptor: ->
|
||||
@editor.scopeDescriptorForBufferPosition(@getBufferPosition())
|
||||
getScopes: ->
|
||||
|
||||
@@ -757,7 +757,7 @@ class DisplayBuffer extends Model
|
||||
#
|
||||
# bufferPosition - A {Point} in the {TextBuffer}
|
||||
#
|
||||
# Returns an {Array} of {String}s.
|
||||
# Returns a {ScopeDescriptor}.
|
||||
scopeDescriptorForBufferPosition: (bufferPosition) ->
|
||||
@tokenizedBuffer.scopeDescriptorForPosition(bufferPosition)
|
||||
|
||||
|
||||
@@ -2370,8 +2370,8 @@ class TextEditor extends Model
|
||||
Section: Managing Syntax Scopes
|
||||
###
|
||||
|
||||
# Essential: Returns the scope descriptor that includes the language. eg.
|
||||
# `['.source.ruby']`, or `['.source.coffee']`. You can use this with
|
||||
# Essential: Returns a {ScopeDescriptor} that includes this editor's language.
|
||||
# eg. `['.source.ruby']`, or `['.source.coffee']`. You can use this with
|
||||
# {Config::get} to get language specific config values.
|
||||
getRootScopeDescriptor: ->
|
||||
@displayBuffer.getRootScopeDescriptor()
|
||||
@@ -2385,7 +2385,7 @@ class TextEditor extends Model
|
||||
#
|
||||
# * `bufferPosition` A {Point} or {Array} of [row, column].
|
||||
#
|
||||
# Returns an {Array} of {String}s.
|
||||
# Returns a {ScopeDescriptor}.
|
||||
scopeDescriptorForBufferPosition: (bufferPosition) -> @displayBuffer.scopeDescriptorForBufferPosition(bufferPosition)
|
||||
scopesForBufferPosition: (bufferPosition) ->
|
||||
deprecate 'Use ::scopeDescriptorForBufferPosition instead'
|
||||
@@ -2397,9 +2397,11 @@ class TextEditor extends Model
|
||||
# For example, if you wanted to find the string surrounding the cursor, you
|
||||
# could call `editor.bufferRangeForScopeAtCursor(".string.quoted")`.
|
||||
#
|
||||
# * `scopeSelector` {String} selector. eg. `'.source.ruby'`
|
||||
#
|
||||
# Returns a {Range}.
|
||||
bufferRangeForScopeAtCursor: (selector) ->
|
||||
@displayBuffer.bufferRangeForScopeAtPosition(selector, @getCursorBufferPosition())
|
||||
bufferRangeForScopeAtCursor: (scopeSelector) ->
|
||||
@displayBuffer.bufferRangeForScopeAtPosition(scopeSelector, @getCursorBufferPosition())
|
||||
|
||||
# Extended: Determine if the given row is entirely a comment
|
||||
isBufferRowCommented: (bufferRow) ->
|
||||
|
||||
@@ -79,7 +79,7 @@ class TokenizedBuffer extends Model
|
||||
return if grammar is @grammar
|
||||
@unsubscribe(@grammar) if @grammar
|
||||
@grammar = grammar
|
||||
@rootScopeDescriptor = [@grammar.scopeName]
|
||||
@rootScopeDescriptor = new ScopeDescriptor(descriptor: [@grammar.scopeName])
|
||||
@currentGrammarScore = score ? grammar.getScore(@buffer.getPath(), @buffer.getText())
|
||||
@subscribe @grammar.onDidUpdate => @retokenizeLines()
|
||||
|
||||
@@ -303,7 +303,7 @@ class TokenizedBuffer extends Model
|
||||
0
|
||||
|
||||
scopeDescriptorForPosition: (position) ->
|
||||
@tokenForPosition(position).scopeDescriptor
|
||||
new ScopeDescriptor descriptor: @tokenForPosition(position).scopeDescriptor
|
||||
|
||||
tokenForPosition: (position) ->
|
||||
{row, column} = Point.fromObject(position)
|
||||
|
||||
Reference in New Issue
Block a user