Class: ScoutApm::AutoInstrument::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/auto_instrument/prism.rb,
lib/scout_apm/auto_instrument/parser.rb

Instance Method Summary collapse

Constructor Details

#initializeCache



331
332
333
# File 'lib/scout_apm/auto_instrument/prism.rb', line 331

def initialize
  @local_assignments = {}
end

Instance Method Details

#local_assignments?(node) ⇒ Boolean



335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/scout_apm/auto_instrument/prism.rb', line 335

def local_assignments?(node)
  return false unless node
  return false unless node.respond_to?(:compact_child_nodes)

  unless @local_assignments.key?(node)
    if node.is_a?(Prism::LocalVariableWriteNode)
      @local_assignments[node] = true
    elsif node.compact_child_nodes.find{|child|
      # Don't check blocks - assignments inside blocks shouldn't affect the parent call
      next if child.is_a?(Prism::BlockNode)
      self.local_assignments?(child)
    }
      @local_assignments[node] = true
    else
      @local_assignments[node] = false
    end
  end

  return @local_assignments[node]
end