Sha256: 7361b7c81fe80a11ab07c819a83bbb1147575e28f6bdb80775e16452b7702882
Contents?: true
Size: 1.11 KB
Versions: 25
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module PlatformosCheck module LanguageServer module VariableLookupFinder class AssignmentsFinder class ScopeVisitor SCOPE_UNAWARE_NODES = %i[range range_lookup variable variable_lookup] attr_reader :global_scope, :current_scope def initialize @node_handler = NodeHandler.new @global_scope = Scope.new({}) @current_scope = Scope.new({}) end def visit_template(template) return unless template visit(liquid_node(template), global_scope) end private def visit(node, scope) return if SCOPE_UNAWARE_NODES.include?(node.type_name) method = :"on_#{node.type_name}" scope = @node_handler.send(method, node, scope) if @node_handler.respond_to?(method) @current_scope = scope node.children.each { |child| visit(child, scope) } end def liquid_node(template) LiquidNode.new(template.root, nil, template) end end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems