<commit_before>module Byebug
  #
  # Implements breakpoint functionality
  #
  class BreakCommand < Command
    self.allow_in_post_mortem = false
    self.allow_in_control = true

    def regexp
      /^\s* b(?:reak)? (?:\s+ (\S+))? (?:\s+ if \s+(.+))? \s*$/x
    end

    def execute
      return puts(self.class.help) if self.class.names.include?(@match[0])

      brkpt = line_breakpoint(@match[1]) || method_breakpoint(@match[1])
      return puts(pr('break.created', id: brkpt.id)) if syntax_valid?(@match[2])

      errmsg(pr('break.errors.expression', expr: @match[2]))
      brkpt.enabled = false
    rescue => e
      errmsg(e.message)
    end

    class << self
      def names
        %w(break)
      end

      def description
        <<-EOD.gsub(/^ {8}/, '')
          b[reak] file:line [if expr]
          b[reak] class(.|#)method [if expr]

          Set breakpoint to some position, (optionally) if expr == true
        EOD
      end
    end

    private

    def line_breakpoint(loc)
      line, file_line = loc.match(/^(\d+)$/), loc.match(/^([^:]+):(\d+)$/)
      return nil unless line || file_line

      f, l = line ? [@state.file, line[1]] : [file_line[1], file_line[2]]

      check_errors(f, l.to_i)

      Breakpoint.add(File.expand_path(f), l.to_i, @match[2])
    end

    def method_breakpoint(location)
      location.match(/([^.#]+)[.#](.+)/) do |match|
        k, m = bb_warning_eval(match[1]), match[2]

        klass = k && k.is_a?(Module) ? k.name : match[1]
        method = m.intern

        Breakpoint.add(klass, method, @match[2])<commit_msg>Fix description of break command (file is optional).<commit_after>module Byebug
  #
  # Implements breakpoint functionality
  #
  class BreakCommand < Command
    self.allow_in_post_mortem = false
    self.allow_in_control = true

    def regexp
      /^\s* b(?:reak)? (?:\s+ (\S+))? (?:\s+ if \s+(.+))? \s*$/x
    end

    def execute
      return puts(self.class.help) if self.class.names.include?(@match[0])

      brkpt = line_breakpoint(@match[1]) || method_breakpoint(@match[1])
      return puts(pr('break.created', id: brkpt.id)) if syntax_valid?(@match[2])

      errmsg(pr('break.errors.expression', expr: @match[2]))
      brkpt.enabled = false
    rescue => e
      errmsg(e.message)
    end

    class << self
      def names
        %w(break)
      end

      def description
        <<-EOD.gsub(/^ {8}/, '')
          b[reak] [file:]line [if expr]
          b[reak] class(.|#)method [if expr]

          Set breakpoint to some position, (optionally) if expr == true
        EOD
      end
    end

    private

    def line_breakpoint(loc)
      line, file_line = loc.match(/^(\d+)$/), loc.match(/^([^:]+):(\d+)$/)
      return nil unless line || file_line

      f, l = line ? [@state.file, line[1]] : [file_line[1], file_line[2]]

      check_errors(f, l.to_i)

      Breakpoint.add(File.expand_path(f), l.to_i, @match[2])
    end

    def method_breakpoint(location)
      location.match(/([^.#]+)[.#](.+)/) do |match|
        k, m = bb_warning_eval(match[1]), match[2]

        klass = k && k.is_a?(Module) ? k.name : match[1]
        method = m.intern

        Breakpoint.add(klass, method, @match[2])
{'fraction_non_alphanumeric': 0.1734917161613004, 'fraction_numerical': 0.0087527352297593, 'mean_word_length': 2.466955579631636, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, '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': '3839006', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1128, 'n_words': 248}