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

Warn users or provide auto-fix when frame is used in a sketch #99

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/src/processing/app/ui/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,12 @@ static public void showChanges() {
}
}

static public void showChangesV4() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this @urbanskimichal! What are your thoughts on replacing showChanges outright?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually how about doing a showChangesV3 and showChangesV4 (same for handleCrustyCode). See urbanskimichal#2.

if (!Base.isCommandLine()) {
Platform.openURL("https://github.com/processing/processing4/wiki/Changes-in-4.0");
}
}


// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Expand Down
1 change: 1 addition & 0 deletions build/shared/lib/languages/PDE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Copy link
Collaborator

@sampottinger sampottinger Jun 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor request... I think we have been doing } else {

else {
result = Language.interpolate("editor.status.undef_name", undefinedName);
}
}
break;

Expand Down
18 changes: 15 additions & 3 deletions java/src/processing/mode/java/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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("^");
Expand Down