From 17aa235c6bb8ac989ea0cd7483fe28dfa1efdd3f Mon Sep 17 00:00:00 2001 From: A Pottinger Date: Sat, 21 Nov 2020 12:34:07 -0800 Subject: [PATCH] Allow ill advised but legal overridding of size, smooth, etc. --- build/shared/lib/languages/PDE.properties | 2 - .../java/preproc/PdeParseTreeListener.java | 40 +++++++------------ 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/build/shared/lib/languages/PDE.properties b/build/shared/lib/languages/PDE.properties index a4dc37d2b..b81fcd11e 100644 --- a/build/shared/lib/languages/PDE.properties +++ b/build/shared/lib/languages/PDE.properties @@ -410,8 +410,6 @@ editor.status.bad.generic = Possibly missing type in generic near '%s'? editor.status.bad.identifier = Bad identifier? Did you forget a variable or start an identifier with digits near '%s'? editor.status.bad.parameter = Error on parameter or method declaration near '%s'? editor.status.bad.import = Import not allowed here. -editor.status.bad.size = Too many arguments to size. -editor.status.bad.smooth = Too many arguments to smooth. editor.status.extraneous = Incomplete statement or extra code near '%s'? editor.status.mismatched = Missing operator, semicolon, or '}' near '%s'? editor.status.missing.name = Missing name or ; near '%s'? diff --git a/java/src/processing/mode/java/preproc/PdeParseTreeListener.java b/java/src/processing/mode/java/preproc/PdeParseTreeListener.java index 314d7b0c2..f1520c43e 100644 --- a/java/src/processing/mode/java/preproc/PdeParseTreeListener.java +++ b/java/src/processing/mode/java/preproc/PdeParseTreeListener.java @@ -630,17 +630,7 @@ public class PdeParseTreeListener extends ProcessingBaseListener { } if (argsContext.getChildCount() > 7) { - pdeParseTreeErrorListenerMaybe.ifPresent((listener) -> { - Token token = ctx.getStart(); - int line = token.getLine(); - int charOffset = token.getCharPositionInLine(); - - listener.onError(new PdePreprocessIssue( - line, - charOffset, - PreprocessIssueMessageSimplifier.getLocalStr("editor.status.bad.size") - )); - }); + thisRequiresRewrite = false; // Uesr may have overloaded size. } } @@ -670,7 +660,12 @@ public class PdeParseTreeListener extends ProcessingBaseListener { } ParseTree argsContext = ctx.getChild(2); + if (argsContext.getChildCount() == 0 || argsContext.getChildCount() > 3) { + return; // User override of pixel density. + } + pixelDensity = argsContext.getChild(0).getText(); + delete(ctx.start, ctx.stop); insertAfter(ctx.stop, "/* pixelDensity commented out by preprocessor */"); pixelDensityRequiresRewrite = true; @@ -682,6 +677,11 @@ public class PdeParseTreeListener extends ProcessingBaseListener { return; } + ParseTree argsContext = ctx.getChild(2); + if (argsContext.getChildCount() > 0) { + return; // User override of noSmooth. + } + delete(ctx.start, ctx.stop); insertAfter(ctx.stop, "/* noSmooth commented out by preprocessor */"); noSmoothRequiresRewrite = true; @@ -694,26 +694,16 @@ public class PdeParseTreeListener extends ProcessingBaseListener { } ParseTree argsContext = ctx.getChild(2); + if (argsContext.getChildCount() > 2) { + return; // User may have overloaded smooth; + } + if (argsContext.getChildCount() > 0) { smoothParam = argsContext.getChild(0).getText(); } else { smoothParam = ""; } - if (argsContext.getChildCount() > 2) { - pdeParseTreeErrorListenerMaybe.ifPresent((listener) -> { - Token token = ctx.getStart(); - int line = token.getLine(); - int charOffset = token.getCharPositionInLine(); - - listener.onError(new PdePreprocessIssue( - line, - charOffset, - PreprocessIssueMessageSimplifier.getLocalStr("editor.status.bad.smooth") - )); - }); - } - delete(ctx.start, ctx.stop); insertAfter(ctx.stop, "/* smooth commented out by preprocessor */"); smoothRequiresRewrite = true;