Class: LanguageServer::Protocol::Interface::LocationLink

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/protocol/interface/location_link.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(origin_selection_range: nil, target_uri:, target_range:, target_selection_range:) ⇒ LocationLink

Returns a new instance of LocationLink.



5
6
7
8
9
10
11
12
13
14
# File 'lib/language_server/protocol/interface/location_link.rb', line 5

def initialize(origin_selection_range: nil, target_uri:, target_range:, target_selection_range:)
  @attributes = {}

  @attributes[:originSelectionRange] = origin_selection_range if origin_selection_range
  @attributes[:targetUri] = target_uri
  @attributes[:targetRange] = target_range
  @attributes[:targetSelectionRange] = target_selection_range

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



56
57
58
# File 'lib/language_server/protocol/interface/location_link.rb', line 56

def attributes
  @attributes
end

Instance Method Details

#origin_selection_rangeRange

Span of the origin of this link.

Used as the underlined span for mouse interaction. Defaults to the word range at the mouse position.

Returns:



23
24
25
# File 'lib/language_server/protocol/interface/location_link.rb', line 23

def origin_selection_range
  attributes.fetch(:originSelectionRange)
end

#target_rangeRange

The full target range of this link. If the target for example is a symbol then target range is the range enclosing this symbol not including leading/trailing whitespace but everything else like comments. This information is typically used to highlight the range in the editor.

Returns:



42
43
44
# File 'lib/language_server/protocol/interface/location_link.rb', line 42

def target_range
  attributes.fetch(:targetRange)
end

#target_selection_rangeRange

The range that should be selected and revealed when this link is being followed, e.g the name of a function. Must be contained by the ‘targetRange`. See also `DocumentSymbol#range`

Returns:



52
53
54
# File 'lib/language_server/protocol/interface/location_link.rb', line 52

def target_selection_range
  attributes.fetch(:targetSelectionRange)
end

#target_uristring

The target resource identifier of this link.

Returns:

  • (string)


31
32
33
# File 'lib/language_server/protocol/interface/location_link.rb', line 31

def target_uri
  attributes.fetch(:targetUri)
end

#to_hashObject



58
59
60
# File 'lib/language_server/protocol/interface/location_link.rb', line 58

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



62
63
64
# File 'lib/language_server/protocol/interface/location_link.rb', line 62

def to_json(*args)
  to_hash.to_json(*args)
end