mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
[ruby/error_highlight] Improve English comments and messages
https://github.com/ruby/error_highlight/commit/5f976265ef
This commit is contained in:
parent
71e231847b
commit
c693b0e477
@ -1,13 +1,13 @@
|
||||
require_relative "version"
|
||||
|
||||
module ErrorHighlight
|
||||
# Identify the code fragment at that a given exception occurred.
|
||||
# Identify the code fragment where a given exception occurred.
|
||||
#
|
||||
# Options:
|
||||
#
|
||||
# point_type: :name | :args
|
||||
# :name (default) points the method/variable name that the exception occurred.
|
||||
# :args points the arguments of the method call that the exception occurred.
|
||||
# :name (default) points to the method/variable name where the exception occurred.
|
||||
# :args points to the arguments of the method call where the exception occurred.
|
||||
#
|
||||
# backtrace_location: Thread::Backtrace::Location
|
||||
# It locates the code fragment of the given backtrace_location.
|
||||
@ -113,7 +113,7 @@ module ErrorHighlight
|
||||
snippet = @node.script_lines[lineno - 1 .. last_lineno - 1].join("")
|
||||
snippet += "\n" unless snippet.end_with?("\n")
|
||||
|
||||
# It require some work to support Unicode (or multibyte) characters.
|
||||
# It requires some work to support Unicode (or multibyte) characters.
|
||||
# Tentatively, we stop highlighting if the code snippet has non-ascii characters.
|
||||
# See https://github.com/ruby/error_highlight/issues/4
|
||||
raise NonAscii unless snippet.ascii_only?
|
||||
@ -504,7 +504,6 @@ module ErrorHighlight
|
||||
def spot_fcall_for_args
|
||||
_mid, nd_args = @node.children
|
||||
if nd_args && nd_args.first_lineno == nd_args.last_lineno
|
||||
# binary operator
|
||||
fetch_line(nd_args.first_lineno)
|
||||
@beg_column = nd_args.first_column
|
||||
@end_column = nd_args.last_column
|
||||
|
||||
@ -24,7 +24,7 @@ module ErrorHighlight
|
||||
_, _, snippet, highlight = ErrorHighlight.formatter.message_for(spot).lines
|
||||
out += "\n | #{ snippet } #{ highlight }"
|
||||
else
|
||||
out += "\n (cannot create a snippet of the method definition; use Ruby 3.5 or later)"
|
||||
out += "\n (cannot highlight method definition; try Ruby 3.5 or later)"
|
||||
end
|
||||
end
|
||||
ret << "\n" + out if out
|
||||
|
||||
@ -56,11 +56,11 @@ module ErrorHighlight
|
||||
end
|
||||
|
||||
def self.terminal_width
|
||||
# lazy load io/console, so it's not loaded when 'max_snippet_width' is set
|
||||
# lazy load io/console to avoid loading it when 'max_snippet_width' is manually set
|
||||
require "io/console"
|
||||
$stderr.winsize[1] if $stderr.tty?
|
||||
rescue LoadError, NoMethodError, SystemCallError
|
||||
# do not truncate when window size is not available
|
||||
# skip truncation when terminal window size is unavailable
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -1468,7 +1468,7 @@ wrong number of arguments (given 1, expected 2) (ArgumentError)
|
||||
MethodDefLocationSupported ?
|
||||
"| def wrong_number_of_arguments_test(x, y)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" :
|
||||
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
|
||||
"(cannot highlight method definition; try Ruby 3.5 or later)"
|
||||
}
|
||||
END
|
||||
|
||||
@ -1494,7 +1494,7 @@ missing keyword: :kw3 (ArgumentError)
|
||||
MethodDefLocationSupported ?
|
||||
"| def keyword_test(kw1:, kw2:, kw3:)
|
||||
^^^^^^^^^^^^" :
|
||||
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
|
||||
"(cannot highlight method definition; try Ruby 3.5 or later)"
|
||||
}
|
||||
END
|
||||
|
||||
@ -1515,7 +1515,7 @@ unknown keyword: :kw4 (ArgumentError)
|
||||
MethodDefLocationSupported ?
|
||||
"| def keyword_test(kw1:, kw2:, kw3:)
|
||||
^^^^^^^^^^^^" :
|
||||
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
|
||||
"(cannot highlight method definition; try Ruby 3.5 or later)"
|
||||
}
|
||||
END
|
||||
|
||||
@ -1545,7 +1545,7 @@ wrong number of arguments (given 1, expected 3) (ArgumentError)
|
||||
MethodDefLocationSupported ?
|
||||
"| def wrong_number_of_arguments_test2(
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" :
|
||||
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
|
||||
"(cannot highlight method definition; try Ruby 3.5 or later)"
|
||||
}
|
||||
END
|
||||
|
||||
@ -1567,7 +1567,7 @@ wrong number of arguments (given 1, expected 0) (ArgumentError)
|
||||
MethodDefLocationSupported ?
|
||||
"| v = -> {}
|
||||
^^" :
|
||||
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
|
||||
"(cannot highlight method definition; try Ruby 3.5 or later)"
|
||||
}
|
||||
END
|
||||
|
||||
@ -1589,7 +1589,7 @@ wrong number of arguments (given 1, expected 0) (ArgumentError)
|
||||
MethodDefLocationSupported ?
|
||||
"| v = lambda { }
|
||||
^" :
|
||||
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
|
||||
"(cannot highlight method definition; try Ruby 3.5 or later)"
|
||||
}
|
||||
END
|
||||
|
||||
@ -1615,7 +1615,7 @@ wrong number of arguments (given 1, expected 2) (ArgumentError)
|
||||
MethodDefLocationSupported ?
|
||||
"| define_method :define_method_test do |x, y|
|
||||
^^" :
|
||||
"(cannot create a snippet of the method definition; use Ruby 3.5 or later)"
|
||||
"(cannot highlight method definition; try Ruby 3.5 or later)"
|
||||
}
|
||||
END
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user