Class: ThemeCheck::LanguageServer::FilterCompletionProvider
- Inherits:
-
CompletionProvider
show all
- Defined in:
- lib/theme_check/language_server/completion_providers/filter_completion_provider.rb
Constant Summary
collapse
- NAMED_FILTER =
/#{Liquid::FilterSeparator}\s*(\w+)/o
CompletionHelper::WORD
Instance Method Summary
collapse
all, inherited
#cursor_on_first_word?, #cursor_on_start_content?, #first_word, #matches
Instance Method Details
#can_complete?(content, cursor) ⇒ Boolean
15
16
17
18
19
20
|
# File 'lib/theme_check/language_server/completion_providers/filter_completion_provider.rb', line 15
def can_complete?(content, cursor)
content.match?(Liquid::FilterSeparator) && (
cursor_on_start_content?(content, cursor, Liquid::FilterSeparator) ||
cursor_on_filter?(content, cursor)
)
end
|
#completions(content, cursor) ⇒ Object
8
9
10
11
12
13
|
# File 'lib/theme_check/language_server/completion_providers/filter_completion_provider.rb', line 8
def completions(content, cursor)
return [] unless can_complete?(content, cursor)
ShopifyLiquid::Filter.labels
.select { |w| w.starts_with?(partial(content, cursor)) }
.map { |filter| filter_to_completion(filter) }
end
|