Skip to content

Commit 74fd259

Browse files
committed
Fix ImageJ macro language functionality
The language rename from "IJ1 Macro" to "ImageJ Macro" (imagej/imagej-legacy@a031605) broke the Script Editor's special handling, because internally, the name was being used to check whether the language is the ImageJ macro language. It's unfortunate that this component has any special handling for the Image Macro language whatsoever -- it's supposed to be completely agnostic to specific script languages -- but we are where we are, and this commit fixes the immediate problem. See also: https://forum.image.sc/t/71733
1 parent 5fdd0be commit 74fd259

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

src/main/java/org/scijava/ui/swing/script/EditorPane.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ public void loadPreferences() {
10671067
setTabsEmulated(false);
10681068
setPaintTabLines(false);
10691069
setAutoCompletion(true);
1070-
setKeylessAutoCompletion(true); // true for backwards compatibility with IJ1 macro auto-completion
1070+
setKeylessAutoCompletion(true); // true for backwards compatibility with ImageJ macro auto-completion
10711071
setFallbackAutoCompletion(false);
10721072
setMarkOccurrences(false);
10731073
} else {
@@ -1078,7 +1078,7 @@ public void loadPreferences() {
10781078
setWhitespaceVisible(prefService.getBoolean(getClass(), WHITESPACE_VISIBLE_PREFS, isWhitespaceVisible()));
10791079
setPaintTabLines(prefService.getBoolean(getClass(), TABLINES_VISIBLE_PREFS, getPaintTabLines()));
10801080
setAutoCompletion(prefService.getBoolean(getClass(), AUTOCOMPLETE_PREFS, true));
1081-
setKeylessAutoCompletion(prefService.getBoolean(getClass(), AUTOCOMPLETE_KEYLESS_PREFS, true)); // true for backwards compatibility with IJ1 macro
1081+
setKeylessAutoCompletion(prefService.getBoolean(getClass(), AUTOCOMPLETE_KEYLESS_PREFS, true)); // true for backwards compatibility with ImageJ macro
10821082
setFallbackAutoCompletion(prefService.getBoolean(getClass(), AUTOCOMPLETE_FALLBACK_PREFS, false));
10831083
setMarkOccurrences(prefService.getBoolean(getClass(), MARK_OCCURRENCES_PREFS, false));
10841084
setMarginLineEnabled(prefService.getBoolean(getClass(), MARGIN_VISIBLE_PREFS, false));

src/main/java/org/scijava/ui/swing/script/ErrorParser.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,15 @@ public void parse(final Throwable t) {
151151
parse(sw.toString());
152152
}
153153

154-
private boolean isIJ1Macro() {
154+
private boolean isImageJMacro() {
155155
final ScriptLanguage lang = editorPane.getCurrentLanguage();
156-
return lang != null && "IJ1 Macro".equals(lang.getLanguageName());
156+
if (lang == null) return false;
157+
final String name = lang.getLanguageName();
158+
return name.equals("ImageJ Macro") || name.equals("IJ1 Macro");
157159
}
158160

159161
public boolean isLogDetailed() {
160-
if (!isIJ1Macro()) return parsingSucceeded;
162+
if (!isImageJMacro()) return parsingSucceeded;
161163
for (final Window win : Window.getWindows()) {
162164
if (win != null && win instanceof Dialog && "Macro Error".equals(((Dialog)win).getTitle())) {
163165
return true; // hopefully there is something in the console
@@ -194,7 +196,7 @@ private void parse(final String errorLog) {
194196
abort();
195197
return;
196198
}
197-
final boolean isIJM = isIJ1Macro();
199+
final boolean isIJM = isImageJMacro();
198200
if (isIJM) {
199201
abort("Execution errors handled by the Macro Interpreter. Use the Interpreter's Debug option for error tracking", false);
200202
return;

src/main/java/org/scijava/ui/swing/script/TextEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3767,7 +3767,7 @@ private JMenu helpMenu() {
37673767
menu.add(helpMenuItem("Fiji on GitHub", "https://github.com/fiji"));
37683768
menu.add(helpMenuItem("SciJava on GitHub", "https://github.com/scijava/"));
37693769
menu.addSeparator();
3770-
menu.add(helpMenuItem("IJ1 Macro Functions", "https://imagej.nih.gov/ij/developer/macro/functions.html"));
3770+
menu.add(helpMenuItem("ImageJ Macro Functions", "https://imagej.nih.gov/ij/developer/macro/functions.html"));
37713771
menu.add(helpMenuItem("ImageJ Docs: Development", "https://imagej.net/develop/"));
37723772
menu.add(helpMenuItem("ImageJ Docs: Scripting", "https://imagej.net/scripting/"));
37733773
menu.addSeparator();

src/main/java/org/scijava/ui/swing/script/highliters/IJ1MacroHighlighter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
import org.scijava.ui.swing.script.SyntaxHighlighter;
3434

3535
/**
36-
* SyntaxHighliter for ij1-macros.
36+
* SyntaxHighliter for imagej-macros.
3737
*
3838
* @author Johannes Schindelin
3939
* @author Jonathan Hale
4040
*/
41-
@Plugin(type = SyntaxHighlighter.class, name = "ij1-macro")
41+
@Plugin(type = SyntaxHighlighter.class, name = "imagej-macro")
4242
public class IJ1MacroHighlighter extends ImageJMacroTokenMaker implements
4343
SyntaxHighlighter
4444
{

0 commit comments

Comments
 (0)