-
Notifications
You must be signed in to change notification settings - Fork 54
Add autocompletion framework #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@ctrueden let me know what do you think. Even if autocompletion is not implemented yet in the scripting languages, it's fine since all the changes are backward compatible. |
7b900a5 to
1e3ba36
Compare
|
Great, this is something I've been wanting to add to the SciJava script framework. (The other major missing thing is a "script recorder" type feature, which given a SciJava module execution, generates the line of code needed to reproduce it in that script language.) I will try to find time to review the details later this week. Ping me again if I'm holding you up. |
|
I don't think I'll have time to implement autocompletion for scripting languages any time soon (need at least another free weekend :-)) but as I said this PR should hold the main foundation of autocompletion. So feel free to merge after reviewing it. I'll ping you here at the end of this weekend :-) |
|
Also once it's done that work could be used in the Scijava TextEditor :-D |
|
Just for reference: Icy has a nice auto-completion here: It was discussed shortly at NEUBIAS2017 and suggested by @ctrueden that this could be ported into https://github.com/scijava/script-editor It didn't look deep into this code, but maybe we could still profit from their implementations for JS and Python... |
7b82a48 to
c099152
Compare
|
Well, I am surprised to see how easy it was to implement a first "naive" working autocompletion ! That implementation should provide autocompletion for all the scripting languages. I am pretty happy with that for now. The framework should provide an easy way to extend autocompletion being language specific or not. About the architecture, I am sure it can be improved (I did my best but IJ coding standard are pretty high ! (which is a good thing)). So I am waiting for @ctrueden comments about that :-) |
|
|
||
| @Override | ||
| public AutoCompleter getAutoCompleter(ScriptEngine scriptEngine) { | ||
| return new DefaultAutoCompleter(this, scriptEngine); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This override is unnecessary, no? Because AbstractScriptLanguage already defines this same logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Netbeans does not agree with you (only a warning). Should I just remove it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird. What is the warning? The whole point of having methods implemented in the abstract base class is so that you don't have to implement them that same way in the subclass. NetBeans warning about that does not make sense...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's saying Add @Override Annotation. Note that the other methods above have @Override
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, @ctrueden means you can leave away the whole method, not just the annotation, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, just delete the whole overridden method. Lines 291 through 294.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok !
|
|
||
| @Override | ||
| public AutoCompleter getAutoCompleter(ScriptEngine scriptEngine) { | ||
| return new DefaultAutoCompleter(this, scriptEngine); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This override is unnecessary, no? Because AbstractScriptLanguage already defines this same logic?
|
|
||
| @Override | ||
| public AutoCompleter getAutoCompleter(ScriptEngine scriptEngine) { | ||
| return new DefaultAutoCompleter(this, scriptEngine); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This override is unnecessary, no? Because AbstractScriptLanguage already defines this same logic?
| @Test | ||
| public void testMenuCreation() { | ||
| menuService.getMenu(); | ||
| //menuService.getMenu(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs more explanation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why this test was failing. This is not the case anymore. I'll fix that.
|
|
||
| @Override | ||
| public ScriptLanguage getScriptLanguage() { | ||
| return this.scriptLanguage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing actually uses this field in the base layer... do you use it in downstream implementations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. I'll remove it.
|
|
||
| @Override | ||
| public ScriptEngine getScriptEngine() { | ||
| return this.scriptEngine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternately, the autocompleter could be kept stateless, with the ScriptEngine instance being passed as another argument to the autocomplete methods. Which do you like better? (I don't feel super strongly; just pointing it out.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point here and I like the idea. That will make the class less complicated.
|
|
||
| @Override | ||
| public AutoCompleter getAutoCompleter(ScriptEngine scriptEngine) { | ||
| return new DefaultAutoCompleter(this, scriptEngine); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we have Java 8, this could be a default method of ScriptLanguage interface itself, rather than in the abstract base class. That would potentially be "more backwards compatible", just in case anyone out there has implemented the ScriptLanguage interface directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do that.
|
I made some comments. The only real concern I have is that failing test... otherwise, all looks great. We should decide once and for all if |
|
Relating to @imagejan's comments about Icy's autocompletion: one thing that Icy does is that it gives special priority to the Icy-specific classes. So you end up getting completions that are relevant to the context of Icy plugin development. The current framework is very general, which is good, but I'm wondering what the best way forward is to make it possible to give contextual hints like that, but in an extensible way. (Icy just hardcodes everything.) One option would be to have some kind of new plugin type that identifies high-priority completions. It would be nice if it were not language-specific either, but rather a layer which operates sort of orthogonally with the actual completion strings. Maybe something as simple as "with such-and-such prefix, which classes make sense to autocomplete?" That will be the same across all script languages, and it will allow components to highlight "completion-friendly" classes. All of these thoughts are half-baked, of course, but wanted to jot this down before it's out of my head again. |
5417713 to
9a5aead
Compare
6d541e5 to
e6cb31f
Compare
|
All the comments have been addressed. Feel free to merge this one and we can still extend it later. I think it's good enough to start with. About Icy code, I had a look but I didn't find useful things to steal so I just started from scratch. The framework is simple for now but I definitely want to make something extensible. For example, we could have My last commit implements autocompletion by inspecting attributes/methods of an object (detected if the string ends by |
|
Thank you both for your comments. |
|
Once this has been merged, I'll cut a new release of the kernel, build conda packages and make an announcement on the forum (I'll also need a new |
|
Do you need a new I am currently reworking how status.imagej.net works (actually, it will become |
|
Well, I just need the last |
|
Eventually we need to update the pom-scijava bill of materials to reference the new SciJava Common version. But in the meantime, you can likely override the I just asked because I can merge and release a new SJC soon (will try this weekend if I have time), but getting all my ducks in a row to do the full suite of releases and update pom-scijava to match is a larger endeavor which will take a few more days at least. |
|
Oh, I see. So if you just cut a new release of |
|
Just a note that I haven't forgotten about this. I am planning to clean up and merge this branch soon (within a few days). I have to sort out how to make releases to OSS Sonatype though, now that our Jenkins configuration is hosed up. I want to instead do it from the CLI, without needing Jenkins anymore. Once I have that sorted, I'll try to get this merged, and then cut a new |
|
Cleaned up, fleshed out and merged! |
Add a framework for an autocompletion framework. Each scripting language is free to implement an
AutoCompleterto provide autocompletion.If they don't the default
AdaptedAutoCompleterwill just return no results when an autocompletion is asked.