Before this change, ? Array.try_convert would highlight the code
snippets as C, but because it's actually a ruby method all the code in
the comment is ruby.
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.
Unfortunately, alias? requires loading the entire source code for each method,
so this can get pretty slow for modules that include hundreds of methods.
* switch to show all monkeypatches is now -a (for all)
* improved some method names (top_method_candidates => method_candidates in wrapped_module.rb)
* improved in-session documentation for show-source and show-doc
* applies to modules/classes, displays the full list of candidate module definitions or documentation (in case of show-doc)
* TODO: a fucktonne of tests
* also defined a WrappedModule#doc
* TODO: define a module_object (analogous to method_object) for method_options(), to further DRY up show-doc and show-source