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.



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

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.



47
48
49
# File 'lib/language_server/protocol/interface/code_lens.rb', line 47

def attributes
  @attributes
end

Instance Method Details

#commandCommand

The command this code lens represents.

Returns:



34
35
36
# File 'lib/language_server/protocol/interface/code_lens.rb', line 34

def command
  attributes.fetch(:command)
end

#dataany

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

Returns:

  • (any)


43
44
45
# File 'lib/language_server/protocol/interface/code_lens.rb', line 43

def data
  attributes.fetch(:data)
end

#rangeRange

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

Returns:



26
27
28
# File 'lib/language_server/protocol/interface/code_lens.rb', line 26

def range
  attributes.fetch(:range)
end

#to_hashObject



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

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



53
54
55
# File 'lib/language_server/protocol/interface/code_lens.rb', line 53

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