Class: PlatformosCheck::LanguageServer::CompletionEngine
- Inherits:
-
Object
- Object
- PlatformosCheck::LanguageServer::CompletionEngine
- Defined in:
- lib/platformos_check/language_server/completion_engine.rb
Instance Method Summary collapse
- #completions(relative_path, line, col) ⇒ Object
- #context(relative_path, line, col) ⇒ Object
-
#initialize(storage, bridge = nil) ⇒ CompletionEngine
constructor
A new instance of CompletionEngine.
Constructor Details
#initialize(storage, bridge = nil) ⇒ CompletionEngine
Returns a new instance of CompletionEngine.
6 7 8 9 10 |
# File 'lib/platformos_check/language_server/completion_engine.rb', line 6 def initialize(storage, bridge = nil) @storage = storage @bridge = bridge @providers = CompletionProvider.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/completion_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) = e. backtrace = e.backtrace.join("\n") @bridge.log("[completion error] error: #{}\n#{backtrace}") end |
#context(relative_path, line, col) ⇒ Object
27 28 29 |
# File 'lib/platformos_check/language_server/completion_engine.rb', line 27 def context(relative_path, line, col) CompletionContext.new(@storage, relative_path, line, col) end |