Class: PlatformosCheck::LanguageServer::ThemeRenderDocumentLinkProvider

Inherits:
DocumentLinkProvider show all
Defined in:
lib/platformos_check/language_server/document_link_providers/theme_render_document_link_provider.rb

Constant Summary

Constants included from RegexHelpers

RegexHelpers::HTML_LIQUID_PLACEHOLDER, RegexHelpers::LIQUID_TAG, RegexHelpers::LIQUID_TAG_OR_VARIABLE, RegexHelpers::LIQUID_VARIABLE, RegexHelpers::START_OR_END_QUOTE

Instance Method Summary collapse

Methods inherited from DocumentLinkProvider

all, #app_file_type, #default_dir, #default_extension, #default_relative_path, #document_links, #end_coordinates, inherited, #initialize, #partial_regexp, #start_coordinates, #translation_components_for_match, #translation_file_link, #yaml

Methods included from URIHelper

#file_path, #file_uri

Methods included from PositionHelper

#bounded, #from_index_to_row_column, #from_row_column_to_index

Methods included from RegexHelpers

#matches

Constructor Details

This class inherits a constructor from PlatformosCheck::LanguageServer::DocumentLinkProvider

Instance Method Details



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/platformos_check/language_server/document_link_providers/theme_render_document_link_provider.rb', line 11

def file_link(match, platformos_app)
  partial = match[:partial]
  relative_path = nil
  path_prefixes(platformos_app).each do |prefix|
    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