Class: PlatformosCheck::LanguageServer::FilterCompletionProvider
- Inherits:
-
CompletionProvider
- Object
- CompletionProvider
- PlatformosCheck::LanguageServer::FilterCompletionProvider
- Defined in:
- lib/platformos_check/language_server/completion_providers/filter_completion_provider.rb
Constant Summary collapse
- NAMED_FILTER =
/#{Liquid::FilterSeparator}\s*(\w+)/o
- FILTER_SEPARATOR_INCLUDING_SPACES =
/\s*#{Liquid::FilterSeparator}/
- INPUT_TYPE_VARIABLE =
'variable'
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 PlatformosCheck::LanguageServer::CompletionProvider
Instance Method Details
#can_complete?(content, cursor) ⇒ Boolean
25 26 27 28 29 30 |
# File 'lib/platformos_check/language_server/completion_providers/filter_completion_provider.rb', line 25 def can_complete?(content, cursor) content.match?(Liquid::FilterSeparator) && ( cursor_on_start_content?(content, cursor, Liquid::FilterSeparator) || cursor_on_filter?(content, cursor) ) end |
#completions(context) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/platformos_check/language_server/completion_providers/filter_completion_provider.rb', line 10 def completions(context) content = context.content cursor = context.cursor return [] if content.nil? return [] unless can_complete?(content, cursor) context = context_with_cursor_before_potential_filter_separator(context) variable_lookup = VariableLookupFinder.lookup(context) denied_filters = denied_filters_for(variable_lookup) available_filters_for(determine_input_type(variable_lookup)) .select { |filter| filter.name.start_with?(partial(content, cursor)) && denied_filters.none?(filter.name) } .map { |filter| filter_to_completion(filter) } end |