Class: SyntaxTree::LanguageServer::InlayHints::Hint

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/language_server.rb

Overview

This represents a hint that is going to be displayed in the editor.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line:, character:, label:) ⇒ Hint

Returns a new instance of Hint.



23
24
25
26
27
# File 'lib/syntax_tree/language_server.rb', line 23

def initialize(line:, character:, label:)
  @line = line
  @character = character
  @label = label
end

Instance Attribute Details

#characterObject (readonly)

Returns the value of attribute character.



21
22
23
# File 'lib/syntax_tree/language_server.rb', line 21

def character
  @character
end

#labelObject (readonly)

Returns the value of attribute label.



21
22
23
# File 'lib/syntax_tree/language_server.rb', line 21

def label
  @label
end

#lineObject (readonly)

Returns the value of attribute line.



21
22
23
# File 'lib/syntax_tree/language_server.rb', line 21

def line
  @line
end

Instance Method Details

#to_json(*opts) ⇒ Object

This is the shape that the LSP expects.



30
31
32
33
34
35
36
37
38
# File 'lib/syntax_tree/language_server.rb', line 30

def to_json(*opts)
  {
    position: {
      line: line,
      character: character
    },
    label: label
  }.to_json(*opts)
end