Class: LanguageServer::Protocol::Interface::FoldingRange

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

Overview

Represents a folding range. To be valid, start and end line must be bigger than zero and smaller than the number of lines in the document. Clients are free to ignore invalid ranges.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_line:, start_character: nil, end_line:, end_character: nil, kind: nil, collapsed_text: nil) ⇒ FoldingRange



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/language_server/protocol/interface/folding_range.rb', line 9

def initialize(start_line:, start_character: nil, end_line:, end_character: nil, kind: nil, collapsed_text: nil)
  @attributes = {}

  @attributes[:startLine] = start_line
  @attributes[:startCharacter] = start_character if start_character
  @attributes[:endLine] = end_line
  @attributes[:endCharacter] = end_character if end_character
  @attributes[:kind] = kind if kind
  @attributes[:collapsedText] = collapsed_text if collapsed_text

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

Instance Method Details

#collapsed_textstring | nil

The text that the client should show when the specified range is collapsed. If not defined or not supported by the client, a default will be chosen by the client.

Since:

  • 3.17.0



74
75
76
# File 'lib/language_server/protocol/interface/folding_range.rb', line 74

def collapsed_text
  attributes.fetch(:collapsedText)
end

#end_characteruinteger | nil

The zero-based character offset before the folded range ends. If not defined, defaults to the length of the end line.



52
53
54
# File 'lib/language_server/protocol/interface/folding_range.rb', line 52

def end_character
  attributes.fetch(:endCharacter)
end

#end_lineuinteger

The zero-based end line of the range to fold. The folded area ends with the line’s last character. To be valid, the end must be zero or larger and smaller than the number of lines in the document.



44
45
46
# File 'lib/language_server/protocol/interface/folding_range.rb', line 44

def end_line
  attributes.fetch(:endLine)
end

#kindFoldingRangeKind | nil

Describes the kind of the folding range such as ‘comment’ or ‘region’. The kind is used to categorize folding ranges and used by commands like ‘Fold all comments’. See [FoldingRangeKind](#FoldingRangeKind) for an enumeration of standardized kinds.



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

def kind
  attributes.fetch(:kind)
end

#start_characteruinteger | nil

The zero-based character offset from where the folded range starts. If not defined, defaults to the length of the start line.



35
36
37
# File 'lib/language_server/protocol/interface/folding_range.rb', line 35

def start_character
  attributes.fetch(:startCharacter)
end

#start_lineuinteger

The zero-based start line of the range to fold. The folded area starts after the line’s last character. To be valid, the end must be zero or larger and smaller than the number of lines in the document.



27
28
29
# File 'lib/language_server/protocol/interface/folding_range.rb', line 27

def start_line
  attributes.fetch(:startLine)
end

#to_hashObject



80
81
82
# File 'lib/language_server/protocol/interface/folding_range.rb', line 80

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



84
85
86
# File 'lib/language_server/protocol/interface/folding_range.rb', line 84

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