Class: ThemeCheck::LanguageServer::ObjectCompletionProvider
- Inherits:
-
CompletionProvider
show all
- Defined in:
- lib/theme_check/language_server/completion_providers/object_completion_provider.rb
Constant Summary
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
14
15
16
17
18
19
|
# File 'lib/theme_check/language_server/completion_providers/object_completion_provider.rb', line 14
def can_complete?(content, cursor)
content.match?(Liquid::VariableStart) && (
cursor_on_first_word?(content, cursor) ||
cursor_on_start_content?(content, cursor, Liquid::VariableStart)
)
end
|
#completions(content, cursor) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/theme_check/language_server/completion_providers/object_completion_provider.rb', line 6
def completions(content, cursor)
return [] unless can_complete?(content, cursor)
partial = first_word(content) || ''
ShopifyLiquid::Object.labels
.select { |w| w.starts_with?(partial) }
.map { |object| object_to_completion(object) }
end
|