Class: LanguageServer::Protocol::Interface::CodeLens

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

Overview

A code lens represents a command that should be shown along with source text, like the number of references, a way to run tests, etc.

A code lens is unresolved when no command is associated to it. For performance reasons the creation of a code lens and resolving should be done in two stages.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(range:, command: nil, data: nil) ⇒ CodeLens

Returns a new instance of CodeLens.



13
14
15
16
17
18
19
20
21
# File 'lib/language_server/protocol/interface/code_lens.rb', line 13

def initialize(range:, command: nil, data: nil)
  @attributes = {}

  @attributes[:range] = range
  @attributes[:command] = command if command
  @attributes[:data] = data if data

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



49
50
51
# File 'lib/language_server/protocol/interface/code_lens.rb', line 49

def attributes
  @attributes
end

Instance Method Details

#commandCommand

The command this code lens represents.

Returns:



36
37
38
# File 'lib/language_server/protocol/interface/code_lens.rb', line 36

def command
  attributes.fetch(:command)
end

#dataLSPAny

A data entry field that is preserved on a code lens item between a code lens and a code lens resolve request.

Returns:

  • (LSPAny)


45
46
47
# File 'lib/language_server/protocol/interface/code_lens.rb', line 45

def data
  attributes.fetch(:data)
end

#rangeRange

The range in which this code lens is valid. Should only span a single line.

Returns:



28
29
30
# File 'lib/language_server/protocol/interface/code_lens.rb', line 28

def range
  attributes.fetch(:range)
end

#to_hashObject



51
52
53
# File 'lib/language_server/protocol/interface/code_lens.rb', line 51

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



55
56
57
# File 'lib/language_server/protocol/interface/code_lens.rb', line 55

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