GeezerVison is showing github.com — Autocompletion of imports, class names, and static fields and methods after a classname by acardona · Pull Request #47 · scijava/script-editor
Conversation
acardona
commented
Nov 19, 2020
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
In any language, even in no language (for now), type and press control+space:
- "from ij ": expands possible packages and subpackages.
- "from ij.gui ": inserts "import " and expands possible classes (notice the white space after "gui")
- "ImageP": expands to e.g. ImagePlus
- "ImagePlus.": expands static fields and methods, case independent.
- "ImagePlus.C": expands matching static fields and methods such as COLOR_RGB.
- "importClass(Package.": expands to all available package + class name.
- "importClass(Package.
This code builds on ClassUtil (the helper class aiming at fixing the "Open help for Class..." which is preliminary implemented as "Source or javadoc for class or package...", see #46 ).
This pull request is merely a point of discussion and exploration.
NOTE that it will take a few seconds before the autocompletion with control+space starts working: your system will be busy collecting class names from all jar files in Fiji.
There are some known issues:
- For some reason, when there are commas in an import, like:
"from ij import IJ, ImagePl"
... fails to recognize that this is the importStatement pattern, even though when tested separately in jython it works. May have to do with different number of backslashes for escaping characters.
- The "import ij" doesn't expand to e.g. "import ij.gui.PointRoi", rather, the list of classes is beyond the "ij" package and the replacement text removes the "ij" altogether.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
haesleinhuepf reacted with heart emoji
This can happen when using a networked account across different computers
or with different monitors.
and collect info and URLs from their pom.xml
fixes or replaces the "Open Help" menu item, by using ClassUtils and
showing a UI that lists all matching classes with buttons to open their
source code in github or gitlab and the javadoc when available
(will guess the URL, load it, and not show a link to it when 404).
Can match partial text (the list of possible classes may be longer)
and can also match package names or partial package names. Any substring
of a fully qualified class name will be matched, which is fabulous.
(Compare with current implementatio nof "Open Help..." which requires
a fully qualified class name to work, which is not useful as often
one does not know it or not have it handy in a script.)
of package suffixes comes from java 8.
for a name that matches a subURL of javadoc.scijava.org
…ckage
and fields and methods of imported classes.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Hi @ctrueden,
I understand that, given the scijava umbrella, you'd prefer the autocompletion to be implemented independently for each language via their org.scijava.script.ScriptLanguage, which seems to have method handles for that.
Was there any autocompletion already implemented for any language?
If so, can these already be triggered from the Script Editor EditorPane, which is an RSyntaxTextArea?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
class names on any substring rather than only the beginning.
…lass name,
not just the beginning.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
imagejan
commented
Nov 28, 2020
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
@acardona wrote:
Was there any autocompletion already implemented for any language?
Yes, @haesleinhuepf implemented auto-completion for the IJ1 Macro language, which ships by default with imagej-lecagy, and also for Groovy (and others?), these latter ones only ship via the CLIJ update sites however (right?).
EDIT:
see also #41 (which is very minimal and functionally limited).
|
haesleinhuepf reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
acardona
commented
Nov 29, 2020
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
This branch is now ready to merge, implementing java class autocompletion, static method autocompletion, and automatic import insertion for jython scripts.
In addition, includes previous fixes for constraining dimensions of the Script Editor window to within the screen (to e.g. avoid seg faults in virtual desktops), and also a new menu item to open source or javadoc for a selected class or package.
Ideally, this branch would be merged and released immediately for use in the I2K conference starting tomorrow. My own tutorial is on December 1st, 2020 at UTC 21:00, and we'll make heavy use of jython scripting using java classes.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|