From 1345f77f93e8ec4dd0be4a272b69a4e1ee09334f Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Fri, 30 Oct 2015 03:03:58 +0100 Subject: [PATCH 1/5] Workaround for JRE bug freezing the PDE Because of a JRE bug, code completion will occasionally freeze the PDE. Never seen this one before, however, it happened to me three times in a row while I was giving a lecture today and I had to kill the PDE and write all the code again. I can reproduce it back to beta 7. It is caused by JIT compiler, workaround is to disable it for this particular method. See https://bugs.openjdk.java.net/browse/JDK-8060036 and http://kingsfleet.blogspot.com.br/2014/11/but-thats-impossible-or-finding-out.html --- build/windows/config.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/windows/config.xml b/build/windows/config.xml index 90c290121..cca6bebb6 100644 --- a/build/windows/config.xml +++ b/build/windows/config.xml @@ -43,6 +43,10 @@ -Djna.nounpack=true 1.8.0_51 + + -XX:CompileCommand=exclude,javax/swing/text/GlyphView,getBreakSpot 256 From a1eb3473380dbb49586a8482640e8d6dd7440eb7 Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Fri, 30 Oct 2015 03:27:08 +0100 Subject: [PATCH 2/5] Make CompletionCandidate immutable This one goes from ASTGenerator on a background thread to the JList which displays code suggestions. Until refactored, I'm making it immutable with convenience methods returning mutated copies to prevent possible threading issues. --- .../mode/java/pdex/ASTGenerator.java | 22 +++++----- .../mode/java/pdex/CompletionCandidate.java | 42 ++++++++++++------- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/java/src/processing/mode/java/pdex/ASTGenerator.java b/java/src/processing/mode/java/pdex/ASTGenerator.java index 5368765e6..bc2bdef70 100644 --- a/java/src/processing/mode/java/pdex/ASTGenerator.java +++ b/java/src/processing/mode/java/pdex/ASTGenerator.java @@ -1015,9 +1015,10 @@ public class ASTGenerator { if (candidates.get(0).getElementName() .equals(candidates.get(candidates.size() - 1).getElementName())) { log("All CC are methods only: " + candidates.get(0).getElementName()); - for (CompletionCandidate candidate : candidates) { - candidate.regenerateCompletionString(); - defListModel.addElement(candidate); + for (int i = 0; i < candidates.size(); i++) { + CompletionCandidate cc = candidates.get(i).withRegeneratedCompString(); + candidates.set(i, cc); + defListModel.addElement(cc); } } else { @@ -1030,14 +1031,15 @@ public class ASTGenerator { CompletionCandidate cc = candidates.get(i - 1); String label = cc.getLabel(); int x = label.lastIndexOf(')'); - if(candidates.get(i).getType() == CompletionCandidate.PREDEF_METHOD) { - cc.setLabel((cc.getLabel().contains("") ? "" : "") - + cc.getElementName() + "(...)" + label.substring(x + 1)); + String newLabel; + if (candidates.get(i).getType() == CompletionCandidate.PREDEF_METHOD) { + newLabel = (cc.getLabel().contains("") ? "" : "") + + cc.getElementName() + "(...)" + label.substring(x + 1); + } else { + newLabel = cc.getElementName() + "(...)" + label.substring(x + 1); } - else { - cc.setLabel(cc.getElementName() + "(...)" + label.substring(x + 1)); - } - cc.setCompletionString(cc.getElementName() + "("); + String newCompString = cc.getElementName() + "("; + candidates.set(i - 1, cc.withLabelAndCompString(newLabel, newCompString)); ignoredSome = true; continue; } diff --git a/java/src/processing/mode/java/pdex/CompletionCandidate.java b/java/src/processing/mode/java/pdex/CompletionCandidate.java index 2a9d9f936..ca48ab15d 100644 --- a/java/src/processing/mode/java/pdex/CompletionCandidate.java +++ b/java/src/processing/mode/java/pdex/CompletionCandidate.java @@ -33,11 +33,11 @@ import org.eclipse.jdt.core.dom.VariableDeclarationFragment; public class CompletionCandidate implements Comparable{ - private String elementName; - private String label; // the toString value - private String completionString; - private Object wrappedObject; - private int type; + private final String elementName; + private final String label; // the toString value + private final String completionString; + private final Object wrappedObject; + private final int type; static final int PREDEF_CLASS = 0; static final int PREDEF_FIELD = 1; @@ -158,6 +158,7 @@ public class CompletionCandidate implements Comparable{ label = labelStr; completionString = completionStr; this.type = type; + wrappedObject = null; } public CompletionCandidate(String name, int type) { @@ -165,6 +166,17 @@ public class CompletionCandidate implements Comparable{ label = name; completionString = name; this.type = type; + wrappedObject = null; + } + + private CompletionCandidate(String elementName, String label, + String completionString, int type, + Object wrappedObject) { + this.elementName = elementName; + this.label = label; + this.completionString = completionString; + this.type = type; + this.wrappedObject = wrappedObject; } public String getElementName() { @@ -204,14 +216,13 @@ public class CompletionCandidate implements Comparable{ } } - public void setLabel(String label) { - this.label = label; - } - - public void setCompletionString(String completionString) { - this.completionString = completionString; + public CompletionCandidate withLabelAndCompString(String label, + String completionString) { + return new CompletionCandidate(this.elementName, label, completionString, + this.type, this.wrappedObject); } + @Override public int compareTo(CompletionCandidate cc) { if(type != cc.getType()){ return cc.getType() - type; @@ -219,7 +230,7 @@ public class CompletionCandidate implements Comparable{ return (elementName.compareTo(cc.getElementName())); } - public void regenerateCompletionString(){ + public CompletionCandidate withRegeneratedCompString() { if (wrappedObject instanceof MethodDeclaration) { MethodDeclaration method = (MethodDeclaration)wrappedObject; @@ -243,8 +254,7 @@ public class CompletionCandidate implements Comparable{ if (method.getReturnType2() != null) label.append(" : " + method.getReturnType2()); cstr.append(")"); - this.label = label.toString(); - this.completionString = cstr.toString(); + return this.withLabelAndCompString(label.toString(), cstr.toString()); } else if (wrappedObject instanceof Method) { Method method = (Method)wrappedObject; @@ -265,8 +275,7 @@ public class CompletionCandidate implements Comparable{ label.append(" : " + method.getReturnType().getSimpleName()); label.append(" - " + method.getDeclaringClass().getSimpleName() + ""); cstr.append(")"); - this.label = label.toString(); - this.completionString = cstr.toString(); + return this.withLabelAndCompString(label.toString(), cstr.toString()); /* * StringBuilder label = new StringBuilder(""+method.getName() + "("); StringBuilder cstr = new StringBuilder(method.getName() + "("); @@ -286,6 +295,7 @@ public class CompletionCandidate implements Comparable{ label.append(" - " + method.getDeclaringClass().getSimpleName() + ""); * */ } + return this; } } From c3222348e1148ad7a6aaba39a1b9004c1ac7090e Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Fri, 30 Oct 2015 03:30:37 +0100 Subject: [PATCH 3/5] Styling --- build/windows/config.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/windows/config.xml b/build/windows/config.xml index cca6bebb6..8add550ee 100644 --- a/build/windows/config.xml +++ b/build/windows/config.xml @@ -43,10 +43,10 @@ -Djna.nounpack=true 1.8.0_51 - - -XX:CompileCommand=exclude,javax/swing/text/GlyphView,getBreakSpot + + -XX:CompileCommand=exclude,javax/swing/text/GlyphView,getBreakSpot 256 From 25b1db8ef0a1cb56c85d0dcf0e0655d49201419e Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Fri, 1 Jan 2016 22:29:30 +0100 Subject: [PATCH 4/5] Initialize sketch args before calling settings() --- core/src/processing/core/PApplet.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 88ef59d16..a60718a3e 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -10231,6 +10231,13 @@ public class PApplet implements PConstants { // } sketch.sketchPath = folder; + // Don't set 'args' to a zero-length array if it should be null [3.0a8] + if (args.length != argIndex + 1) { + // pass everything after the class name in as args to the sketch itself + // (fixed for 2.0a5, this was just subsetting by 1, which didn't skip opts) + sketch.args = PApplet.subset(args, argIndex + 1); + } + // Call the settings() method which will give us our size() call // try { sketch.handleSettings(); @@ -10252,13 +10259,6 @@ public class PApplet implements PConstants { // //fullScreen |= sketch.sketchFullScreen(); // sketch.fullScreen |= fullScreen; - // Don't set 'args' to a zero-length array if it should be null [3.0a8] - if (args.length != argIndex + 1) { - // pass everything after the class name in as args to the sketch itself - // (fixed for 2.0a5, this was just subsetting by 1, which didn't skip opts) - sketch.args = PApplet.subset(args, argIndex + 1); - } - sketch.external = external; if (windowColor != 0) { From d519490186c0324f92c96ee71b9a3188f88f7b6a Mon Sep 17 00:00:00 2001 From: GABBAR1947 Date: Sun, 31 Jan 2016 18:11:32 +0530 Subject: [PATCH 5/5] whitespaces removed --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1c3e154ec..9302220f9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Processing ========== This is the official source code for the [Processing](http://processing.org) Development Environment (PDE), -the “core” and the libraries that are included with the [download](http://processing.org/download). +the “core” and the libraries that are included with the [download](http://processing.org/download). __I've found a bug!__ Let us know [here](https://github.com/processing/processing/issues) (after first checking if someone has already posted a similar problem). @@ -22,7 +22,7 @@ The instructions for building the source [are here](https://github.com/processin Please help us fix problems, and if you're submitting code, following the [style guidelines](https://github.com/processing/processing/wiki/Style-Guidelines) helps save us a lot of time. __And finally...__ -Someday we'll also fix all these bugs, throw together hundreds of unit tests, and get rich off all this stuff that we're giving away for free. But not today. +Someday we'll also fix all these bugs, throw together hundreds of unit tests, and get rich off all this stuff that we're giving away for free. But not today. So in the meantime, I ask for your patience, [participation](https://github.com/processing/processing/wiki/Project-List),