Sha256: dc0fd5aafdfc301775f081c160bf00da1b0ed15fca23221ef31687c3820bea77

Contents?: true

Size: 897 Bytes

Versions: 5

Compression:

Stored size: 897 Bytes

Contents

# frozen_string_literal: true

module ThemeCheck
  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 => error
        @bridge || raise(error)

        message = error.message
        backtrace = error.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

5 entries across 5 versions & 1 rubygems

Version Path
theme-check-1.15.0 lib/theme_check/language_server/completion_engine.rb
theme-check-1.14.0 lib/theme_check/language_server/completion_engine.rb
theme-check-1.13.0 lib/theme_check/language_server/completion_engine.rb
theme-check-1.12.1 lib/theme_check/language_server/completion_engine.rb
theme-check-1.12.0 lib/theme_check/language_server/completion_engine.rb