Method completion

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Method completion

WildDonkey
Hi
I'm trying to add some kind of method completion to the jconsole.
The basic idea was to use javap on the variable which then prints out the filtered list matching the string between the . and the end of line. This kind of works but now I realise it's rather annoying not to be able to chain methods as in: inst.methodA().methodB(a,b).methodC().TAB

What is the best way to resolve what the type of parameters being passed to methodB is - do I need to resort to using the java parser and if so, could someone give me some pointers ?

I'll obviously send the patch back when its working properly.
Thanks
David
Reply | Threaded
Open this post in threaded view
|

Re: Method completion

Wade Chandler-6
--- WildDonkey <[hidden email]> wrote:

> Hi
> I'm trying to add some kind of method completion to
> the jconsole.
> The basic idea was to use javap on the variable
> which then prints out the
> filtered list matching the string between the . and
> the end of line. This
> kind of works but now I realise it's rather annoying
> not to be able to chain
> methods as in:
> inst.methodA().methodB(a,b).methodC().TAB
>
> What is the best way to resolve what the type of
> parameters being passed to
> methodB is - do I need to resort to using the java
> parser and if so, could
> someone give me some pointers ?
>
> I'll obviously send the patch back when its working
> properly.
> Thanks
> David
>

Much larger question than can be answered really in a
few emails.  I think it would be easier to download an
open source IDE like Netbeans and see how they did it.
 You would not only have pointers, but a real working
example and the source.

Wade


-------------------------------------------------------
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
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Method completion

Werner Schuster (murphee)
In reply to this post by WildDonkey
WildDonkey wrote:

>I'm trying to add some kind of method completion to the jconsole.
>The basic idea was to use javap on the variable which then prints out the
>filtered list matching the string between the . and the end of line.
>  
>


>kind of works but now I realise it's rather annoying not to be able to chain
>methods as in: inst.methodA().methodB(a,b).methodC().TAB
>
>  
>
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/




-------------------------------------------------------
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
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers
Reply | Threaded
Open this post in threaded view
|

Re: Method completion

Alexey Zinger
--- "Werner Schuster (murphee)" <[hidden email]> 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
_______________________________________________
Beanshell-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-developers