From a121eacdb3c735c15f3d479f1b65b50de45f7006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Urba=C5=84ski?= Date: Sun, 10 May 2020 19:02:57 +0200 Subject: [PATCH] Added warnings when frame is used, added link to new version's Changes wiki --- app/src/processing/app/ui/Editor.java | 6 ++++++ build/shared/lib/languages/PDE.properties | 1 + .../java/CompileErrorMessageSimplifier.java | 8 +++++++- java/src/processing/mode/java/Compiler.java | 18 +++++++++++++++--- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/app/src/processing/app/ui/Editor.java b/app/src/processing/app/ui/Editor.java index 832be571b7..500ff20cee 100644 --- a/app/src/processing/app/ui/Editor.java +++ b/app/src/processing/app/ui/Editor.java @@ -1310,6 +1310,12 @@ static public void showChanges() { } } + static public void showChangesV4() { + if (!Base.isCommandLine()) { + Platform.openURL("https://github.com/processing/processing4/wiki/Changes-in-4.0"); + } + } + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . diff --git a/build/shared/lib/languages/PDE.properties b/build/shared/lib/languages/PDE.properties index 410e74e352..b9a90c97c5 100644 --- a/build/shared/lib/languages/PDE.properties +++ b/build/shared/lib/languages/PDE.properties @@ -398,6 +398,7 @@ editor.status.undef_global_var = The global variable "%s" does not exist editor.status.undef_class = The class "%s" does not exist editor.status.undef_var = The variable "%s" does not exist editor.status.undef_name = The name "%s" cannot be recognized +editor.status.item_removed = "%s" was removed in this version, please use "%s" instead. editor.status.unterm_string_curly = String literal is not closed by a straight double quote. Curly quotes like %s won't help. editor.status.type_mismatch = Type mismatch, "%s" does not match with "%s" editor.status.unused_variable = The value of the local variable "%s" is not used diff --git a/java/src/processing/mode/java/CompileErrorMessageSimplifier.java b/java/src/processing/mode/java/CompileErrorMessageSimplifier.java index 87d5c8038c..c5bac678c4 100644 --- a/java/src/processing/mode/java/CompileErrorMessageSimplifier.java +++ b/java/src/processing/mode/java/CompileErrorMessageSimplifier.java @@ -242,7 +242,13 @@ public static String getSimplifiedErrorMessage(IProblem iprob, String badCode) { case IProblem.UndefinedName: if (args.length > 0) { - result = Language.interpolate("editor.status.undef_name", args[0]); + final String undefinedName = args[0]; + if (undefinedName.equals("frame")) { + result = Language.interpolate("editor.status.item_removed", undefinedName, "surface"); + } + else { + result = Language.interpolate("editor.status.undef_name", undefinedName); + } } break; diff --git a/java/src/processing/mode/java/Compiler.java b/java/src/processing/mode/java/Compiler.java index dac5f5bdc5..2cd34b3fd5 100644 --- a/java/src/processing/mode/java/Compiler.java +++ b/java/src/processing/mode/java/Compiler.java @@ -247,6 +247,9 @@ public void close() { } "displayWidth and displayHeight."); handleCrustyCode(); + } else if (what.equals("frame")) { + exception.setMessage("frame was removed, use surface instead."); + handleCrustyCodeV4(); } else { exception.setMessage("Cannot find anything " + "named \u201C" + what + "\u201D"); @@ -316,14 +319,23 @@ public void close() { } return success; } + static protected void printCrustyCodeMessage() { + System.err.println("This code needs to be updated " + + "for this version of Processing, " + + "please read the Changes page on the Wiki."); + } static protected void handleCrustyCode() { - System.err.println("This code needs to be updated " + - "for this version of Processing, " + - "please read the Changes page on the Wiki."); + printCrustyCodeMessage(); Editor.showChanges(); } + static protected void handleCrustyCodeV4() { + printCrustyCodeMessage(); + // maybe put here an auto-fix prompt + Editor.showChangesV4(); + } + protected int caretColumn(String caretLine) { return caretLine.indexOf("^");