Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Only suggest filters available in SourceIndex #689

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def determine_input_type(context)
end

def available_filters_for(input_type)
filters = ShopifyLiquid::Filter.filters
filters = ShopifyLiquid::SourceIndex.filters
.select { |filter| input_type.nil? || filter.input_type == input_type }
return all_labels if filters.empty?
return filters if input_type == INPUT_TYPE_VARIABLE
Expand Down
16 changes: 0 additions & 16 deletions lib/theme_check/shopify_liquid/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,9 @@ module Filter
"debug",
]

def filters
@filters ||= SourceIndex.filters +
LABELS_NOT_IN_SOURCE_INDEX.map { |name| build_filter_entry_for(name) }.freeze
end

def labels
@labels ||= SourceIndex.filters.map(&:name) + LABELS_NOT_IN_SOURCE_INDEX
end

private

def build_filter_entry_for(name)
SourceIndex::FilterEntry.new({
"name" => name,
"summary" => name,
"syntax" => "variable | ",
"return_type" => [],
})
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ def test_completions
assert_can_complete_with(@provider, "{{ 'foo.js' | ", "asset_url")
assert_can_complete_with(@provider, "{{ 'foo.js' | asset", "asset_url")
assert_can_complete_with(@provider, "{{ 'foo.js' | asset_url | image", "image_url")
end

def test_completions_for_filters_not_in_source_index
filter_not_in_source_index = 'installments_pricing'
assert_includes(ShopifyLiquid::Filter::LABELS_NOT_IN_SOURCE_INDEX, filter_not_in_source_index)
assert_can_complete_with(@provider, "{{ 'foo.js' | ", filter_not_in_source_index)
refute_can_complete_with(@provider, "{{ 'foo.js' | ", filter_not_in_source_index)
end

def test_completions_with_content_after_cursor
Expand Down
4 changes: 0 additions & 4 deletions test/shopify_liquid_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ def test_filter_labels
assert_equal(168, ThemeCheck::ShopifyLiquid::Filter.labels.size)
end

def test_filter_filters
assert_equal(168, ThemeCheck::ShopifyLiquid::Filter.filters.size)
end

def test_object_labels
assert_equal(119, ThemeCheck::ShopifyLiquid::Object.labels.size)
end
Expand Down