Class: LanguageServer::Protocol::Interface::DocumentSymbol

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

Overview

Represents programming constructs like variables, classes, interfaces etc. that appear in a document. Document symbols can be hierarchical and they have two ranges: one that encloses its definition and one that points to its most interesting range, e.g. the range of an identifier.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, detail: nil, kind:, deprecated: nil, range:, selection_range:, children: nil) ⇒ DocumentSymbol

Returns a new instance of DocumentSymbol.



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

def initialize(name:, detail: nil, kind:, deprecated: nil, range:, selection_range:, children: nil)
  @attributes = {}

  @attributes[:name] = name
  @attributes[:detail] = detail if detail
  @attributes[:kind] = kind
  @attributes[:deprecated] = deprecated if deprecated
  @attributes[:range] = range
  @attributes[:selectionRange] = selection_range
  @attributes[:children] = children if children

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

Instance Method Details

#childrenDocumentSymbol[]

Children of this symbol, e.g. properties of a class.

Returns:



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

def children
  attributes.fetch(:children)
end

#deprecatedboolean

Indicates if this symbol is deprecated.

Returns:

  • (boolean)


53
54
55
# File 'lib/language_server/protocol/interface/document_symbol.rb', line 53

def deprecated
  attributes.fetch(:deprecated)
end

#detailstring

More detail for this symbol, e.g the signature of a function.

Returns:

  • (string)


37
38
39
# File 'lib/language_server/protocol/interface/document_symbol.rb', line 37

def detail
  attributes.fetch(:detail)
end

#kindany

The kind of this symbol.

Returns:

  • (any)


45
46
47
# File 'lib/language_server/protocol/interface/document_symbol.rb', line 45

def kind
  attributes.fetch(:kind)
end

#namestring

The name of this symbol. Will be displayed in the user interface and therefore must not be an empty string or a string only consisting of white spaces.

Returns:

  • (string)


29
30
31
# File 'lib/language_server/protocol/interface/document_symbol.rb', line 29

def name
  attributes.fetch(:name)
end

#rangeRange

The range enclosing this symbol not including leading/trailing whitespace but everything else like comments. This information is typically used to determine if the clients cursor is inside the symbol to reveal in the symbol in the UI.

Returns:



63
64
65
# File 'lib/language_server/protocol/interface/document_symbol.rb', line 63

def range
  attributes.fetch(:range)
end

#selection_rangeRange

The range that should be selected and revealed when this symbol is being picked, e.g the name of a function. Must be contained by the ‘range`.

Returns:



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

def selection_range
  attributes.fetch(:selectionRange)
end

#to_hashObject



86
87
88
# File 'lib/language_server/protocol/interface/document_symbol.rb', line 86

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



90
91
92
# File 'lib/language_server/protocol/interface/document_symbol.rb', line 90

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