1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

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.
This commit is contained in:
Mikhail Khodjaiants 2003-09-30 16:08:11 +00:00
parent 50e9f2922d
commit a44480ebb4
2 changed files with 71 additions and 25 deletions

View file

@ -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

View file

@ -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( "<p>" ); //$NON-NLS-1$
if ( debugTargetName != null )
{
buffer.append( '[' + debugTargetName + "]&nbsp;" ); //$NON-NLS-1$
}
buffer.append( makeHTMLSafe( expression ) );
buffer.append( " = " ); //$NON-NLS-1$
String safeValue = "<b>" + makeHTMLSafe( value ) + "</b>"; //$NON-NLS-1$ //$NON-NLS-2$
buffer.append( safeValue );
buffer.append( "</p>" ); //$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( "&amp;" ); //$NON-NLS-1$
break;
case '<':
buffer.append( "&lt;" ); //$NON-NLS-1$
break;
case '>':
buffer.append( "&gt;" ); //$NON-NLS-1$
break;
default:
buffer.append( ch );
break;
}
}
return buffer.toString();
}
}