Sha256: cd41ebef612430222faa5bb61575488740b1ef402fdbfffe59737908ea74f6c4

Contents?: true

Size: 1.06 KB

Versions: 25

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module PlatformosCheck
  module LanguageServer
    class CompletionProvider
      include CompletionHelper
      include RegexHelpers

      attr_reader :storage

      CurrentToken = Struct.new(:content, :cursor, :absolute_cursor, :buffer)

      class << self
        def all
          @all ||= []
        end

        def inherited(subclass)
          all << subclass
        end
      end

      def initialize(storage = InMemoryStorage.new)
        @storage = storage
      end

      def completions(relative_path, line, col)
        raise NotImplementedError
      end

      def doc_hash(content)
        return {} if content.nil? || content.empty?

        {
          documentation: {
            kind: MarkupKinds::MARKDOWN,
            value: content
          }
        }
      end

      def format_hash(entry)
        return {} unless entry
        return { sortText: entry.name } unless entry.deprecated?

        {
          tags: [CompletionItemTag::DEPRECATED],
          sortText: "~#{entry.name}"
        }
      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_provider.rb
platformos-check-0.4.13 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.4.12 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.4.11 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.4.10 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.4.9 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.4.8 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.4.7 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.4.6 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.4.5 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.4.4 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.4.3 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.4.2 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.4.1 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.4.0 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.3.3 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.3.1 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.3.0 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.2.2 lib/platformos_check/language_server/completion_provider.rb
platformos-check-0.2.1 lib/platformos_check/language_server/completion_provider.rb