Module: ThemeCheck::LanguageServer::VariableLookupFinder
- Extended by:
- VariableLookupFinder
- Included in:
- VariableLookupFinder
- Defined in:
- lib/theme_check/language_server/variable_lookup_finder.rb
Constant Summary collapse
- UNCLOSED_SQUARE_BRACKET =
/\[[^\]]*\Z/
- ENDS_IN_BRACKET_POSITION_THAT_CANT_BE_COMPLETED =
%r{ ( # quotes not preceded by a [ (?<!\[)['"]| # closing ] \]| # opening [ \[ )$ }x
- VARIABLE_LOOKUP_CHARACTERS =
/[a-z0-9_.'"\]\[]/i
- VARIABLE_LOOKUP =
/#{VARIABLE_LOOKUP_CHARACTERS}+/o
- SYMBOLS_PRECEDING_POTENTIAL_LOOKUPS =
%r{ (?: \s(?: if|elsif|unless|and|or|#{Liquid::Condition.operators.keys.join("|")} |echo |case|when |cycle |in ) |[:,=] ) \s+ }omix
- ENDS_WITH_BLANK_POTENTIAL_LOOKUP =
/#{SYMBOLS_PRECEDING_POTENTIAL_LOOKUPS}$/oimx
- ENDS_WITH_POTENTIAL_LOOKUP =
/#{SYMBOLS_PRECEDING_POTENTIAL_LOOKUPS}#{VARIABLE_LOOKUP}$/oimx
Instance Method Summary collapse
Instance Method Details
#lookup(content, cursor) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/theme_check/language_server/variable_lookup_finder.rb', line 38 def lookup(content, cursor) return if cursor_is_on_bracket_position_that_cant_be_completed(content, cursor) potential_lookup = lookup_liquid_variable(content, cursor) || lookup_liquid_tag(content, cursor) # And we only return it if it's parsed by Liquid as VariableLookup return unless potential_lookup.is_a?(Liquid::VariableLookup) potential_lookup end |