Skip to content
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

Autocomplete methods and functions #220

Merged
merged 7 commits into from
Oct 8, 2019

Conversation

haesleinhuepf
Copy link
Member

@haesleinhuepf haesleinhuepf commented Aug 19, 2019

Hey all, hey @imagejan, hey @ctrueden,

I'm testing the autocompletion of variable names and functions+comments for some time. Also users on the forum seemed to be pretty happy about it.
https://forum.image.sc/t/auto-code-completion-for-ij-macro/11642/95

Do you see any issues? Shall we merge it? Thanks!

Cheers,
Robert

haesleinhuepf added 2 commits July 16, 2019 11:32
* underscores allowed in function names
* upper/lower case enabled
* put macro-dependent stuff first
* sorted it alphabetically
@ctrueden
Copy link
Member

Thanks, @haesleinhuepf. I'd like to dig in to the Travis CI failure. The issue is probably with explicit ImageJ1 class references. I am considering how best to deal with it. We could whitelist the class net.imagej.legacy.plugin.MacroAutoCompletionProvider, or we could tweak it not to use a direct reference to the IJ1 Interpreter. I am also considering whether it might be better to split the IJ1 macro language plugin to a separate component from the base imagej-legacy layer.

@haesleinhuepf
Copy link
Member Author

Hey @ctrueden

are there any news regarding the CI?

I added some more updates and new content to the auto-completion. For example @imagejan may like this one:
image

Thanks for your support!

Cheers,
Robert

@ctrueden ctrueden force-pushed the autocomplete_methods_and_functions branch from ed5d5eb to da5ffb5 Compare October 8, 2019 21:56
@ctrueden
Copy link
Member

ctrueden commented Oct 8, 2019

I force-pushed a change that I hope will fix it.

@ctrueden
Copy link
Member

ctrueden commented Oct 8, 2019

Here is the patch that I squashed in:

diff --git src/main/java/net/imagej/legacy/IJ1Helper.java src/main/java/net/imagej/legacy/IJ1Helper.java
index 41ee03b..4919c4e 100644
--- src/main/java/net/imagej/legacy/IJ1Helper.java
+++ src/main/java/net/imagej/legacy/IJ1Helper.java
@@ -598,6 +598,11 @@ public class IJ1Helper extends AbstractContextual {
                return Interpreter.getInstance();
        }

+       /** Gets the result of {@link Interpreter#getAdditionalFunctions()}. */
+       public static String getAdditionalMacroFunctions() {
+               return Interpreter.getAdditionalFunctions();
+       }
+
        /**
         * Gets the value of the specified variable, from the given macro
         * {@link Interpreter}.
diff --git src/main/java/net/imagej/legacy/plugin/MacroAutoCompletionProvider.java src/main/java/net/imagej/legacy/plugin/MacroAutoCompletionProvider.java
index 760d3c5..4ee4ff2 100644
--- src/main/java/net/imagej/legacy/plugin/MacroAutoCompletionProvider.java
+++ src/main/java/net/imagej/legacy/plugin/MacroAutoCompletionProvider.java
@@ -42,14 +42,14 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;

-import ij.macro.Interpreter;
+import net.imagej.legacy.IJ1Helper;
+
 import org.fife.ui.autocomplete.BasicCompletion;
 import org.fife.ui.autocomplete.Completion;
 import org.fife.ui.autocomplete.DefaultCompletionProvider;
 import org.fife.ui.autocomplete.SortByRelevanceComparator;
 import org.fife.ui.rtextarea.RTextArea;
 import org.fife.ui.rtextarea.ToolTipSupplier;
-
 import org.scijava.module.ModuleInfo;
 import org.scijava.module.ModuleService;

@@ -324,7 +324,7 @@ class MacroAutoCompletionProvider extends DefaultCompletionProvider implements
                        e.printStackTrace();
                        return;
                }
-               text = text + "\n" + Interpreter.getAdditionalFunctions();
+               text = text + "\n" + IJ1Helper.getAdditionalMacroFunctions();

                int linecount = 0;
                String[] textArray = text.split("\n");

@ctrueden ctrueden merged commit d7a48e4 into master Oct 8, 2019
@ctrueden ctrueden deleted the autocomplete_methods_and_functions branch October 8, 2019 22:02
@ctrueden
Copy link
Member

ctrueden commented Oct 8, 2019

The CI passed, so I merged it.

@haesleinhuepf
Copy link
Member Author

Great, thanks @ctrueden ! 😍

ndefrancesco added a commit to ndefrancesco/imagej-legacy that referenced this pull request Dec 13, 2019
Solves issue imagej#232 which affected functions pulled from the doc html files.
The behaviour seems to have been inadvertedly introduced in merge imagej#220.
ndefrancesco added a commit to ndefrancesco/imagej-legacy that referenced this pull request Mar 12, 2020
Solves issue imagej#232 which affected functions pulled from the doc html files.
The behaviour seems to have been inadvertedly introduced in merge imagej#220.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants