Class: PlatformosCheck::LanguageServer::ObjectCompletionProvider

Inherits:
CompletionProvider show all
Defined in:
lib/platformos_check/language_server/completion_providers/object_completion_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 CompletionProvider

#storage

Instance Method Summary collapse

Methods inherited from CompletionProvider

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::CompletionProvider

Instance Method Details

#completions(context) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/platformos_check/language_server/completion_providers/object_completion_provider.rb', line 6

def completions(context)
  content = context.content

  return [] if content.nil?
  return [] unless (variable_lookup = VariableLookupFinder.lookup(context))
  return [] unless variable_lookup.lookups.empty?
  return [] if content[context.cursor - 1] == "."

  current_file_type = file_type(find_file(context))

  PlatformosLiquid::SourceIndex
    .objects
    .select(&:global?)
    .select { |object| object.app_file_type ? object.app_file_type == current_file_type : true }
    .select { |object| object.name.start_with?(partial(variable_lookup)) }
    .map { |object| object_to_completion(object) }
end

#partial(variable_lookup) ⇒ Object



24
25
26
# File 'lib/platformos_check/language_server/completion_providers/object_completion_provider.rb', line 24

def partial(variable_lookup)
  variable_lookup.name || ''
end