Class: PlatformosCheck::LanguageServer::HoverEngine

Inherits:
Object
  • Object
show all
Defined in:
lib/platformos_check/language_server/hover_engine.rb

Instance Method Summary collapse

Constructor Details

#initialize(storage, bridge = nil) ⇒ HoverEngine

Returns a new instance of HoverEngine.



6
7
8
9
10
# File 'lib/platformos_check/language_server/hover_engine.rb', line 6

def initialize(storage, bridge = nil)
  @storage = storage
  @bridge = bridge
  @providers = HoverProvider.all.map { |x| x.new(storage) }
end

Instance Method Details

#completions(relative_path, line, col) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/platformos_check/language_server/hover_engine.rb', line 12

def completions(relative_path, line, col)
  context = context(relative_path, line, col)

  @providers
    .flat_map { |provider| provider.completions(context) }
    .uniq { |completion_item| completion_item[:label] }
rescue StandardError => e
  @bridge || raise(e)

  message = e.message
  backtrace = e.backtrace.join("\n")

  @bridge.log("[completion error] error: #{message}\n#{backtrace}")
end

#context(relative_path, line, col) ⇒ Object



27
28
29
# File 'lib/platformos_check/language_server/hover_engine.rb', line 27

def context(relative_path, line, col)
  CompletionContext.new(@storage, relative_path, line, col)
end