class Solargraph::Source::Cursor
word located there.
Information about a single Position in a Source, including the
def argument?
-
(Boolean)-
def argument? # @argument ||= !signature_position.nil? @argument ||= !recipient.nil? end
def assign?
-
(Boolean)-
def assign? [:lvasgn, :ivasgn, :gvasgn, :cvasgn].include? chain&.node&.type end
def chain
-
(Chain)-
def chain @chain ||= SourceChainer.chain(source, position) end
def comment?
-
(Boolean)-
def comment? @comment ||= source.comment_at?(position) end
def end_of_word
-
(String)-
def end_of_word @end_of_word ||= begin match = source.code[offset..-1].to_s.match(end_word_pattern) match ? match[0] : '' end end
def end_word_pattern
-
(Regexp)-
def end_word_pattern /^([a-z0-9_]|[^\u0000-\u007F])*[\?\!]?/i end
def filename
-
(String)-
def filename source.filename end
def initialize source, position
-
position(Position, Array(Integer, Integer)) -- -
source(Source) --
def initialize source, position @source = source @position = Position.normalize(position) end
def node
-
(AST::Node)-
def node @node ||= source.node_at(position.line, position.column) end
def node_position
-
(Position)-
def node_position @node_position ||= begin if start_of_word.empty? match = source.code[0, offset].match(/[\s]*(\.|:+)[\s]*$/) if match Position.from_offset(source.code, offset - match[0].length) else position end else position end end end
def offset
-
(Integer)-
def offset @offset ||= Position.to_offset(source.code, position) end
def range
-
(Range)-
def range @range ||= begin s = Position.from_offset(source.code, offset - start_of_word.length) e = Position.from_offset(source.code, offset + end_of_word.length) Solargraph::Range.new(s, e) end end
def recipient
-
(Cursor, nil)-
def recipient @recipient ||= begin node = recipient_node node ? Cursor.new(source, Range.from_node(node).ending) : nil end end
def recipient_node
-
(Parser::AST::Node, nil)-
def recipient_node @recipient_node ||= Solargraph::Parser::NodeMethods.find_recipient_node(self) end
def start_of_constant?
-
(Boolean)-
def start_of_constant? source.code[offset-2, 2] == '::' end
def start_of_word
-
(String)-
def start_of_word @start_of_word ||= begin match = source.code[0..offset-1].to_s.match(start_word_pattern) result = (match ? match[0] : '') # Including the preceding colon if the word appears to be a symbol result = ":#{result}" if source.code[0..offset-result.length-1].end_with?(':') and !source.code[0..offset-result.length-1].end_with?('::') result end end
def start_word_pattern
-
(Regexp)-
def start_word_pattern /(@{1,2}|\$)?([a-z0-9_]|[^\u0000-\u007F])*\z/i end
def string?
-
(Boolean)-
def string? @string ||= source.string_at?(position) end
def word
-
(String)-
def word @word ||= start_of_word + end_of_word end