Return ScopeDescriptor objects

This commit is contained in:
Ben Ogle
2014-10-20 17:49:02 -07:00
parent 4c4b82fe6c
commit ce2959c0b9
4 changed files with 11 additions and 9 deletions

View File

@@ -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: ->

View File

@@ -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)

View File

@@ -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) ->

View File

@@ -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)