Class: PlatformosCheck::LanguageServer::TagHoverProvider

Inherits:
HoverProvider
  • Object
show all
Defined in:
lib/platformos_check/language_server/hover_providers/tag_hover_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

Constants included from CompletionHelper

CompletionHelper::WORD

Instance Attribute Summary

Attributes inherited from HoverProvider

#storage

Instance Method Summary collapse

Methods inherited from HoverProvider

all, #doc_hash, #format_hash, inherited, #initialize

Methods included from RegexHelpers

#matches

Methods included from CompletionHelper

#cursor_on_first_word?, #cursor_on_start_content?, #first_word

Constructor Details

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

Instance Method Details

#can_complete?(context) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/platformos_check/language_server/hover_providers/tag_hover_provider.rb', line 17

def can_complete?(context)
  context.content.start_with?(Liquid::TagStart) && (cursor_on_first_word?(context.buffer.lines[context.line], context.col) || cursor_on_start_content?(context.buffer.lines[context.line], context.col, Liquid::TagStart))
end

#completions(context) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/platformos_check/language_server/hover_providers/tag_hover_provider.rb', line 6

def completions(context)
  content = context.content

  return [] if content.nil?
  return [] unless can_complete?(context)

  partial = first_word(context.buffer.lines[context.line]) || ''
  PlatformosLiquid::SourceIndex.tags.select { |tag| tag.name.start_with?(partial) }
                               .map { |tag| tag_to_completion(tag) }.first
end