class Solargraph::Location
A pointer to a section of source text identified by its filename and Range.
Attributes
@return [String]
@return [Solargraph::Range]
Public Class Methods
Source
# File lib/solargraph/location.rb, line 65 def self.from_node(node) return nil if node.nil? || node.loc.nil? range = Range.from_node(node) self.new(node.loc.expression.source_buffer.name, range) end
@param node [Parser::AST::Node, nil] @return [Location, nil]
Source
# File lib/solargraph/location.rb, line 18 def initialize filename, range @filename = filename @range = range end
@param filename [String] @param range [Solargraph::Range]
Public Instance Methods
Source
# File lib/solargraph/location.rb, line 29 def <=>(other) return nil unless other.is_a?(Location) if filename == other.filename range <=> other.range else filename <=> other.filename end end
@param other [self]
Source
# File lib/solargraph/location.rb, line 72 def == other return false unless other.is_a?(Location) # @sg-ignore https://github.com/castwide/solargraph/pull/1114 filename == other.filename and range == other.range end
@param other [BasicObject]
Source
# File lib/solargraph/location.rb, line 43 def contain? location range.contain?(location.range.start) && range.contain?(location.range.ending) && filename == location.filename end
@param location [self]
Source
# File lib/solargraph/location.rb, line 47 def inspect "<#{self.class.name}: filename=#{filename}, range=#{range.inspect}>" end
Source
# File lib/solargraph/location.rb, line 56 def to_hash { filename: filename, range: range.to_hash } end
@return [Hash]
Protected Instance Methods
Source
# File lib/solargraph/location.rb, line 24 def equality_fields [filename, range] end
@sg-ignore Fix “Not enough arguments to Module#protected”