Sha256: fb1334f7b25bdf6a7505043a3e378d68b3b50fb6f007889c5c592a102c0a24f3

Contents?: true

Size: 1001 Bytes

Versions: 2

Compression:

Stored size: 1001 Bytes

Contents

# frozen_string_literal: true

module PlatformosCheck
  module LanguageServer
    class ThemeRenderDocumentLinkProvider < DocumentLinkProvider
      @partial_regexp = PARTIAL_THEME_RENDER
      @app_file_type = :partials
      @default_dir = 'views/partials'
      @default_extension = '.liquid'

      def file_link(partial, platformos_app)
        relative_path = nil
        path_prefixes(platformos_app).each do |prefix|
          partial_with_prefix = (prefix.split(File::SEPARATOR) + [partial]).join(File::SEPARATOR)
          relative_path = platformos_app.send(app_file_type).detect { |f| f.name == partial_with_prefix }&.relative_path
          break if relative_path
        end

        relative_path ||= default_relative_path(partial)

        file_uri(@storage.path(relative_path))
      end

      private

      def path_prefixes(platformos_app)
        platformos_app.app_config.content['theme_search_paths'] || ['']
      rescue StandardError
        ['']
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
platformos-check-0.3.1 lib/platformos_check/language_server/document_link_providers/theme_render_document_link_provider.rb
platformos-check-0.3.0 lib/platformos_check/language_server/document_link_providers/theme_render_document_link_provider.rb