Closed tferr closed 2 years ago
This pull request has been mentioned on Image.sc Forum. There might be relevant details there:
https://forum.image.sc/t/auto-code-completion-for-python-and-groovy-in-imagej-fiji/20515/22
@acardona , there are still two things that are missing in this PR:
from ij import (ImagePlus, ImageProcessor)
, neither ImagePlus
nor ImageProcessor
get recognized as being importedfrom ij import ImagePlus
imp = ImagePlus()
But no completions are retrieved if you use:
from ij import IJ
imp = IJ.getImage()
The latter would be the most important issue. I will wait for your feedback on this.
This pull request has been mentioned on Image.sc Forum. There might be relevant details there:
https://forum.image.sc/t/auto-code-completion-for-python-and-groovy-in-imagej-fiji/20515/25
Thanks a lot @tferr, this is great.
On from ij import (ImagePlus, ImageProcessor)
: are these even valid? If so, I had no idea. In python, one can use multi-imports like:
from ij import ImagePlus, ImageProcessor
or even:
from ij import ImagePlus,\
ImageProcessor
On this use case:
from ij import IJ
imp = IJ.getImage()
If it's from a static method, the object class can be retrieved from the return type of the static method.
If it's from a function, like:
from ij import IJ
def getImage():
return IJ.getImage()
imp = getImage()
... then no cookie: it's the perennial problem in non-strongly typed languages. Python is fixing this with annotations, which seem to be a part of the language in 3.8. There is currently an effort to bring jython to python 3+, but it's very understaffed (one very part-time developer).
For clarity, here is what this PR implements:
Here are some snapshots:
Field:
Fuzzy string search (methods):
Invalid import:
I have to say, I find it quite functional even at this stage. NB:
Hi @tferr, the code may have changed significantly. Would appreciate if you could revise your commits and see which can be applied. The branch I pushed forward is "fix-autocompletion-listener".
And @haesleinhuepf: notice I've had to change the AutoCompletionListener interface significantly. Please have a look, should be straightforward to adapt for CLIJ to insert expansions for commonly used variable names.
@acardona, to include JavaDoc URLs and list types in the completions, I would have to modify DotAutoCompletions#get() to return both the completion String and the completion description (also a String). Are you OK with it?
Hi @tferr, sounds good, should then return a new object that has both as fields rather than just a String.
By the way @tferr, when done, after review/test, I'd appreciate very much if you could release it all: the jython-autocompletion and the script-editor, so that it all appears in the Fiji updater.
@acardona, sincere apologies for the delay. 'Real work' got in the way. I think I have it working, but still need to test it more seriously. Hyperlinks seem to be working, and the completion lists the type for both fields and methods. If there are no major issues I will push and release tonight.
There are still some (minor) issues like the .acess$000
entry below, but we can always tackle this at a later time point), otherwise it will never be ready
Sounds great! On the subclasses: a one-liner filtering for dollar signs '$', indicative of subclasses, would do, at the level of the returned stream or list of autocompletions.
@acardona, I don't seem to have write access to this repository. Could you please merge this AND release version 5.0.10 of the script editor? Otherwise, give me write permissions and I will do so. Thanks!
@acardona , @haesleinhuepf , This implements the following changes by extending Albert's recent work: