<commit_before>require 'trace_tree/tree_graphable'
require 'trace_tree/tree_htmlable'

class TraceTree
  class Node

    include TreeGraphable
    include TreeHtmlable

    attr_reader :bindings
    attr_accessor :parent

    def initialize trace_point
      @event = trace_point.event
      @method_id = trace_point.method_id
      @bindings = filter_call_stack trace_point.binding.of_callers!
    end

    def << node
      callees << node
      node.parent = self
    end

    def callees
      @callees ||= []
    end

    def whole_stack
      bindings.map{|b| location_without_lineno b}
    end

    def parent_stack
      range = (raise_event? ? bindings : bindings[1..-1])
      range.map{|b| location_without_lineno b}
    end

    private<commit_msg>for better performance, do not create singleton classes<commit_after>require 'trace_tree/tree_graphable'
require 'trace_tree/tree_htmlable'

class TraceTree
  class Node

    include TreeGraphable
    include TreeHtmlable

    attr_reader :bindings
    attr_accessor :parent

    def initialize trace_point
      @event = trace_point.event
      @method_id = trace_point.method_id
      @bindings = filter_call_stack trace_point.binding.of_callers
    end

    def << node
      callees << node
      node.parent = self
    end

    def callees
      @callees ||= []
    end

    def whole_stack
      bindings.map{|b| location_without_lineno b}
    end

    def parent_stack
      range = (raise_event? ? bindings : bindings[1..-1])
      range.map{|b| location_without_lineno b}
    end

    private
{'fraction_non_alphanumeric': 0.07046764894298527, 'fraction_numerical': 0.0025624599615631004, 'mean_word_length': 2.79126213592233, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2721591', 'n_tokens_mistral': 507, 'n_tokens_neox': 481, 'n_words': 116}