Class: RubyLsp::Requests::DocumentSymbol
- Extended by:
- T::Generic, T::Sig
- Defined in:
- lib/ruby_lsp/requests/document_symbol.rb
Overview

The [document symbol](microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol) request informs the editor of all the important symbols, such as classes, variables, and methods, defined in a file. With this information, the editor can populate breadcrumbs, file outline and allow for fuzzy symbol searches.
In VS Code, fuzzy symbol search can be accessed by opening the command palette and inserting an ‘@` symbol.
# Example
“‘ruby class Person # –> document symbol: class
attr_reader :age # --> document symbol: field
def initialize
@age = 0 # --> document symbol: variable
end
def age # --> document symbol: method
end
end “‘
Constant Summary collapse
- ResponseType =
type_member { { fixed: T::Array[Interface::DocumentSymbol] } }
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dispatcher) ⇒ DocumentSymbol
constructor
A new instance of DocumentSymbol.
- #perform ⇒ Object
Constructor Details
#initialize(dispatcher) ⇒ DocumentSymbol
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ruby_lsp/requests/document_symbol.rb', line 52 def initialize(dispatcher) super() @listeners = T.let( [Listeners::DocumentSymbol.new(dispatcher)], T::Array[Listener[ResponseType]], ) Addon.addons.each do |addon| addon_listener = addon.create_document_symbol_listener(dispatcher) @listeners << addon_listener if addon_listener end end |
Class Method Details
.provider ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/ruby_lsp/requests/document_symbol.rb', line 39 def provider Interface::DocumentSymbolClientCapabilities.new( hierarchical_document_symbol_support: true, symbol_kind: { value_set: (Constant::SymbolKind::FILE..Constant::SymbolKind::TYPE_PARAMETER).to_a, }, ) end |
Instance Method Details
#perform ⇒ Object
66 67 68 |
# File 'lib/ruby_lsp/requests/document_symbol.rb', line 66 def perform @listeners.flat_map(&:response).compact end |