Class: PlatformosCheck::LanguageServer::VariableLookupFinder::AssignmentsFinder

Inherits:
Object
  • Object
show all
Includes:
RegexHelpers
Defined in:
lib/platformos_check/language_server/variable_lookup_finder/assignments_finder.rb,
lib/platformos_check/language_server/variable_lookup_finder/assignments_finder/scope.rb,
lib/platformos_check/language_server/variable_lookup_finder/assignments_finder/node_handler.rb,
lib/platformos_check/language_server/variable_lookup_finder/assignments_finder/scope_visitor.rb

Defined Under Namespace

Classes: NodeHandler, Scope, ScopeVisitor

Constant Summary

Constants included from RegexHelpers

RegexHelpers::HTML_LIQUID_PLACEHOLDER, RegexHelpers::LIQUID_TAG, RegexHelpers::LIQUID_TAG_OR_VARIABLE, RegexHelpers::LIQUID_VARIABLE, RegexHelpers::START_OR_END_QUOTE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RegexHelpers

#matches

Constructor Details

#initialize(content) ⇒ AssignmentsFinder

Returns a new instance of AssignmentsFinder.



11
12
13
14
# File 'lib/platformos_check/language_server/variable_lookup_finder/assignments_finder.rb', line 11

def initialize(content)
  @content = close_tag(content)
  @scope_visitor = ScopeVisitor.new
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



9
10
11
# File 'lib/platformos_check/language_server/variable_lookup_finder/assignments_finder.rb', line 9

def content
  @content
end

#scope_visitorObject (readonly)

Returns the value of attribute scope_visitor.



9
10
11
# File 'lib/platformos_check/language_server/variable_lookup_finder/assignments_finder.rb', line 9

def scope_visitor
  @scope_visitor
end

Instance Method Details

#assignmentsObject



29
30
31
32
# File 'lib/platformos_check/language_server/variable_lookup_finder/assignments_finder.rb', line 29

def assignments
  current_scope = scope_visitor.current_scope
  current_scope.variables
end

#find!Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/platformos_check/language_server/variable_lookup_finder/assignments_finder.rb', line 16

def find!
  template = parse(content)

  if template
    visit_template(template)
    return
  end

  liquid_tags.each do |tag|
    visit_template(last_line_parse(tag))
  end
end