Class: Yoda::Server::HoverProvider
- Inherits:
-
Object
- Object
- Yoda::Server::HoverProvider
- Defined in:
- lib/yoda/server/hover_provider.rb
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #create_hover(signature) ⇒ Object
- #create_hover_text(description) ⇒ String
-
#initialize(session) ⇒ HoverProvider
constructor
A new instance of HoverProvider.
- #request_hover(uri, position) ⇒ Object
Constructor Details
#initialize(session) ⇒ HoverProvider
Returns a new instance of HoverProvider.
7 8 9 |
# File 'lib/yoda/server/hover_provider.rb', line 7 def initialize(session) @session = session end |
Instance Attribute Details
#session ⇒ Object (readonly)
Returns the value of attribute session.
4 5 6 |
# File 'lib/yoda/server/hover_provider.rb', line 4 def session @session end |
Instance Method Details
#create_hover(signature) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/yoda/server/hover_provider.rb', line 24 def create_hover(signature) LSP::Interface::Hover.new( contents: signature.descriptions.map { |value| create_hover_text(value) }, range: LSP::Interface::Range.new(signature.node_range.to_language_server_protocol_range), ) end |
#create_hover_text(description) ⇒ String
33 34 35 |
# File 'lib/yoda/server/hover_provider.rb', line 33 def create_hover_text(description) description.to_markdown end |
#request_hover(uri, position) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/yoda/server/hover_provider.rb', line 13 def request_hover(uri, position) source = session.file_store.get(uri) location = Parsing::Location.of_language_server_protocol_position(line: position[:line], character: position[:character]) node_worker = Evaluation::CurrentNodeExplain.new(session.registry, source, location) current_node_signature = node_worker.current_node_signature create_hover(current_node_signature) if current_node_signature end |