Class: RubyLsp::Rails::Hover
- Inherits:
-
Object
- Object
- RubyLsp::Rails::Hover
- Includes:
- Requests::Support::Common
- Defined in:
- lib/ruby_lsp/ruby_lsp_rails/hover.rb
Overview

Augment [hover](microsoft.github.io/language-server-protocol/specification#textDocument_hover) with information about a model.
# Example
“‘ruby User.all # ^ hovering here will show information about the User model “`
Instance Method Summary collapse
-
#initialize(client, response_builder, node_context, global_state, dispatcher) ⇒ Hover
constructor
: (RunnerClient client, ResponseBuilders::Hover response_builder, NodeContext node_context, GlobalState global_state, Prism::Dispatcher dispatcher) -> void.
-
#on_constant_path_node_enter(node) ⇒ Object
: (Prism::ConstantPathNode node) -> void.
-
#on_constant_read_node_enter(node) ⇒ Object
: (Prism::ConstantReadNode node) -> void.
-
#on_string_node_enter(node) ⇒ Object
: (Prism::StringNode node) -> void.
-
#on_symbol_node_enter(node) ⇒ Object
: (Prism::SymbolNode node) -> void.
Constructor Details
#initialize(client, response_builder, node_context, global_state, dispatcher) ⇒ Hover
: (RunnerClient client, ResponseBuilders::Hover response_builder, NodeContext node_context, GlobalState global_state, Prism::Dispatcher dispatcher) -> void
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ruby_lsp/ruby_lsp_rails/hover.rb', line 21 def initialize(client, response_builder, node_context, global_state, dispatcher) @client = client @response_builder = response_builder @node_context = node_context @nesting = node_context.nesting #: Array[String] @graph = global_state.graph #: Rubydex::Graph dispatcher.register( self, :on_constant_path_node_enter, :on_constant_read_node_enter, :on_symbol_node_enter, :on_string_node_enter, ) end |
Instance Method Details
#on_constant_path_node_enter(node) ⇒ Object
: (Prism::ConstantPathNode node) -> void
38 39 40 41 42 43 44 45 46 |
# File 'lib/ruby_lsp/ruby_lsp_rails/hover.rb', line 38 def on_constant_path_node_enter(node) name = constant_name(node) return unless name declaration = @graph.resolve_constant(name, @nesting) return unless declaration generate_column_content(declaration.name) end |
#on_constant_read_node_enter(node) ⇒ Object
: (Prism::ConstantReadNode node) -> void
49 50 51 52 53 54 |
# File 'lib/ruby_lsp/ruby_lsp_rails/hover.rb', line 49 def on_constant_read_node_enter(node) declaration = @graph.resolve_constant(node.name.to_s, @nesting) return unless declaration generate_column_content(declaration.name) end |
#on_string_node_enter(node) ⇒ Object
: (Prism::StringNode node) -> void
62 63 64 |
# File 'lib/ruby_lsp/ruby_lsp_rails/hover.rb', line 62 def on_string_node_enter(node) handle_possible_i18n(node) end |
#on_symbol_node_enter(node) ⇒ Object
: (Prism::SymbolNode node) -> void
57 58 59 |
# File 'lib/ruby_lsp/ruby_lsp_rails/hover.rb', line 57 def on_symbol_node_enter(node) handle_possible_dsl(node) end |