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.2.0 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.1.0 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.0.3 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.0.2 lib/platformos_check/language_server/completion_engine.rb
platformos-check-0.0.1 lib/platformos_check/language_server/completion_engine.rb