mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
define a Pry::Method#source_location, fixes #524
* This fixes _file_ for rbx core methods by special casing rbx right at Pry::Method#source_location, as a result most things down stream should 'just work' with rbx, with no other checks required
This commit is contained in:
parent
fa6791eb56
commit
74d3d0da48
2 changed files with 15 additions and 13 deletions
|
@ -250,8 +250,8 @@ class Pry
|
|||
code = strip_comments_from_c_code(info.source)
|
||||
end
|
||||
when :ruby
|
||||
if Helpers::BaseHelpers.rbx? && core?
|
||||
code = core_code
|
||||
if Helpers::BaseHelpers.rbx? && !pry_method?
|
||||
code = core_code
|
||||
elsif pry_method?
|
||||
code = Pry.new(:input => StringIO.new(Pry.line_buffer[source_line..-1].join), :prompt => proc {""}, :hooks => Pry::Hooks.new).r
|
||||
else
|
||||
|
@ -270,8 +270,8 @@ class Pry
|
|||
info = pry_doc_info
|
||||
info.docstring if info
|
||||
when :ruby
|
||||
if Helpers::BaseHelpers.rbx? && core?
|
||||
strip_leading_hash_and_whitespace_from_ruby_comments(core_doc)
|
||||
if Helpers::BaseHelpers.rbx? && !pry_method?
|
||||
strip_leading_hash_and_whitespace_from_ruby_comments(core_doc)
|
||||
elsif pry_method?
|
||||
raise CommandError, "Can't view doc for a REPL-defined method."
|
||||
else
|
||||
|
@ -286,6 +286,15 @@ class Pry
|
|||
source_location.nil? ? :c : :ruby
|
||||
end
|
||||
|
||||
def source_location
|
||||
if Helpers::BaseHelpers.rbx?
|
||||
file, line = @method.source_location
|
||||
[RbxPath.convert_path_to_full(file), line]
|
||||
else
|
||||
@method.source_location
|
||||
end
|
||||
end
|
||||
|
||||
# @return [String, nil] The name of the file the method is defined in, or
|
||||
# `nil` if the filename is unavailable.
|
||||
def source_file
|
||||
|
|
|
@ -1,20 +1,13 @@
|
|||
class Pry
|
||||
module RbxMethod
|
||||
private
|
||||
def core?
|
||||
source_file and RbxPath.is_core_path?(source_file)
|
||||
end
|
||||
|
||||
def core_code
|
||||
MethodSource.source_helper(core_path_line)
|
||||
MethodSource.source_helper(source_location)
|
||||
end
|
||||
|
||||
def core_doc
|
||||
MethodSource.comment_helper(core_path_line)
|
||||
end
|
||||
|
||||
def core_path_line
|
||||
[RbxPath.convert_path_to_full(source_file), source_line]
|
||||
MethodSource.comment_helper(source_location)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue