Class: LanguageServer::Protocol::Interface::InlineValueEvaluatableExpression

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

Overview

Provide an inline value through an expression evaluation.

If only a range is specified, the expression will be extracted from the underlying document.

An optional expression can be used to override the extracted expression.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(range:, expression: nil) ⇒ InlineValueEvaluatableExpression

Returns a new instance of InlineValueEvaluatableExpression.



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

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

  @attributes[:range] = range
  @attributes[:expression] = expression if expression

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

Instance Method Details

#expressionstring

If specified the expression overrides the extracted expression.

Returns:

  • (string)


36
37
38
# File 'lib/language_server/protocol/interface/inline_value_evaluatable_expression.rb', line 36

def expression
  attributes.fetch(:expression)
end

#rangeRange

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

Returns:



28
29
30
# File 'lib/language_server/protocol/interface/inline_value_evaluatable_expression.rb', line 28

def range
  attributes.fetch(:range)
end

#to_hashObject



42
43
44
# File 'lib/language_server/protocol/interface/inline_value_evaluatable_expression.rb', line 42

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



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

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