Re: Parsing jython code

Albert Cardona <[email protected]> Fri, 11 Dec 2020 18:03:03 +0000
Newsgroups gmane.comp.lang.jython.devel
Message-ID <CAJj13_-dekQyA+jJWkUrKCyJj2iO02THCKZd2_wsxUOX4qDCPg@mail.gmail.com>
Hi Yaqiang,

Thanks for the pointers. So far, I've managed to make a half-decent
framework for autocompleting jython code. It works remarkably well,
and it includes the ability to automatically insert imports for java
classes when these are autocompleted; the latter being a major feature
that motivated the whole project, to ease the discovery of the many
libraries in the image processing software Fiji (https://fiji.sc).

I'm sure it could work better (and the code be less naive!) if I knew
the jython internals better. For example now I'm stuck with
org.python.core.antlr.ast.Num: how to get, from here, the underlying
numeric class? Returning the "Num.getInternalN().getClass()" gives me
e.g. a PyInteger, but that's not the class from which I should be
harvesting methods and fields for autocompletion. I wonder what the
java class is for 'int' and 'float', and how to get it from a Num?

For the record, here is the library for gather strings for completion:
https://github.com/fiji/jython-autocompletion

And it is used from Fiji's Script Editor
(https://github.com/scijava/script-editor/tree/fix-autocompletion-listener).

Best regards,

Albert

Missatge de Yaqiang Wang <[email protected]> del dia dj., 10 de
des. 2020 a les 6:55:
>
> Hi Albert, glad to hear you are working on Java and Jython code autocompletions. I also used RSyntaxArea in MeteoInfo software (http://www.meteothink.org/index.html) and some basic code autocompletion functions were implemented in the code editor and console. But the software lacks static code analysis capabilities. Hope your work can be effective to help the Jython community.
>
> Regards
> Yaqiang
>
> On Thu, Dec 3, 2020 at 6:17 AM Albert Cardona <[email protected]> wrote:
>>
>> Hi Garret, thanks for pointing to jedi. The one issue I see is I'll
>> have to figure out how to invoke it from java and deliver the
>> autocompletions to a java RSyntaxArea. Seems doable, but tricky.
>>
>> Missatge de Garrett Rolfs <[email protected]> del dia dc., 2 de des.
>> 2020 a les 19:31:
>> >
>> > Albert Cardona <[email protected]> writes:
>> >
>> > > The ultimate goal is to be able to provide autocompletions for
>> > > variables within scope, and for functions of imported modules as well.
>> >
>> > Are you pursuing something jedi cannot handle?
>> >
>> >   - https://pypi.org/project/jedi/
>> >
>> > -Garrett
>> >
>> >
>> >
>> > _______________________________________________
>> > Jython-dev mailing list
>> > [email protected]
>> > https://lists.sourceforge.net/lists/listinfo/jython-dev
>>
>>
>> _______________________________________________
>> Jython-dev mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/jython-dev
>
>
>
> --
> *************************************************
> Dr. Yaqiang Wang
> Chinese Academy of Meteorological Sciences (CAMS)
> 46, Zhong-Guan-Cun South Avenue
> Beijing, 100081
> China
>
> [email protected]
>
> www.meteothink.org
> **************************************************