From 3c9709886ff86cf3811d042bcbbbc4dc1e7ecd10 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Mon, 19 Aug 2013 20:04:54 +0530 Subject: [PATCH] completion panel type bugfix --- .../mode/experimental/CompletionCandidate.java | 12 +++++++++--- .../mode/experimental/CompletionPanel.java | 7 +++++++ .../mode/experimental/ExperimentalMode.java | 4 +++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/pdex/src/processing/mode/experimental/CompletionCandidate.java b/pdex/src/processing/mode/experimental/CompletionCandidate.java index 5c3761db4..bc2973785 100644 --- a/pdex/src/processing/mode/experimental/CompletionCandidate.java +++ b/pdex/src/processing/mode/experimental/CompletionCandidate.java @@ -5,6 +5,7 @@ import java.lang.reflect.Method; import java.util.List; import org.eclipse.jdt.core.dom.ASTNode; +import org.eclipse.jdt.core.dom.FieldDeclaration; import org.eclipse.jdt.core.dom.MethodDeclaration; import org.eclipse.jdt.core.dom.SingleVariableDeclaration; import org.eclipse.jdt.core.dom.TypeDeclaration; @@ -27,7 +28,6 @@ public class CompletionCandidate implements Comparable{ public CompletionCandidate(Method method) { method.getDeclaringClass().getName(); elementName = method.getName(); - type = LOCAL_METHOD; StringBuffer label = new StringBuffer(method.getName() + "("); StringBuffer cstr = new StringBuffer(method.getName() + "("); for (int i = 0; i < method.getParameterTypes().length; i++) { @@ -53,14 +53,20 @@ public class CompletionCandidate implements Comparable{ public CompletionCandidate(SingleVariableDeclaration svd) { completionString = svd.getName().toString(); elementName = svd.getName().toString(); - type = LOCAL_VAR; + if(svd.getParent() instanceof FieldDeclaration) + type = LOCAL_FIELD; + else + type = LOCAL_VAR; label = svd.getName() + " : " + svd.getType(); } public CompletionCandidate(VariableDeclarationFragment vdf) { completionString = vdf.getName().toString(); elementName = vdf.getName().toString(); - type = LOCAL_VAR; + if(vdf.getParent() instanceof FieldDeclaration) + type = LOCAL_FIELD; + else + type = LOCAL_VAR; label = vdf.getName() + " : " + ASTGenerator.extracTypeInfo2(vdf); } diff --git a/pdex/src/processing/mode/experimental/CompletionPanel.java b/pdex/src/processing/mode/experimental/CompletionPanel.java index 0336c72e9..55e66c430 100644 --- a/pdex/src/processing/mode/experimental/CompletionPanel.java +++ b/pdex/src/processing/mode/experimental/CompletionPanel.java @@ -214,6 +214,9 @@ public class CompletionPanel { if (value instanceof CompletionCandidate) { CompletionCandidate cc = (CompletionCandidate) value; switch (cc.getType()) { + case CompletionCandidate.LOCAL_VAR: + label.setIcon(editor.dmode.localVarIcon); + break; case CompletionCandidate.LOCAL_FIELD: case CompletionCandidate.PREDEF_FIELD: label.setIcon(editor.dmode.fieldIcon); @@ -228,10 +231,14 @@ public class CompletionPanel { break; default: + log("(CustomListRenderer)Unknown CompletionCandidate type " + cc.getType()); break; } } + else + log("(CustomListRenderer)Unknown CompletionCandidate object " + value); + return label; } } diff --git a/pdex/src/processing/mode/experimental/ExperimentalMode.java b/pdex/src/processing/mode/experimental/ExperimentalMode.java index 783eeeba9..d5f07395a 100755 --- a/pdex/src/processing/mode/experimental/ExperimentalMode.java +++ b/pdex/src/processing/mode/experimental/ExperimentalMode.java @@ -161,7 +161,7 @@ public class ExperimentalMode extends JavaMode { return defaultValue; } - protected ImageIcon classIcon, fieldIcon, methodIcon; + protected ImageIcon classIcon, fieldIcon, methodIcon, localVarIcon; protected void loadIcons(){ String iconPath = getContentFile("data") .getAbsolutePath() @@ -171,6 +171,8 @@ public class ExperimentalMode extends JavaMode { + "methpub_obj.png"); fieldIcon = new ImageIcon(iconPath + File.separator + "field_protected_obj.png"); + localVarIcon = new ImageIcon(iconPath + File.separator + + "field_default_obj.png"); log("Icons loaded"); }