lib/theme_check/language_server/variable_lookup_finder.rb
def lookup_liquid_tag(content, cursor)
        return unless cursor_is_on_liquid_tag_lookup_position(content, cursor)

        markup = parseable_markup(content, cursor)
        return empty_lookup if markup == :empty_lookup_markup

        template = Liquid::Template.parse(markup)
        current_tag = template.root.nodelist[0]

        case current_tag.tag_name
        when "if", "unless"
          variable_lookup_for_if_tag(current_tag)
        when "case"
          variable_lookup_for_case_tag(current_tag)
        when "cycle"
          variable_lookup_for_cycle_tag(current_tag)
        when "for"
          variable_lookup_for_for_tag(current_tag)
        when "tablerow"
          variable_lookup_for_tablerow_tag(current_tag)
        when "render"
          variable_lookup_for_render_tag(current_tag)
        when "assign"
          variable_lookup_for_assign_tag(current_tag)
        when "echo"
          variable_lookup_for_echo_tag(current_tag)
        end

      # rubocop:disable Style/RedundantReturn
      rescue Liquid::SyntaxError
        # We don't complete variable for liquid syntax errors
        return
      end
# Context:
#
# We know full well that the code as it is being typed is probably not
# something that can be parsed by liquid.
#
# How this works:
#
# 1. Attempt to turn the code of the token until the cursor position into
#    valid liquid code with some hacks.
# 2. If the code ends in space at a "potential lookup" spot
#   a. Then return an empty variable lookup
# 3. Parse the valid liquid code
# 4. Attempt to extract a VariableLookup from Liquid::Template
We know full well that the code as it is being typed is probably not
something that can be parsed by liquid.



1. Attempt to turn the code of the token until the cursor position into
valid liquid code with some hacks.
2. If the code ends in space at a "potential lookup" spot
a. Then return an empty variable lookup
3. Parse the valid liquid code
4. Attempt to extract a VariableLookup from Liquid::Template
We know full well that the code as it is being typed is probably not something that can be parsed by liquid . 1 . Attempt to turn the code of the token until the cursor position into valid liquid code with some hacks . 2 . If the code ends in space at a " potential lookup " spot a . Then return an empty variable lookup 3 . Parse the valid liquid code 4 . Attempt to extract a VariableLookup from Liquid :: Template
def lookup_liquid_tag(content, cursor)
        return unless cursor_is_on_liquid_tag_lookup_position(content, cursor)
        markup = parseable_markup(content, cursor)
        return empty_lookup if markup == :empty_lookup_markup
        template = Liquid::Template.parse(markup)
        current_tag = template.root.nodelist[0]
        case current_tag.tag_name
        when "if", "unless"
          variable_lookup_for_if_tag(current_tag)
        when "case"
          variable_lookup_for_case_tag(current_tag)
        when "cycle"
          variable_lookup_for_cycle_tag(current_tag)
        when "for"
          variable_lookup_for_for_tag(current_tag)
        when "tablerow"
          variable_lookup_for_tablerow_tag(current_tag)
        when "render"
          variable_lookup_for_render_tag(current_tag)
        when "assign"
          variable_lookup_for_assign_tag(current_tag)
        when "echo"
          variable_lookup_for_echo_tag(current_tag)
        end
      rescue Liquid::SyntaxError
        return
      end
def lookup_liquid_tag ( content , cursor ) return unless cursor_is_on_liquid_tag_lookup_position ( content , cursor ) markup = parseable_markup ( content , cursor ) return empty_lookup if markup == :empty_lookup_markup template = Liquid :: Template . parse ( markup ) current_tag = template . root . nodelist [ 0 ] case current_tag . tag_name when "if" , "unless" variable_lookup_for_if_tag ( current_tag ) when "case" variable_lookup_for_case_tag ( current_tag ) when "cycle" variable_lookup_for_cycle_tag ( current_tag ) when "for" variable_lookup_for_for_tag ( current_tag ) when "tablerow" variable_lookup_for_tablerow_tag ( current_tag ) when "render" variable_lookup_for_render_tag ( current_tag ) when "assign" variable_lookup_for_assign_tag ( current_tag ) when "echo" variable_lookup_for_echo_tag ( current_tag ) end rescue Liquid :: SyntaxError return end
Context:
We know full well that the code as it is being typed is probably not
something that can be parsed by liquid.
Context : We know full well that the code as it is being typed is probably not something that can be parsed by liquid .
# rubocop:disable Style/RedundantReturn # We don't complete variable for liquid syntax errors
content
cursor