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

Workaround for JRE bug freezing the PDE #4079

Merged
merged 3 commits into from Feb 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions build/windows/config.xml
Expand Up @@ -43,6 +43,10 @@
<opt>-Djna.nounpack=true</opt>
<!-- starting in 3.0, require Java 8 -->
<minVersion>1.8.0_51</minVersion>
<!-- TODO: remove the line below as soon as we are on 1.8.0_60 or newer,
see https://bugs.openjdk.java.net/browse/JDK-8060036 and
http://kingsfleet.blogspot.com.br/2014/11/but-thats-impossible-or-finding-out.html -->
<opt>-XX:CompileCommand=exclude,javax/swing/text/GlyphView,getBreakSpot</opt>
<!-- increase available per PDE X request -->
<maxHeapSize>256</maxHeapSize>
</jre>
Expand Down
22 changes: 12 additions & 10 deletions java/src/processing/mode/java/pdex/ASTGenerator.java
Expand Up @@ -1015,9 +1015,10 @@ protected static DefaultListModel<CompletionCandidate> filterPredictions(List<Co
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 {
Expand All @@ -1030,14 +1031,15 @@ protected static DefaultListModel<CompletionCandidate> filterPredictions(List<Co
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("<html>") ? "<html>" : "")
+ cc.getElementName() + "(...)" + label.substring(x + 1));
}
else {
cc.setLabel(cc.getElementName() + "(...)" + label.substring(x + 1));
String newLabel;
if (candidates.get(i).getType() == CompletionCandidate.PREDEF_METHOD) {
newLabel = (cc.getLabel().contains("<html>") ? "<html>" : "")
+ cc.getElementName() + "(...)" + label.substring(x + 1);
} else {
newLabel = 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;
}
Expand Down
42 changes: 26 additions & 16 deletions java/src/processing/mode/java/pdex/CompletionCandidate.java
Expand Up @@ -33,11 +33,11 @@


public class CompletionCandidate implements Comparable<CompletionCandidate>{
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;
Expand Down Expand Up @@ -158,13 +158,25 @@ public CompletionCandidate(String name, String labelStr, String completionStr, i
label = labelStr;
completionString = completionStr;
this.type = type;
wrappedObject = null;
}

public CompletionCandidate(String name, int type) {
elementName = name;
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() {
Expand Down Expand Up @@ -204,22 +216,21 @@ public String getNoHtmlLabel(){
}
}

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;
}
return (elementName.compareTo(cc.getElementName()));
}

public void regenerateCompletionString(){
public CompletionCandidate withRegeneratedCompString() {
if (wrappedObject instanceof MethodDeclaration) {
MethodDeclaration method = (MethodDeclaration)wrappedObject;

Expand All @@ -243,8 +254,7 @@ public void regenerateCompletionString(){
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;
Expand All @@ -265,8 +275,7 @@ else if (wrappedObject instanceof Method) {
label.append(" : " + method.getReturnType().getSimpleName());
label.append(" - <font color=#777777>" + method.getDeclaringClass().getSimpleName() + "</font></html>");
cstr.append(")");
this.label = label.toString();
this.completionString = cstr.toString();
return this.withLabelAndCompString(label.toString(), cstr.toString());
/*
* StringBuilder label = new StringBuilder("<html>"+method.getName() + "(");
StringBuilder cstr = new StringBuilder(method.getName() + "(");
Expand All @@ -286,6 +295,7 @@ else if (wrappedObject instanceof Method) {
label.append(" - <font color=#777777>" + method.getDeclaringClass().getSimpleName() + "</font></html>");
* */
}
return this;
}

}