From f600a3f5ba5af6f099e776edaf5b5a994e464229 Mon Sep 17 00:00:00 2001 From: bananeweizen Date: Sun, 22 Jan 2006 20:30:07 +0000 Subject: [PATCH] sort variables in watch view alphabetically --- .../internal/debug/core/model/PHPStackFrame.java | 26 ++++++++++--------- .../debug/core/model/PHPVariableComparator.java | 13 ++++++++++ 2 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPVariableComparator.java diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java index bbebc6a..1c5dcdd 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java @@ -6,11 +6,12 @@ which accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html Contributors: - IBM Corporation - Initial implementation - Vicente Fernando - www.alfersoft.com.ar + IBM Corporation - Initial implementation + Vicente Fernando - www.alfersoft.com.ar **********************************************************************/ package net.sourceforge.phpdt.internal.debug.core.model; +import java.util.Arrays; import java.util.Vector; import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy; @@ -215,9 +216,9 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Compa try { if (valOld.hasVariables () || // If the 'static' value has child variables - valNew.hasVariables ()) { // or if the DBG value has child variables + valNew.hasVariables ()) { // or if the DBG value has child variables if (!hasRecursion (varOld) && - !hasRecursion (varNew)) { // Both branches should not have a recursion + !hasRecursion (varNew)) { // Both branches should not have a recursion updateVariableList (valOld.getChildVariables (), // Update the variable list for the child variables valNew.getChildVariables ()); } @@ -285,10 +286,11 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Compa if (!isUpToDate ()) { resetHasChangedInfo (varList); - updateVariableList (varList, this.getPHPDBGProxy ().readVariables (this)); + updateVariableList (varList, this.getPHPDBGProxy ().readVariables (this)); setUpToDate (true); variables = (PHPVariable[]) varList.toArray (new PHPVariable[varList.size ()]); + Arrays.sort(variables, new PHPVariableComparator()); } return variables; // Give the array back to user interface @@ -337,7 +339,7 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Compa public IVariable findVariable (String s) throws DebugException { if (!isUpToDate ()) { resetHasChangedInfo (varList); - updateVariableList (varList, this.getPHPDBGProxy ().readVariables (this)); + updateVariableList (varList, this.getPHPDBGProxy ().readVariables (this)); setUpToDate (true); variables = (PHPVariable[]) varList.toArray (new PHPVariable[varList.size ()]); @@ -373,18 +375,18 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Compa public String getName() { StringBuffer name = new StringBuffer(); - + if (!this.getDescription().equals ("")) { name.append (this.getDescription ()); } else { name.append (this.getFileName ()); } - + name.append (" [line "); name.append (this.getLineNumber ()); name.append ("]"); - + return name.toString(); } @@ -444,7 +446,7 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Compa setUpToDate (false); - thread.prepareForResume (DebugEvent.STEP_INTO); // Don't know why, but this is necessary + thread.prepareForResume (DebugEvent.STEP_INTO); // Don't know why, but this is necessary this.getPHPDBGProxy ().readStepIntoEnd (PHPStackFrame.this); ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_INTO); @@ -459,7 +461,7 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Compa setUpToDate (false); - thread.prepareForResume (DebugEvent.STEP_OVER); + thread.prepareForResume (DebugEvent.STEP_OVER); this.getPHPDBGProxy ().readStepOverEnd (PHPStackFrame.this) ; ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_OVER); @@ -474,7 +476,7 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Compa setUpToDate (false); - thread.prepareForResume (DebugEvent.STEP_RETURN); + thread.prepareForResume (DebugEvent.STEP_RETURN); this.getPHPDBGProxy ().readStepReturnEnd (PHPStackFrame.this) ; ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_RETURN); diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPVariableComparator.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPVariableComparator.java new file mode 100644 index 0000000..1cd86e3 --- /dev/null +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPVariableComparator.java @@ -0,0 +1,13 @@ +package net.sourceforge.phpdt.internal.debug.core.model; + +import java.util.Comparator; + +public class PHPVariableComparator implements Comparator { + + public int compare(Object arg0, Object arg1) { + PHPVariable left=(PHPVariable) arg0; + PHPVariable right=(PHPVariable) arg1; + return left.getName().compareTo(right.getName()); + } + +} -- 1.7.1