Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Obviously there isn't ever gonna be a 100% solution for a language as dynamic as Perl. Even if you had some kind of internal reflection capability at runtime, you can't account for an AUTOLOAD that hasn't been run yet. And for textual parsing you can't find dynamically created methods and attributes.

In PerlySense I take a heuristic approach to identifying methods.(And I don't distinguish between methods and attributes.)

Basically, Perl code has a lot of conventions and idioms. If it looks like Perl, let's assume it is Perl. So if you look at Perl code and see this, what would you say it looks like?

$self->send_email();
It looks like a method on the class for the current package. So let's assume that's what it is. In the same vein I take the shortcut of considering this a method/accessor:
$self->{email} = $recipient_email;

If PerlySense can't find an explicit declaration for a sub or attribute (mostly attributes), it will look for matching POD to display or navigate to.

How you interpret things kinda depends on whether you consider false positives or false negatives worse. Maybe some positives are worse in some situations and negatives worse in others (possibly completions vs refactorings). Just looking at methods invoked on $self is not gonna find all of them, but static parsing of "sub" + $self->method and $self->{attribute} turns out to be pretty complete.

When it comes to static parsing of syntax, I guess we'll need to write plugins to accompany module-introduced syntax for Moose, Class::Accessor, Class::MethodMaker, etc.

I haven't done anything like that yet, but there's enough Moose classes in the code base at work that I'm really starting to miss a working "Go to Base Class" for the Moose stuff.

/J


In reply to Re: How to find all the available functions in a file or methods in a module? by jplindstrom
in thread How to find all the available functions in a file or methods in a module? by szabgab

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (1)
As of 2024-04-25 00:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found