Sha256: 4a66190074f2c5b9ca5c41efbcf5a3c6c342147511e444e1cbdeeb9a276e746a

Contents?: true

Size: 886 Bytes

Versions: 25

Compression:

Stored size: 886 Bytes

Contents

# frozen_string_literal: true

module PlatformosCheck
  module LanguageServer
    class CompletionEngine
      def initialize(storage, bridge = nil)
        @storage = storage
        @bridge = bridge
        @providers = CompletionProvider.all.map { |x| x.new(storage) }
      end

      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

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

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
platformos-check-0.4.14 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.13 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.12 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.11 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.10 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.9 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.8 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.7 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.6 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.5 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.4 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.3 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.2 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.1 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.4.0 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.3.3 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.3.1 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.3.0 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.2.2 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.2.1 lib/platformos_check/language_server/completion_engine.rb