Class: LanguageServer::Protocol::Interface::InlineValue

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

Overview

Inline value information can be provided by different means:

  • directly as a text value (class InlineValueText).

  • as a name to use for a variable lookup (class InlineValueVariableLookup)

  • as an evaluatable expression (class InlineValueEvaluatableExpression)

The InlineValue types combines all inline value types into one type.

Since:

  • 3.17.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(range:, text:, variable_name: nil, case_sensitive_lookup:, expression: nil) ⇒ InlineValue

Returns a new instance of InlineValue.

Since:

  • 3.17.0



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/language_server/protocol/interface/inline_value.rb', line 14

def initialize(range:, text:, variable_name: nil, case_sensitive_lookup:, expression: nil)
  @attributes = {}

  @attributes[:range] = range
  @attributes[:text] = text
  @attributes[:variableName] = variable_name if variable_name
  @attributes[:caseSensitiveLookup] = case_sensitive_lookup
  @attributes[:expression] = expression if expression

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Since:

  • 3.17.0



66
67
68
# File 'lib/language_server/protocol/interface/inline_value.rb', line 66

def attributes
  @attributes
end

Instance Method Details

#case_sensitive_lookupboolean

How to perform the lookup.

Returns:

  • (boolean)

Since:

  • 3.17.0



54
55
56
# File 'lib/language_server/protocol/interface/inline_value.rb', line 54

def case_sensitive_lookup
  attributes.fetch(:caseSensitiveLookup)
end

#expressionstring | nil

If specified the expression overrides the extracted expression.

Returns:

  • (string | nil)

Since:

  • 3.17.0



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

def expression
  attributes.fetch(:expression)
end

#rangeRange

The document range for which the inline value applies.

Returns:

Since:

  • 3.17.0



30
31
32
# File 'lib/language_server/protocol/interface/inline_value.rb', line 30

def range
  attributes.fetch(:range)
end

#textstring

The text of the inline value.

Returns:

  • (string)

Since:

  • 3.17.0



38
39
40
# File 'lib/language_server/protocol/interface/inline_value.rb', line 38

def text
  attributes.fetch(:text)
end

#to_hashObject

Since:

  • 3.17.0



68
69
70
# File 'lib/language_server/protocol/interface/inline_value.rb', line 68

def to_hash
  attributes
end

#to_json(*args) ⇒ Object

Since:

  • 3.17.0



72
73
74
# File 'lib/language_server/protocol/interface/inline_value.rb', line 72

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

#variable_namestring | nil

If specified the name of the variable to look up.

Returns:

  • (string | nil)

Since:

  • 3.17.0



46
47
48
# File 'lib/language_server/protocol/interface/inline_value.rb', line 46

def variable_name
  attributes.fetch(:variableName)
end