Completion fix for Jruby.

Jruby doesn't always provide the method `#instance_methods()` on objects. By
checking to see if this method exists before using it the completion system
won't totally barf itself when used on Jruby.

Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
This commit is contained in:
Yorick Peterse 2012-06-19 13:19:32 +02:00
parent d53eb0921d
commit d3f1abbe37
1 changed files with 6 additions and 1 deletions

View File

@ -163,7 +163,12 @@ class Pry
end
next if name != "IRB::Context" and
/^(IRB|SLex|RubyLex|RubyToken)/ =~ name
candidates.concat m.instance_methods(false).collect{|x| x.to_s}
# jruby doesn't always provide #instance_methods() on each
# object.
if m.respond_to?(:instance_methods)
candidates.concat m.instance_methods(false).collect{|x| x.to_s}
end
}
candidates.sort!
candidates.uniq!