diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 2689dd1c3c4..669bc45dec5 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,19 +1,25 @@ -2003-10-24 Mikhail Khodjaiants +2003-09-30 Mikhail Khodjaiants + Fix for PR 39737: Tooltip in debug mode over long strings is not handled properly. + Added an internal constant to limit the hover text size. + Present the hover text in HTML format. + * DebugTextHover.java + +2003-09-24 Mikhail Khodjaiants Fix for PR 43624: The "Show Types Name" action of the Registers view doesn't work. * ShowRegisterTypesAction.java * RegistersView.java -2003-10-22 Mikhail Khodjaiants +2003-09-22 Mikhail Khodjaiants Moved the 'AddAddressBreakpointActionDelegate' action to the 'org.eclipse.cdt.debug.internal.ui.actions' package. * AddAddressBreakpointActionDelegate.java * plugin.xml -2003-10-16 Mikhail Khodjaiants +2003-09-16 Mikhail Khodjaiants Cleanup. * CUISourceLocator.java -2003-10-11 Mikhail Khodjaiants +2003-09-11 Mikhail Khodjaiants Reset the selection of variable after casting. * CastToArrayActionDelegate.java * CastToTypeActionDelegate.java diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java index af67b9aa767..db350f7db30 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/editors/DebugTextHover.java @@ -31,6 +31,8 @@ import org.eclipse.jface.text.ITextViewer; */ public class DebugTextHover implements ITextHover { + static final private int MAX_HOVER_INFO_SIZE = 100; + /** * Constructor for DebugTextHover. */ @@ -82,36 +84,17 @@ public class DebugTextHover implements ITextHover StringBuffer buffer = new StringBuffer(); boolean showDebugTarget = targetList.size() > 1; Iterator iterator = targetList.iterator(); - boolean first = true; while ( iterator.hasNext() ) { IDebugTarget target = (IDebugTarget)iterator.next(); ICExpressionEvaluator ee = (ICExpressionEvaluator)target.getAdapter( ICExpressionEvaluator.class ); if ( ee.canEvaluate() ) { - String result = evaluateExpression( ee, expression ); + String result = evaluateExpression( ee, expression ).trim(); try { if ( result != null ) - { - if ( first ) - { - first = false; - } - else - { - buffer.append( '\n' ); - } - if ( showDebugTarget ) - { - buffer.append( '[' ); - buffer.append( target.getName() ); - buffer.append( "]: " ); - } - buffer.append( expression ); - buffer.append( '=' ); - buffer.append( result ); - } + appendVariable( buffer, expression, result, showDebugTarget ? target.getName() : null ); } catch( DebugException x ) { @@ -163,4 +146,61 @@ public class DebugTextHover implements ITextHover } return result; } + + /** + * A variable gets one line for each debug target it appears in. + */ + private static void appendVariable( StringBuffer buffer, + String expression, + String value, + String debugTargetName ) throws DebugException + { + if ( value.length() > MAX_HOVER_INFO_SIZE ) + value = value.substring( 0, MAX_HOVER_INFO_SIZE ) + " ..."; + buffer.append( "

" ); //$NON-NLS-1$ + if ( debugTargetName != null ) + { + buffer.append( '[' + debugTargetName + "] " ); //$NON-NLS-1$ + } + buffer.append( makeHTMLSafe( expression ) ); + buffer.append( " = " ); //$NON-NLS-1$ + + String safeValue = "" + makeHTMLSafe( value ) + ""; //$NON-NLS-1$ //$NON-NLS-2$ + buffer.append( safeValue ); + buffer.append( "

" ); //$NON-NLS-1$ + } + + /** + * Replace any characters in the given String that would confuse an HTML + * parser with their escape sequences. + */ + private static String makeHTMLSafe( String string ) + { + StringBuffer buffer = new StringBuffer( string.length() ); + + for ( int i = 0; i != string.length(); i++ ) + { + char ch = string.charAt( i ); + + switch( ch ) + { + case '&': + buffer.append( "&" ); //$NON-NLS-1$ + break; + + case '<': + buffer.append( "<" ); //$NON-NLS-1$ + break; + + case '>': + buffer.append( ">" ); //$NON-NLS-1$ + break; + + default: + buffer.append( ch ); + break; + } + } + return buffer.toString(); + } }