From: Jeff A. <ja...@fa...> - 2019-03-14 20:24:30
|
Albert: By coincidence, Tobias Kohn has written on the list that he has created an IDE (for high-school students). And of course there is PyDev within Eclipse which has achieved something similar and I'm glad to say supports Jython. Now I look I'm slightly surprised that a PyCode is that opaque. However, I believe what you are aiming for would be based on the AST you can get from the compile() function at the Python level, or Java compiler calls if you wish. This has much symbolic information embedded in it and links back to source code. I have played with this in pure Python 3 and Jython's looks very similar. A compled function object is quite inspectable (see inspect module), so maybe that is a way in for you too. The pdb module must understand the code it is debugging too, and amazingly works in Jython, so you could look how that gets from byte code to source code. There is an open bug about missing line numbers in ASTs, and I've sometimes found line numbers in error messages to be off their mark, but I've always been fixing something else at the time (of course). There may be some annoyances here. Jeff Jeff Allen On 13/03/2019 02:03, Albert Cardona wrote: > Hi all, > > In Fiji--an open source java software for image processing--we have an > "Script Editor" [1] capable of executing a number of languages, > including jython. > > I've written big chunks of it and I know its codebase reasonably well. > > What I'd like to do is to add IDE features such as the ability to > select a name and jump to its definition, be it within the same file > (perhaps easier, and a good start) or some other file. > > I understand that the org.python.util.PythonInterpreter has methods to > compile, but not execute, a bunch of code, returning a PyCode object. > > Are there introspection methods in the returned PyCode that could be > used for the above purpose? Or how would you approach this feature? > > Thanks for any suggestions. > > Albert Cardona > > [1] https://github.com/scijava/script-editor > > > -- > Group Leader, HHMI Janelia Research Campus, USA. > Reader (Associate Professor), Dept. Physiol. Dev. Neurosci., > University of Cambridge, UK. > https://albert.rierol.net > https://www.janelia.org/lab/cardona-lab/ > https://www.pdn.cam.ac.uk/directory/albert-cardona > > > _______________________________________________ > Jython-dev mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-dev > |