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

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

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: nil, variable_name: nil, case_sensitive_lookup: nil, expression: nil) ⇒ InlineValue

Returns a new instance of InlineValue.

Parameters:

  • range: (Object)
  • text: (String) (defaults to: nil)
  • variable_name: (String) (defaults to: nil)
  • case_sensitive_lookup: (Boolean) (defaults to: nil)
  • expression: (String) (defaults to: nil)

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: nil, variable_name: nil, case_sensitive_lookup: nil, expression: nil)
  @attributes = {}

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

  @attributes.freeze
end

Instance Attribute Details

#attributesHash[Symbol, untyped] (readonly)

Returns:

  • (Hash[Symbol, untyped])

Since:

  • 3.17.0



76
77
78
# File 'lib/language_server/protocol/interface/inline_value.rb', line 76

def attributes
  @attributes
end

Instance Method Details

#case_sensitive_lookupboolean

How to perform the lookup.

Returns:

  • (boolean)

Since:

  • 3.17.0



64
65
66
# File 'lib/language_server/protocol/interface/inline_value.rb', line 64

def case_sensitive_lookup
  attributes.fetch(:caseSensitiveLookup)
end

#expressionstring

If specified the expression overrides the extracted expression.

Returns:

  • (string)

Since:

  • 3.17.0



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

def expression
  attributes.fetch(:expression)
end

#rangeRange

The document range for which the inline value applies.

--- OR ---

The document range for which the inline value applies. The range is used to extract the variable name from the underlying document.

--- OR ---

The document range for which the inline value applies. The range is used to extract the evaluatable expression from the underlying document.

Returns:

Since:

  • 3.17.0



40
41
42
# File 'lib/language_server/protocol/interface/inline_value.rb', line 40

def range
  attributes.fetch(:range)
end

#textstring

The text of the inline value.

Returns:

  • (string)

Since:

  • 3.17.0



48
49
50
# File 'lib/language_server/protocol/interface/inline_value.rb', line 48

def text
  attributes.fetch(:text)
end

#to_hashHash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])

Since:

  • 3.17.0



78
79
80
# File 'lib/language_server/protocol/interface/inline_value.rb', line 78

def to_hash
  attributes
end

#to_json(*args) ⇒ String

Parameters:

  • (Object)

Returns:

  • (String)

Since:

  • 3.17.0



82
83
84
# File 'lib/language_server/protocol/interface/inline_value.rb', line 82

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

#variable_namestring

If specified the name of the variable to look up.

Returns:

  • (string)

Since:

  • 3.17.0



56
57
58
# File 'lib/language_server/protocol/interface/inline_value.rb', line 56

def variable_name
  attributes.fetch(:variableName)
end