Bug prevented lookup of Deeply::Nested::Class::Definitions.
Also properly differentiate when looking up docs/source for *commands* and for the class that represents the command, i.e:
show-doc show-source #=> displays show-source --help
show-doc Pry::Command::ShowSource #=> comments above class definition (as with any other class)
Pry::CodeObject::Helpers mixin provides the following methods:
command?
module_with_yard_docs?
real_method_object?
c_method?
which are then mixed into the code objects: Pry::Command, Pry::Method, Pry::WrappedModule, Pry::WrappedModule::Candidate
This ensures that if the top-ranked module candidate is broken (i.e we can't extract its source)
that the module candidate with the next highest ranking is shown, and so on.
This commit also makes the speedy show-source more robust
This requires an updated method_source gem. This approach works by reading all code between the start of the class definition
and the method with the highest line number in one go. Since we know this chunk of code is valid we can avoid the expensive eval-based validity checks.
Once we have primed the expression buffer with this chunk of code we then start the expensive checks looking for a complete expression, but there shouldn't be
many lines of code left since we've already processed the last method in the class definition. Using this technique i was able to show-source the 2000 line definition of
ActiveRecord::Base in under a second.