From c33f0a9a16da607d8ce8906fa5003668484d5689 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Thu, 5 Aug 2004 19:57:18 +0000 Subject: [PATCH] Display the error message in the array label, if the attempt to get array values fails. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 6 ++++++ .../internal/core/model/CArrayPartition.java | 2 +- .../core/model/CArrayPartitionValue.java | 10 +++++++++- .../internal/core/model/CDebugElement.java | 18 +++++++++--------- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 056980e740a..01e8d7513c8 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,9 @@ +2004-08-05 Mikhail Khodjaiants + Display the error message in the array label, if the attempt to get array values fails. + * CArrayPartition.java + * CArrayPartitionValue.java + * CDebugElement.java: made the exception throwing methods static. + 2004-08-05 Mikhail Khodjaiants Fixed the "resumed" event handler of the variable types. * CExpression.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java index 52e67c87b70..f2be688f1b3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java @@ -274,7 +274,7 @@ public class CArrayPartition extends AbstractCVariable { } } catch( CDIException e ) { -// children.add( CVariableFactory.createVariableWithError( parent, e.getMessage() ) ); + requestFailed( e.getMessage(), e ); } } else { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java index 6063bad552e..07449037f96 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java @@ -14,7 +14,9 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; +import org.eclipse.cdt.debug.core.model.ICDebugElementStatus; import org.eclipse.cdt.debug.core.model.ICExpressionEvaluator; +import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IVariable; @@ -94,7 +96,13 @@ public class CArrayPartitionValue extends AbstractCValue { if ( !isAllocated() || !hasVariables() ) return Collections.EMPTY_LIST; if ( fVariables.size() == 0 ) { - fVariables = CArrayPartition.splitArray( this, getCDIVariable(), getStart(), getEnd() ); + try { + fVariables = CArrayPartition.splitArray( this, getCDIVariable(), getStart(), getEnd() ); + } + catch( DebugException e ) { + setStatus( ICDebugElementStatus.ERROR, e.getMessage() ); + getParentVariable().fireChangeEvent( DebugEvent.STATE ); + } } return fVariables; } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugElement.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugElement.java index 82e92db0688..d2582d4d19a 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugElement.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugElement.java @@ -11,8 +11,8 @@ package org.eclipse.cdt.debug.internal.core.model; import java.text.MessageFormat; +import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.CDebugCorePlugin; -import org.eclipse.cdt.debug.core.CDebugModel; import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDISession; @@ -74,7 +74,7 @@ abstract public class CDebugElement extends PlatformObject implements ICDebugEle * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier() */ public String getModelIdentifier() { - return CDebugModel.getPluginIdentifier(); + return CDIDebugModel.getPluginIdentifier(); } /* @@ -217,7 +217,7 @@ abstract public class CDebugElement extends PlatformObject implements ICDebugEle * @param e Exception that has occurred (can be null) * @throws DebugException The exception with a status code of REQUEST_FAILED */ - public void requestFailed( String message, Exception e ) throws DebugException { + public static void requestFailed( String message, Exception e ) throws DebugException { requestFailed( message, e, DebugException.REQUEST_FAILED ); } @@ -228,7 +228,7 @@ abstract public class CDebugElement extends PlatformObject implements ICDebugEle * @param e underlying exception that has occurred * @throws DebugException The exception with a status code of TARGET_REQUEST_FAILED */ - public void targetRequestFailed( String message, CDIException e ) throws DebugException { + public static void targetRequestFailed( String message, CDIException e ) throws DebugException { requestFailed( MessageFormat.format( "Target request failed: {0}.", new String[]{ message } ), e, DebugException.TARGET_REQUEST_FAILED ); //$NON-NLS-1$ } @@ -240,7 +240,7 @@ abstract public class CDebugElement extends PlatformObject implements ICDebugEle * @param code status code * @throws DebugException a new exception with given status code */ - public void requestFailed( String message, Throwable e, int code ) throws DebugException { + public static void requestFailed( String message, Throwable e, int code ) throws DebugException { throwDebugException( message, code, e ); } @@ -251,7 +251,7 @@ abstract public class CDebugElement extends PlatformObject implements ICDebugEle * @param e Throwable that has occurred * @throws DebugException The exception with a status code of TARGET_REQUEST_FAILED */ - public void targetRequestFailed( String message, Throwable e ) throws DebugException { + public static void targetRequestFailed( String message, Throwable e ) throws DebugException { throwDebugException( MessageFormat.format( "Target request failed: {0}.", new String[]{ message } ), DebugException.TARGET_REQUEST_FAILED, e ); //$NON-NLS-1$ } @@ -261,15 +261,15 @@ abstract public class CDebugElement extends PlatformObject implements ICDebugEle * @param message Failure message * @throws DebugException The exception with a status code of NOT_SUPPORTED. */ - public void notSupported( String message ) throws DebugException { + public static void notSupported( String message ) throws DebugException { throwDebugException( message, DebugException.NOT_SUPPORTED, null ); } /** * Throws a debug exception with the given message, error code, and underlying exception. */ - protected void throwDebugException( String message, int code, Throwable exception ) throws DebugException { - throw new DebugException( new Status( IStatus.ERROR, CDebugModel.getPluginIdentifier(), code, message, exception ) ); + protected static void throwDebugException( String message, int code, Throwable exception ) throws DebugException { + throw new DebugException( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), code, message, exception ) ); } protected void infoMessage( Throwable e ) {