aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2012-08-15 05:39:51 (EDT)
committerzzhongwei2012-08-15 05:39:51 (EDT)
commit9c70dc1d16da89e55a5307152799f5d6112cd496 (patch)
treebf068519654145e8c47c28c4bc566659ed2a35fc
parent4a8016fb422527a4475e3f646d6589dd30c3909d (diff)
downloadorg.eclipse.pdt-9c70dc1d16da89e55a5307152799f5d6112cd496.zip
org.eclipse.pdt-9c70dc1d16da89e55a5307152799f5d6112cd496.tar.gz
org.eclipse.pdt-9c70dc1d16da89e55a5307152799f5d6112cd496.tar.bz2
387266: [Emanuel] Show variables in debugger view by name (sorting by
name). https://bugs.eclipse.org/bugs/show_bug.cgi?id=387266
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPDebugCorePreferenceInitializer.java2
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPDebugCorePreferenceNames.java1
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPProjectPreferences.java12
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/DefaultExpressionsManager.java2
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/ExpressionValue.java31
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/model/PHPStackFrame.java8
-rw-r--r--plugins/org.eclipse.php.debug.ui/plugin.properties3
-rw-r--r--plugins/org.eclipse.php.debug.ui/plugin.xml17
8 files changed, 70 insertions, 6 deletions
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPDebugCorePreferenceInitializer.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPDebugCorePreferenceInitializer.java
index e19780a..56c3f06 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPDebugCorePreferenceInitializer.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPDebugCorePreferenceInitializer.java
@@ -54,6 +54,8 @@ public class PHPDebugCorePreferenceInitializer extends
node.put(IPHPDebugConstants.PHP_DEBUG_PARAMETERS_INITIALIZER,
"org.eclipse.php.debug.core.defaultInitializer"); //$NON-NLS-1$
+ node.putBoolean(PHPDebugCorePreferenceNames.SORT_BY_NAME, false);
+
try {
StringBuilder b = new StringBuilder();
Enumeration<NetworkInterface> ii = NetworkInterface
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPDebugCorePreferenceNames.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPDebugCorePreferenceNames.java
index 44f325c..b0303ae 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPDebugCorePreferenceNames.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPDebugCorePreferenceNames.java
@@ -66,4 +66,5 @@ public class PHPDebugCorePreferenceNames {
public static final String DEFAULT_BASE_PATH = "DefaultProjectBasePath";
public static final String ENABLE_CLI_DEBUG = Debug_ID + "enable_cli_debug";//$NON-NLS-1$
+ public static final String SORT_BY_NAME = Debug_ID + "sort_by_name";//$NON-NLS-1$
}
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPProjectPreferences.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPProjectPreferences.java
index cd13911..3b6dc3b 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPProjectPreferences.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPProjectPreferences.java
@@ -71,6 +71,18 @@ public class PHPProjectPreferences {
}
+ public static boolean isSortByName() {
+ Preferences prefs = getModelPreferences();
+ return prefs.getBoolean(PHPDebugCorePreferenceNames.SORT_BY_NAME);
+
+ }
+
+ public static void changeSortByNameStatus() {
+ Preferences prefs = getModelPreferences();
+ prefs.setValue(PHPDebugCorePreferenceNames.SORT_BY_NAME,
+ !prefs.getBoolean(PHPDebugCorePreferenceNames.SORT_BY_NAME));
+ }
+
public static String getDefaultBasePath(IProject project) {
String basePath = null;
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/DefaultExpressionsManager.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/DefaultExpressionsManager.java
index 34f7184..79216b1 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/DefaultExpressionsManager.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/DefaultExpressionsManager.java
@@ -151,7 +151,7 @@ public class DefaultExpressionsManager implements ExpressionsManager {
ExpressionValue variableValue = expressionValueDeserializer
.deserializer(null, value);
- Expression[] localVariables = variableValue.getChildren();
+ Expression[] localVariables = variableValue.getOriChildren();
if (localVariables == null) {
localVariables = EMPTY_VARIABLE_ARRAY;
}
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/ExpressionValue.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/ExpressionValue.java
index 5f372d2..8e8299d 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/ExpressionValue.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/ExpressionValue.java
@@ -11,6 +11,13 @@
*******************************************************************************/
package org.eclipse.php.internal.debug.core.zend.debugger;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.php.internal.debug.core.preferences.PHPProjectPreferences;
+
public class ExpressionValue {
public static int NULL_TYPE = 0;
@@ -50,10 +57,32 @@ public class ExpressionValue {
return valueAsString;
}
- public Expression[] getChildren() {
+ public Expression[] getOriChildren() {
return children;
}
+ public Expression[] getChildren() {
+ return sort(children);
+ }
+
+ public static Expression[] sort(Expression[] children) {
+ if (PHPProjectPreferences.isSortByName()) {
+ List<Expression> list = new ArrayList<Expression>();
+ for (Expression expression : children) {
+ list.add(expression);
+ }
+ Collections.sort(list, new Comparator<Expression>() {
+ public int compare(Expression o1, Expression o2) {
+ return o1.getName()[o1.getName().length - 1].compareTo(o2
+ .getName()[o1.getName().length - 1]);
+ }
+ });
+ return list.toArray(new Expression[list.size()]);
+ } else {
+ return children;
+ }
+ }
+
public boolean isNull() {
return type == NULL_TYPE;
}
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/model/PHPStackFrame.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/model/PHPStackFrame.java
index 231d602..abbef64 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/model/PHPStackFrame.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/model/PHPStackFrame.java
@@ -21,6 +21,7 @@ import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.php.internal.debug.core.model.PHPDebugElement;
import org.eclipse.php.internal.debug.core.zend.debugger.Expression;
+import org.eclipse.php.internal.debug.core.zend.debugger.ExpressionValue;
/**
* PHP stack frame.
@@ -99,11 +100,12 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame {
* @see org.eclipse.debug.core.model.IStackFrame#getVariables()
*/
public IVariable[] getVariables() throws DebugException {
- Expression[] localVariables = fLocalVariables;
+ Expression[] localVariables = ExpressionValue.sort(fLocalVariables);
IVariable[] variables = new PHPVariable[localVariables.length];
for (int i = 0; i < localVariables.length; i++) {
- variables[i] = new PHPVariable((PHPDebugTarget) fThread
- .getDebugTarget(), localVariables[i]);
+ variables[i] = new PHPVariable(
+ (PHPDebugTarget) fThread.getDebugTarget(),
+ localVariables[i]);
}
return variables;
}
diff --git a/plugins/org.eclipse.php.debug.ui/plugin.properties b/plugins/org.eclipse.php.debug.ui/plugin.properties
index 5a619fd..975447d 100644
--- a/plugins/org.eclipse.php.debug.ui/plugin.properties
+++ b/plugins/org.eclipse.php.debug.ui/plugin.properties
@@ -55,4 +55,5 @@ PHP.execution.environments = PHP Execution Environments
ScriptProject.rename = ScriptProject Rename
Fragment.rename = Fragment Rename
SourceModule.rename = SourceModule Rename
-ScriptFolder.rename = ScriptFolder Rename \ No newline at end of file
+ScriptFolder.rename = ScriptFolder Rename
+SortActionName = Sort by name \ No newline at end of file
diff --git a/plugins/org.eclipse.php.debug.ui/plugin.xml b/plugins/org.eclipse.php.debug.ui/plugin.xml
index c5a1b09..3218cc6 100644
--- a/plugins/org.eclipse.php.debug.ui/plugin.xml
+++ b/plugins/org.eclipse.php.debug.ui/plugin.xml
@@ -613,4 +613,21 @@
</enablement>
</renameParticipant>
</extension>
+
+
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <viewerContribution
+ targetID="org.eclipse.debug.ui.VariableView"
+ id="org.eclipse.php.debug.ui.variablesView.popupMenu">
+ <!-- Variable Group -->
+ <action
+ label="%SortActionName"
+ class="org.eclipse.php.internal.debug.ui.actions.SortByNameAction"
+ menubarPath="variableGroup"
+ id="org.eclipse.php.debug.ui.SortByName">
+ </action>
+ </viewerContribution>
+ </extension>
+
</plugin>