Class: ThemeCheck::LanguageServer::TagCompletionProvider
- Inherits:
-
CompletionProvider
- Object
- CompletionProvider
- ThemeCheck::LanguageServer::TagCompletionProvider
- Defined in:
- lib/theme_check/language_server/completion_providers/tag_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 Method Summary collapse
Methods inherited from CompletionProvider
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
#can_complete?(content, cursor) ⇒ Boolean
16 17 18 19 20 21 |
# File 'lib/theme_check/language_server/completion_providers/tag_completion_provider.rb', line 16 def can_complete?(content, cursor) content.start_with?(Liquid::TagStart) && ( cursor_on_first_word?(content, cursor) || cursor_on_start_content?(content, cursor, Liquid::TagStart) ) end |
#completions(content, cursor) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/theme_check/language_server/completion_providers/tag_completion_provider.rb', line 6 def completions(content, cursor) return [] unless can_complete?(content, cursor) partial = first_word(content) || '' labels = ShopifyLiquid::Tag.labels labels += ShopifyLiquid::Tag.end_labels labels .select { |w| w.start_with?(partial) } .map { |tag| tag_to_completion(tag) } end |