diff --git a/java/src/processing/mode/java/preproc/PdeParseTreeListener.java b/java/src/processing/mode/java/preproc/PdeParseTreeListener.java index d774b6e92..f2953b284 100644 --- a/java/src/processing/mode/java/preproc/PdeParseTreeListener.java +++ b/java/src/processing/mode/java/preproc/PdeParseTreeListener.java @@ -566,7 +566,7 @@ public void exitMethodDeclaration(ProcessingParser.MethodDeclarationContext ctx) int numChildren = possibleModifiers.getChildCount(); - ParserRuleContext annoationPoint = null; + ParserRuleContext annotationPoint = null; for (int i = 0; i < numChildren; i++) { boolean childIsVisibility; @@ -582,16 +582,16 @@ public void exitMethodDeclaration(ProcessingParser.MethodDeclarationContext ctx) boolean isModifier = child instanceof ProcessingParser.ModifierContext; if (isModifier && isAnnotation((ProcessingParser.ModifierContext) child)) { - annoationPoint = (ParserRuleContext) child; + annotationPoint = (ParserRuleContext) child; } } // Insert at start of method or after annoation if (!hasVisibilityModifier) { - if (annoationPoint == null) { + if (annotationPoint == null) { insertBefore(possibleModifiers.getStart(), "public "); } else { - insertAfter(annoationPoint.getStop(), "public "); + insertAfter(annotationPoint.getStop(), " public "); } } diff --git a/java/test/processing/mode/java/ParserTests.java b/java/test/processing/mode/java/ParserTests.java index 9a1a2c753..040600228 100644 --- a/java/test/processing/mode/java/ParserTests.java +++ b/java/test/processing/mode/java/ParserTests.java @@ -318,6 +318,11 @@ public void annotations() { expectGood("annotations", true); } + @Test + public void staticannotations() { + expectGood("staticannotations", true); + } + @Test public void generics() { expectGood("generics", true); diff --git a/java/test/resources/staticannotations.expected b/java/test/resources/staticannotations.expected new file mode 100644 index 000000000..2b651f2b4 --- /dev/null +++ b/java/test/resources/staticannotations.expected @@ -0,0 +1,65 @@ +import processing.core.*; +import processing.data.*; +import processing.event.*; +import processing.opengl.*; + +import java.util.HashMap; +import java.util.ArrayList; +import java.io.File; +import java.io.BufferedReader; +import java.io.PrintWriter; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.IOException; + +public class staticannotations extends PApplet { + + public void setup() { + +class Button { + + int x, y, radius; + + public Button (int x, int y, int radius) { + this.x = x; + this.y = y; + this.radius = radius; + } + + public boolean over() { + return dist(mouseX, mouseY, this.x, this.y) < this.radius; + } + + public void draw() { + ellipse(this.x, this.y, this.radius * 2, this.radius * 2); + } + + @Deprecated + public void old() { + ellipse(this.x, this.y, this.radius, this.radius); + } + +} + + +class ButtonOther extends Button { + + @Override + public boolean over() { + return dist(mouseX, mouseY, this.x, this.y) < this.radius / 2; + } + +} + + noLoop(); + } + + static public void main(String[] passedArgs) { + String[] appletArgs = new String[] { "staticannotations" }; + if (passedArgs != null) { + PApplet.main(concat(appletArgs, passedArgs)); + } else { + PApplet.main(appletArgs); + } + } +} \ No newline at end of file diff --git a/java/test/resources/staticannotations.pde b/java/test/resources/staticannotations.pde new file mode 100644 index 000000000..db5089042 --- /dev/null +++ b/java/test/resources/staticannotations.pde @@ -0,0 +1,34 @@ +class Button { + + int x, y, radius; + + public Button (int x, int y, int radius) { + this.x = x; + this.y = y; + this.radius = radius; + } + + boolean over() { + return dist(mouseX, mouseY, this.x, this.y) < this.radius; + } + + void draw() { + ellipse(this.x, this.y, this.radius * 2, this.radius * 2); + } + + @Deprecated + void old() { + ellipse(this.x, this.y, this.radius, this.radius); + } + +} + + +class ButtonOther extends Button { + + @Override + boolean over() { + return dist(mouseX, mouseY, this.x, this.y) < this.radius / 2; + } + +}