Class: Mui::Lsp::Protocol::Location
- Inherits:
-
Object
- Object
- Mui::Lsp::Protocol::Location
- Defined in:
- lib/mui/lsp/protocol/location.rb
Overview
LSP Location (URI and range)
Instance Attribute Summary collapse
-
#range ⇒ Object
Returns the value of attribute range.
-
#uri ⇒ Object
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #file_path ⇒ Object
-
#initialize(uri:, range:) ⇒ Location
constructor
A new instance of Location.
- #to_h ⇒ Object
Constructor Details
#initialize(uri:, range:) ⇒ Location
12 13 14 15 |
# File 'lib/mui/lsp/protocol/location.rb', line 12 def initialize(uri:, range:) @uri = uri @range = range.is_a?(Range) ? range : Range.from_hash(range) end |
Instance Attribute Details
#range ⇒ Object
Returns the value of attribute range.
10 11 12 |
# File 'lib/mui/lsp/protocol/location.rb', line 10 def range @range end |
#uri ⇒ Object
Returns the value of attribute uri.
10 11 12 |
# File 'lib/mui/lsp/protocol/location.rb', line 10 def uri @uri end |
Class Method Details
.from_hash(hash) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/mui/lsp/protocol/location.rb', line 21 def self.from_hash(hash) new( uri: hash["uri"] || hash[:uri], range: hash["range"] || hash[:range] ) end |
Instance Method Details
#==(other) ⇒ Object
34 35 36 37 38 |
# File 'lib/mui/lsp/protocol/location.rb', line 34 def ==(other) return false unless other.is_a?(Location) @uri == other.uri && @range == other.range end |
#file_path ⇒ Object
28 29 30 31 32 |
# File 'lib/mui/lsp/protocol/location.rb', line 28 def file_path return nil unless @uri&.start_with?("file://") URI.decode_www_form_component(@uri.sub("file://", "")) end |
#to_h ⇒ Object
17 18 19 |
# File 'lib/mui/lsp/protocol/location.rb', line 17 def to_h { uri: @uri, range: @range.to_h } end |