mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 05:39:18 +01:00
Merge branch 'main' of github.com:processing/processing4
This commit is contained in:
@@ -566,7 +566,7 @@ public class PdeParseTreeListener extends ProcessingBaseListener {
|
||||
|
||||
int numChildren = possibleModifiers.getChildCount();
|
||||
|
||||
ParserRuleContext annoationPoint = null;
|
||||
ParserRuleContext annotationPoint = null;
|
||||
|
||||
for (int i = 0; i < numChildren; i++) {
|
||||
boolean childIsVisibility;
|
||||
@@ -582,16 +582,16 @@ public class PdeParseTreeListener extends ProcessingBaseListener {
|
||||
|
||||
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 ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -318,6 +318,11 @@ public class ParserTests {
|
||||
expectGood("annotations", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void staticannotations() {
|
||||
expectGood("staticannotations", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generics() {
|
||||
expectGood("generics", true);
|
||||
|
||||
65
java/test/resources/staticannotations.expected
Normal file
65
java/test/resources/staticannotations.expected
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
34
java/test/resources/staticannotations.pde
Normal file
34
java/test/resources/staticannotations.pde
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user