$19 GRAYBYTE WORDPRESS FILE MANAGER $60

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.43.35 | ADMIN IP 216.73.216.23
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/ruby34/share/ruby/prism/parse_result/

HOME
Current File : /opt/alt/ruby34/share/ruby/prism/parse_result//errors.rb
# frozen_string_literal: true
# :markup: markdown

require "stringio"

module Prism
  class ParseResult < Result
    # An object to represent the set of errors on a parse result. This object
    # can be used to format the errors in a human-readable way.
    class Errors
      # The parse result that contains the errors.
      attr_reader :parse_result

      # Initialize a new set of errors from the given parse result.
      def initialize(parse_result)
        @parse_result = parse_result
      end

      # Formats the errors in a human-readable way and return them as a string.
      def format
        error_lines = {} #: Hash[Integer, Array[ParseError]]
        parse_result.errors.each do |error|
          location = error.location
          (location.start_line..location.end_line).each do |line|
            error_lines[line] ||= []
            error_lines[line] << error
          end
        end

        source_lines = parse_result.source.source.lines
        source_lines << "" if error_lines.key?(source_lines.size + 1)

        io = StringIO.new
        source_lines.each.with_index(1) do |line, line_number|
          io.puts(line)

          (error_lines.delete(line_number) || []).each do |error|
            location = error.location

            case line_number
            when location.start_line
              io.print(" " * location.start_column + "^")

              if location.start_line == location.end_line
                if location.start_column != location.end_column
                  io.print("~" * (location.end_column - location.start_column - 1))
                end

                io.puts(" " + error.message)
              else
                io.puts("~" * (line.bytesize - location.start_column))
              end
            when location.end_line
              io.puts("~" * location.end_column + " " + error.message)
            else
              io.puts("~" * line.bytesize)
            end
          end
        end

        io.puts
        io.string
      end
    end
  end
end


Current_dir [ NOT WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
10 Feb 2026 9.34 AM
root / linksafe
0755
comments.rb
5.959 KB
27 Jan 2026 4.00 PM
root / linksafe
0644
errors.rb
1.988 KB
27 Jan 2026 4.00 PM
root / linksafe
0644
newlines.rb
3.952 KB
27 Jan 2026 4.00 PM
root / linksafe
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF