Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [Dltk-dev] any objections to changing the "toString" of the CollectionType?

My vision is we should limit the string length and not the number of elements - see attachement.

Alex

Johan Compagner wrote:
Now we get something like this in the debugger:

"number[8]"

What does that say? Nobody can see whats really in it without really expanding it and so on
The Rhino debugger (the old one) did this:

"Array(10.0,200.0,30.0,40.0,5006.0,700.0,200.0,"johan")"

Of course not the complete array values limit it (currently 100 values)

This is the code:

public String formatValue(IScriptValue value) {
        StringBuffer sb = new StringBuffer();
        sb.append(value.getRawValue()); // == Array
        sb.append("("); // == Array

        try {
            IVariable[] variables2 = value.getVariables();
            if (variables2.length > 0) {
                int length = variables2.length;
                length = length > 100 ? 100 : length;
                for (int i = 0; i < variables2.length; i++) {
                    sb.append(variables2[i].getValue().getValueString());
                    sb.append(",");
                }
                sb.setLength(sb.length() - 1);
            }
        } catch (DebugException ex) {
            ex.printStackTrace();
        }
        sb.append(")"); // == Array

        addInstanceId(value, sb);

        return sb.toString();
    }

Should i commit this? Or are you guys liking the current behavior better?

johan

------------------------------------------------------------------------

_______________________________________________
dltk-dev mailing list
dltk-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dltk-dev
### Eclipse Workspace Patch 1.0
#P org.eclipse.dltk.debug
Index: src/org/eclipse/dltk/debug/core/model/ArrayScriptType.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.debug/src/org/eclipse/dltk/debug/core/model/ArrayScriptType.java,v
retrieving revision 1.1
diff -u -r1.1 ArrayScriptType.java
--- src/org/eclipse/dltk/debug/core/model/ArrayScriptType.java	2 Jul 2008 04:05:42 -0000	1.1
+++ src/org/eclipse/dltk/debug/core/model/ArrayScriptType.java	2 Jul 2008 10:28:05 -0000
@@ -1,13 +1,44 @@
 package org.eclipse.dltk.debug.core.model;
 
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IVariable;
+
 /**
  * Represents an 'array' script type
  */
 public class ArrayScriptType extends CollectionScriptType {
 
-	private static String ARRAY = "array";
-
 	public ArrayScriptType() {
-		super(ARRAY);
+		super(IScriptTypeFactory.ARRAY);
+	}
+
+	private static final int MAX_STRING_VALUE = 1024;
+
+	public String formatValue(IScriptValue value) {
+		final StringBuffer sb = new StringBuffer(MAX_STRING_VALUE);
+		sb.append("Array ["); //$NON-NLS-1$
+		try {
+			IVariable[] variables2 = value.getVariables();
+			if (variables2.length > 0) {
+				for (int i = 0; i < variables2.length; i++) {
+					if (i != 0) {
+						sb.append(',');
+					}
+					sb.append(variables2[i].getValue().getValueString());
+					if (sb.length() >= MAX_STRING_VALUE) {
+						if (i != variables2.length - 1) {
+							sb.append("..."); //$NON-NLS-1$
+						}
+						break;
+					}
+				}
+			}
+		} catch (DebugException ex) {
+			ex.printStackTrace();
+		}
+		sb.append(']');
+		addInstanceId(value, sb);
+		return sb.toString();
 	}
+
 }

Back to the top