Class: LanguageServer::Protocol::Interface::CodeLens
- Inherits:
-
Object
- Object
- LanguageServer::Protocol::Interface::CodeLens
- Defined in:
- lib/language_server/protocol/interface/code_lens.rb
Overview
A code lens represents a [command](#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
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#command ⇒ Command | nil
The command this code lens represents.
-
#data ⇒ LSPAny | nil
A data entry field that is preserved on a code lens item between a [CodeLensRequest](#CodeLensRequest) and a [CodeLensResolveRequest] (#CodeLensResolveRequest).
-
#initialize(range:, command: nil, data: nil) ⇒ CodeLens
constructor
A new instance of CodeLens.
-
#range ⇒ Range
The range in which this code lens is valid.
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
48 49 50 |
# File 'lib/language_server/protocol/interface/code_lens.rb', line 48 def attributes @attributes end |
Instance Method Details
#command ⇒ Command | nil
The command this code lens represents.
34 35 36 |
# File 'lib/language_server/protocol/interface/code_lens.rb', line 34 def command attributes.fetch(:command) end |
#data ⇒ LSPAny | nil
A data entry field that is preserved on a code lens item between a [CodeLensRequest](#CodeLensRequest) and a [CodeLensResolveRequest] (#CodeLensResolveRequest)
44 45 46 |
# File 'lib/language_server/protocol/interface/code_lens.rb', line 44 def data attributes.fetch(:data) end |
#range ⇒ Range
The range in which this code lens is valid. Should only span a single line.
26 27 28 |
# File 'lib/language_server/protocol/interface/code_lens.rb', line 26 def range attributes.fetch(:range) end |
#to_hash ⇒ Object
50 51 52 |
# File 'lib/language_server/protocol/interface/code_lens.rb', line 50 def to_hash attributes end |
#to_json(*args) ⇒ Object
54 55 56 |
# File 'lib/language_server/protocol/interface/code_lens.rb', line 54 def to_json(*args) to_hash.to_json(*args) end |