Class: ThemeCheck::LanguageServer::ObjectAttributeCompletionProvider
- Inherits:
-
CompletionProvider
- Object
- CompletionProvider
- ThemeCheck::LanguageServer::ObjectAttributeCompletionProvider
- Defined in:
- lib/theme_check/language_server/completion_providers/object_attribute_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
Instance Attribute Summary
Attributes inherited from CompletionProvider
Instance Method Summary collapse
Methods inherited from CompletionProvider
all, #doc_hash, #format_hash, inherited, #initialize
Methods included from RegexHelpers
Methods included from CompletionHelper
#cursor_on_first_word?, #cursor_on_start_content?, #first_word
Constructor Details
This class inherits a constructor from ThemeCheck::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 23 24 25 26 27 |
# File 'lib/theme_check/language_server/completion_providers/object_attribute_completion_provider.rb', line 6 def completions(context) content = context.content cursor = context.cursor return [] if content.nil? return [] unless (variable_lookup = VariableLookupFinder.lookup(context)) return [] if content[cursor - 1] == "." && content[cursor - 2] == "." # Navigate through lookups until the last valid [object, property] level object, property = VariableLookupTraverser.lookup_object_and_property(variable_lookup) # If the last lookup level is incomplete/invalid, use the partial term # to filter object properties. partial = partial_property_name(property, variable_lookup) return [] unless object object .properties .select { |prop| partial.nil? || prop.name.start_with?(partial) } .map { |prop| property_to_completion(prop) } end |