GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@acardona acardona commented Nov 19, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

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:

  1. 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.

  1. 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
All reactions
  • ❤️ 1 reaction
acardona added 10 commits November 14, 2020 01:19
@acardona
Prevent Script Editor window from being larger than the desktop.
7507734
This can happen when using a networked account across different computers
or with different monitors.
@acardona
ClassUtil: inspect all jar files in search of all class names,
0a1b443
and collect info and URLs from their pom.xml
@acardona
Create new menu item "Source or javadoc for class or package..." which
80fd9dd
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.)
@acardona
Ensure the correct java version is used, although the list
5cf2a7a
of package suffixes comes from java 8.
@acardona
ClassUtil: generalize static method findAllClasses so that it an be used
4583ccf
for other directories.
@acardona
If a classname doesn't have any URLS associated with it, then search
3020432
in DuckDuckGo.
@acardona
ClassUtil: search among the multiple words in the repository name
d8b7d32
for a name that matches a subURL of javadoc.scijava.org
@acardona
ClassUtil methods to pattern-match against package and class names.
e1b1f12
@acardona
New class AutocompletionProvider to provide completions for class, pa…
156d16b
…ckage

and fields and methods of imported classes.
@acardona
Enable autocompletion.
c447129
@imagesc-bot

imagesc-bot commented Nov 19, 2020

Copy link
Copy Markdown

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/15

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@acardona

acardona commented Nov 19, 2020

Copy link
Copy Markdown
Collaborator Author

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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

acardona added 5 commits November 20, 2020 15:12
@acardona
New package for autocompletion classes
0e69794
@acardona
New ClassUtil.findClassNamesContaining method, to enable matching
e5ae00c
class names on any substring rather than only the beginning.
@acardona
When autocompleting "import <text>" enable matching anywhere on the c…
a34b8a0
…lass name,

not just the beginning.
@acardona
ClassUtil: handle empty strings for matching.
b1b4c64
@acardona
Autocompletion: enable autocompleting "from" and "import".
4316bc7
@imagesc-bot

imagesc-bot commented Nov 28, 2020

Copy link
Copy Markdown

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/help-wanted-to-understand-the-service-discovery-model-in-scijava/45919/4

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@imagejan

imagejan commented Nov 28, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

@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
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@acardona
acardona force-pushed the autocompletion branch 2 times, most recently from 4e1a665 to cc6e1d6 Compare November 29, 2020 03:03
@acardona
Autocompletion for python (jython) using the LanguageSupportService.
167ab74
@acardona
acardona force-pushed the autocompletion branch from cc6e1d6 to 167ab74 Compare November 29, 2020 03:12
@acardona

acardona commented Nov 29, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@imagesc-bot

imagesc-bot commented Nov 29, 2020

Copy link
Copy Markdown

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/20

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@acardona
acardona merged commit 5a73939 into scijava:master Nov 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

3 participants

@acardona @imagesc-bot @imagejan
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.