Re: Method completion

Alexey Zinger <inline_four-/[email protected]> Thu, 6 Apr 2006 06:59:50 -0700 (PDT)
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <[email protected]>
--- "Werner Schuster (murphee)" <[email protected]> wrote:

> Doesn't the jconsole run inside the same JVM as the code you want to 
> execute? Then you won't
> need to use javap, but simply use reflection.
> 
> Ie. ask bsh for the content of  variable "inst", then use Reflection to 
> get list of possible methods.
> If a method is chosen, you can query a Method object describing it, 
> which will tell you it's return value, etc.
> 
> For the chaining, you'll have to do some parsing... either
>  - use the bsh parser (although that might not work for incomplete code 
> like "foo.xxx().")
>  - Or use a Hack that just looks for "." and "()" to search for method 
> invocations.
> 
> 
> murphee
> -- 
> Blog @ http://jroller.com/page/murphee
> Maintainer of EclipseShell @ http://eclipse-shell.sourceforge.net/

Another thing to consider here is whether we want autocompletion to run against
the declared return values of methods and field types or against the actual
values.

If we run it against declared types, we're at the mercy of those declarations. 
And of course when it comes to BeanShell functions and variables, we're not
gonna be able to use reflection directly and we won't be guaranteed any sort of
type accuracy.

If we run against actual returned objects, we'll have the full spectrum of
available fields and variables of the object.  But of course the problem is
that it would mean we'd be asking to execute the partial statement before we
press Enter.  This may not be a terrible thing if we use caching to avoid
side-effects and not do this kind of partial execution unless the user asks for
autocompletion (by pressing Tab for instance).  So that might be a decent compromise.

Alexey
2001 Honda CBR600F4i (CCS)
1992 Kawasaki EX500
http://azinger.blogspot.com
http://bsheet.sourceforge.net

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642