Class: Yoda::Server::DefinitionProvider
- Inherits:
-
Object
- Object
- Yoda::Server::DefinitionProvider
- Defined in:
- lib/yoda/server/definition_provider.rb
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #create_location(path, line, column) ⇒ Object
-
#initialize(session) ⇒ DefinitionProvider
constructor
A new instance of DefinitionProvider.
- #provide(uri, position, include_declaration = false) ⇒ Object
Constructor Details
#initialize(session) ⇒ DefinitionProvider
Returns a new instance of DefinitionProvider.
8 9 10 |
# File 'lib/yoda/server/definition_provider.rb', line 8 def initialize(session) @session = session end |
Instance Attribute Details
#session ⇒ Object (readonly)
Returns the value of attribute session.
5 6 7 |
# File 'lib/yoda/server/definition_provider.rb', line 5 def session @session end |
Instance Method Details
#create_location(path, line, column) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/yoda/server/definition_provider.rb', line 27 def create_location(path, line, column) location = Parsing::Location.new(row: line - 1, column: column) LSP::Interface::Location.new( uri: session.uri_of_path(path), range: LSP::Interface::Range.new(Parsing::Range.new(location, location).to_language_server_protocol_range), ) end |
#provide(uri, position, include_declaration = false) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/yoda/server/definition_provider.rb', line 15 def provide(uri, position, include_declaration = false) 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) references = node_worker.defined_files references.map { |(path, line, column)| create_location(path, line, column) } end |