mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 186981: Values of variables are shown differently depending on "show columns" option.
This commit is contained in:
parent
585a40aa2b
commit
d110311f48
8 changed files with 294 additions and 106 deletions
|
@ -0,0 +1,21 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 ARM Limited and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* ARM Limited - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.core.model;
|
||||
|
||||
import org.eclipse.debug.core.model.IRegister;
|
||||
|
||||
/**
|
||||
* C/C++ specific extension of <code>IRegister</code>.
|
||||
* Added to be able to contribute a label provider.
|
||||
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=186981
|
||||
*/
|
||||
public interface ICRegister extends ICVariable, IRegister {
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* ARM Limited - https://bugs.eclipse.org/bugs/show_bug.cgi?id=186981
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.model;
|
||||
|
||||
|
@ -29,19 +30,19 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableDescriptor;
|
|||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayValue;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
|
||||
import org.eclipse.cdt.debug.core.model.CVariableFormat;
|
||||
import org.eclipse.cdt.debug.core.model.ICRegister;
|
||||
import org.eclipse.cdt.debug.core.model.ICStackFrame;
|
||||
import org.eclipse.cdt.debug.core.model.ICType;
|
||||
import org.eclipse.cdt.debug.core.model.ICValue;
|
||||
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IRegister;
|
||||
import org.eclipse.debug.core.model.IRegisterGroup;
|
||||
|
||||
/**
|
||||
* Represents a register in the CDI model.
|
||||
*/
|
||||
public class CRegister extends CVariable implements IRegister {
|
||||
public class CRegister extends CVariable implements ICRegister {
|
||||
|
||||
private class InternalVariable implements IInternalVariable {
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Nokia - Added support for CSourceNotFoundElement ( 167305 )
|
||||
* ARM Limited - https://bugs.eclipse.org/bugs/show_bug.cgi?id=186981
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui;
|
||||
|
||||
|
@ -58,7 +59,6 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.resources.IStorage;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
|
@ -338,20 +338,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
|
|||
String bt = getBaseText( element );
|
||||
if ( bt == null )
|
||||
return null;
|
||||
StringBuffer baseText = new StringBuffer( bt );
|
||||
if ( element instanceof ICDebugElementStatus && !((ICDebugElementStatus)element).isOK() ) {
|
||||
baseText.append( getFormattedString( " <{0}>", ((ICDebugElementStatus)element).getMessage() ) ); //$NON-NLS-1$
|
||||
}
|
||||
if ( element instanceof IAdaptable ) {
|
||||
IEnableDisableTarget target = (IEnableDisableTarget)((IAdaptable)element).getAdapter( IEnableDisableTarget.class );
|
||||
if ( target != null ) {
|
||||
if ( !target.isEnabled() ) {
|
||||
baseText.append( ' ' );
|
||||
baseText.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.25" ) ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
return baseText.toString();
|
||||
return CDebugUIUtils.decorateText( element, bt );
|
||||
}
|
||||
|
||||
private String getBaseText( Object element ) {
|
||||
|
@ -541,30 +528,6 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
|
|||
return null;
|
||||
}
|
||||
|
||||
private String getVariableTypeName( ICType type ) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
String typeName = type.getName();
|
||||
if ( typeName != null )
|
||||
typeName = typeName.trim();
|
||||
if ( type.isArray() && typeName != null ) {
|
||||
int index = typeName.indexOf( '[' );
|
||||
if ( index != -1 )
|
||||
typeName = typeName.substring( 0, index ).trim();
|
||||
}
|
||||
if ( typeName != null && typeName.length() > 0 ) {
|
||||
result.append( typeName );
|
||||
if ( type.isArray() ) {
|
||||
int[] dims = type.getArrayDimensions();
|
||||
for( int i = 0; i < dims.length; ++i ) {
|
||||
result.append( '[' );
|
||||
result.append( dims[i] );
|
||||
result.append( ']' );
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
protected String getVariableText( IVariable var ) throws DebugException {
|
||||
StringBuffer label = new StringBuffer();
|
||||
if ( var instanceof ICVariable ) {
|
||||
|
@ -576,7 +539,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
|
|||
// don't display type
|
||||
}
|
||||
if ( type != null && isShowVariableTypeNames() ) {
|
||||
String typeName = getVariableTypeName( type );
|
||||
String typeName = CDebugUIUtils.getVariableTypeName( type );
|
||||
if ( typeName != null && typeName.length() > 0 ) {
|
||||
label.append( typeName ).append( ' ' );
|
||||
}
|
||||
|
@ -593,48 +556,8 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
|
|||
return label.toString();
|
||||
}
|
||||
|
||||
protected String getValueText( IValue value )/* throws DebugException*/ {
|
||||
StringBuffer label = new StringBuffer();
|
||||
if ( value instanceof ICDebugElementStatus && !((ICDebugElementStatus)value).isOK() ) {
|
||||
label.append( getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.4" ), ((ICDebugElementStatus)value).getMessage() ) ); //$NON-NLS-1$
|
||||
}
|
||||
else if ( value instanceof ICValue ) {
|
||||
ICType type = null;
|
||||
try {
|
||||
type = ((ICValue)value).getType();
|
||||
}
|
||||
catch( DebugException e ) {
|
||||
}
|
||||
try {
|
||||
String valueString = value.getValueString();
|
||||
if ( valueString != null ) {
|
||||
valueString = valueString.trim();
|
||||
if ( type != null && type.isCharacter() ) {
|
||||
if ( valueString.length() == 0 )
|
||||
valueString = "."; //$NON-NLS-1$
|
||||
label.append( valueString );
|
||||
}
|
||||
else if ( type != null && type.isFloatingPointType() ) {
|
||||
Number floatingPointValue = CDebugUtils.getFloatingPointValue( (ICValue)value );
|
||||
if ( CDebugUtils.isNaN( floatingPointValue ) )
|
||||
valueString = "NAN"; //$NON-NLS-1$
|
||||
if ( CDebugUtils.isPositiveInfinity( floatingPointValue ) )
|
||||
valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.23" ); //$NON-NLS-1$
|
||||
if ( CDebugUtils.isNegativeInfinity( floatingPointValue ) )
|
||||
valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.24" ); //$NON-NLS-1$
|
||||
label.append( valueString );
|
||||
}
|
||||
else if ( type == null || (!type.isArray() && !type.isStructure()) ) {
|
||||
if ( valueString.length() > 0 ) {
|
||||
label.append( valueString );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( DebugException e1 ) {
|
||||
}
|
||||
}
|
||||
return label.toString();
|
||||
protected String getValueText( IValue value ) {
|
||||
return CDebugUIUtils.getValueText( value );
|
||||
}
|
||||
|
||||
protected String getSignalText( ICSignal signal ) {
|
||||
|
@ -664,7 +587,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
|
|||
catch( DebugException e1 ) {
|
||||
}
|
||||
if ( type != null && isShowVariableTypeNames() ) {
|
||||
String typeName = getVariableTypeName( type );
|
||||
String typeName = CDebugUIUtils.getVariableTypeName( type );
|
||||
if ( !isEmpty( typeName ) ) {
|
||||
result.insert( 0, typeName + ' ' );
|
||||
}
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* ARM Limited - https://bugs.eclipse.org/bugs/show_bug.cgi?id=186981
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugUtils;
|
||||
import org.eclipse.cdt.debug.core.model.ICDebugElementStatus;
|
||||
import org.eclipse.cdt.debug.core.model.ICStackFrame;
|
||||
import org.eclipse.cdt.debug.core.model.ICType;
|
||||
import org.eclipse.cdt.debug.core.model.ICValue;
|
||||
import org.eclipse.cdt.debug.core.model.IEnableDisableTarget;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IValue;
|
||||
import org.eclipse.debug.core.model.IVariable;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
|
@ -72,4 +83,103 @@ public class CDebugUIUtils {
|
|||
IAdaptable context = DebugUITools.getDebugContext();
|
||||
return ( context != null ) ? (ICStackFrame)context.getAdapter( ICStackFrame.class ) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moved from CDebugModelPresentation because it is also used by CVariableLabelProvider.
|
||||
*/
|
||||
static public String getValueText( IValue value ) {
|
||||
StringBuffer label = new StringBuffer();
|
||||
if ( value instanceof ICDebugElementStatus && !((ICDebugElementStatus)value).isOK() ) {
|
||||
label.append( MessageFormat.format( CDebugUIMessages.getString( "CDTDebugModelPresentation.4" ), new String[] { ((ICDebugElementStatus)value).getMessage() } ) ); //$NON-NLS-1$
|
||||
}
|
||||
else if ( value instanceof ICValue ) {
|
||||
ICType type = null;
|
||||
try {
|
||||
type = ((ICValue)value).getType();
|
||||
}
|
||||
catch( DebugException e ) {
|
||||
}
|
||||
try {
|
||||
String valueString = value.getValueString();
|
||||
if ( valueString != null ) {
|
||||
valueString = valueString.trim();
|
||||
if ( type != null && type.isCharacter() ) {
|
||||
if ( valueString.length() == 0 )
|
||||
valueString = "."; //$NON-NLS-1$
|
||||
label.append( valueString );
|
||||
}
|
||||
else if ( type != null && type.isFloatingPointType() ) {
|
||||
Number floatingPointValue = CDebugUtils.getFloatingPointValue( (ICValue)value );
|
||||
if ( CDebugUtils.isNaN( floatingPointValue ) )
|
||||
valueString = "NAN"; //$NON-NLS-1$
|
||||
if ( CDebugUtils.isPositiveInfinity( floatingPointValue ) )
|
||||
valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.23" ); //$NON-NLS-1$
|
||||
if ( CDebugUtils.isNegativeInfinity( floatingPointValue ) )
|
||||
valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.24" ); //$NON-NLS-1$
|
||||
label.append( valueString );
|
||||
}
|
||||
else if ( type == null || (!type.isArray() && !type.isStructure()) ) {
|
||||
if ( valueString.length() > 0 ) {
|
||||
label.append( valueString );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( DebugException e1 ) {
|
||||
}
|
||||
}
|
||||
return label.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Moved from CDebugModelPresentation because it is also used by CVariableLabelProvider.
|
||||
*/
|
||||
public static String getVariableTypeName( ICType type ) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
if ( type != null ) {
|
||||
String typeName = type.getName();
|
||||
if ( typeName != null )
|
||||
typeName = typeName.trim();
|
||||
if ( type.isArray() && typeName != null ) {
|
||||
int index = typeName.indexOf( '[' );
|
||||
if ( index != -1 )
|
||||
typeName = typeName.substring( 0, index ).trim();
|
||||
}
|
||||
if ( typeName != null && typeName.length() > 0 ) {
|
||||
result.append( typeName );
|
||||
if ( type.isArray() ) {
|
||||
int[] dims = type.getArrayDimensions();
|
||||
for( int i = 0; i < dims.length; ++i ) {
|
||||
result.append( '[' );
|
||||
result.append( dims[i] );
|
||||
result.append( ']' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static String getVariableName( IVariable variable ) throws DebugException {
|
||||
return decorateText( variable, variable.getName() );
|
||||
}
|
||||
|
||||
public static String decorateText( Object element, String text ) {
|
||||
if ( text == null )
|
||||
return null;
|
||||
StringBuffer baseText = new StringBuffer( text );
|
||||
if ( element instanceof ICDebugElementStatus && !((ICDebugElementStatus)element).isOK() ) {
|
||||
baseText.append( MessageFormat.format( " <{0}>", new String[] { ((ICDebugElementStatus)element).getMessage() } ) ); //$NON-NLS-1$
|
||||
}
|
||||
if ( element instanceof IAdaptable ) {
|
||||
IEnableDisableTarget target = (IEnableDisableTarget)((IAdaptable)element).getAdapter( IEnableDisableTarget.class );
|
||||
if ( target != null ) {
|
||||
if ( !target.isEnabled() ) {
|
||||
baseText.append( ' ' );
|
||||
baseText.append( CDebugUIMessages.getString( "CDTDebugModelPresentation.25" ) ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
return baseText.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* IBM Corporation
|
||||
* ARM Limited - https://bugs.eclipse.org/bugs/show_bug.cgi?id=186981
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
|
||||
|
||||
|
@ -15,21 +16,15 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.debug.core.model.ICModule;
|
||||
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleContentProvider;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleLabelProvider;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleMementoProvider;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleProxyFactory;
|
||||
import org.eclipse.core.runtime.IAdapterFactory;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory;
|
||||
|
||||
/**
|
||||
* Comment for .
|
||||
*/
|
||||
public class CDebugElementAdapterFactory implements IAdapterFactory {
|
||||
|
||||
private static IElementLabelProvider fgModuleLabelProvider = new ModuleLabelProvider();
|
||||
private static IElementContentProvider fgModuleContentProvider = new ModuleContentProvider();
|
||||
private static IModelProxyFactory fgModuleProxyFactory = new ModuleProxyFactory();
|
||||
private static IElementMementoProvider fgModuleMementoProvider = new ModuleMementoProvider();
|
||||
|
@ -41,14 +36,6 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
|
|||
if ( adapterType.isInstance( adaptableObject ) ) {
|
||||
return adaptableObject;
|
||||
}
|
||||
if ( adapterType.equals( IElementLabelProvider.class ) ) {
|
||||
if ( adaptableObject instanceof ICModule ) {
|
||||
return fgModuleLabelProvider;
|
||||
}
|
||||
if ( adaptableObject instanceof ICElement ) {
|
||||
return fgModuleLabelProvider;
|
||||
}
|
||||
}
|
||||
if ( adapterType.equals( IElementContentProvider.class ) ) {
|
||||
if ( adaptableObject instanceof IModuleRetrieval ) {
|
||||
return fgModuleContentProvider;
|
||||
|
@ -78,7 +65,6 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
|
|||
*/
|
||||
public Class[] getAdapterList() {
|
||||
return new Class[] {
|
||||
IElementLabelProvider.class,
|
||||
IElementContentProvider.class,
|
||||
IModelProxyFactory.class,
|
||||
IElementMementoProvider.class,
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 ARM Limited and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* ARM Limited - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.debug.core.model.ICModule;
|
||||
import org.eclipse.cdt.debug.core.model.ICVariable;
|
||||
import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleLabelProvider;
|
||||
import org.eclipse.core.runtime.IAdapterFactory;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
|
||||
|
||||
/**
|
||||
* Factory for all (non-default) label providers
|
||||
*/
|
||||
public class CDebugElementLabelProviderFactory implements IAdapterFactory {
|
||||
|
||||
private static IElementLabelProvider fgModuleLabelProvider = new ModuleLabelProvider();
|
||||
private static IElementLabelProvider fgVariableLabelProvider = new CVariableLabelProvider();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
|
||||
*/
|
||||
public Object getAdapter( Object adaptableObject, Class adapterType ) {
|
||||
if ( adapterType.equals( IElementLabelProvider.class ) ) {
|
||||
if ( adaptableObject instanceof ICModule ) {
|
||||
return fgModuleLabelProvider;
|
||||
}
|
||||
if ( adaptableObject instanceof ICElement ) {
|
||||
return fgModuleLabelProvider;
|
||||
}
|
||||
if ( adaptableObject instanceof ICVariable ) {
|
||||
return fgVariableLabelProvider;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
|
||||
*/
|
||||
public Class[] getAdapterList() {
|
||||
return new Class[] {
|
||||
IElementLabelProvider.class,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 ARM Limited and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* ARM Limited - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
|
||||
|
||||
import org.eclipse.cdt.debug.core.model.ICValue;
|
||||
import org.eclipse.cdt.debug.core.model.ICVariable;
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.model.IValue;
|
||||
import org.eclipse.debug.core.model.IVariable;
|
||||
import org.eclipse.debug.internal.ui.elements.adapters.VariableColumnPresentation;
|
||||
import org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.TreePath;
|
||||
|
||||
/**
|
||||
* Label provider for variables and registers.
|
||||
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=186981
|
||||
*
|
||||
* Using the internal platform classes because the API hasn't been defined.
|
||||
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=187500 and
|
||||
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=187502
|
||||
*/
|
||||
public class CVariableLabelProvider extends DebugElementLabelProvider {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.internal.ui.model.elements.DebugElementLabelProvider#getLabel(org.eclipse.jface.viewers.TreePath, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String)
|
||||
*/
|
||||
protected String getLabel( TreePath elementPath, IPresentationContext context, String columnId ) throws CoreException {
|
||||
if ( columnId != null ) {
|
||||
IVariable variable = (IVariable)elementPath.getLastSegment();
|
||||
IValue value = variable.getValue();
|
||||
return getColumnText( variable, value, context, columnId );
|
||||
}
|
||||
return super.getLabel( elementPath, context, columnId );
|
||||
}
|
||||
|
||||
protected String getValueText( IVariable variable, IValue value, IPresentationContext context ) throws CoreException {
|
||||
if ( value instanceof ICValue ) {
|
||||
return CDebugUIUtils.getValueText( value );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getVariableTypeName( IVariable variable, IPresentationContext context ) throws CoreException {
|
||||
if ( variable instanceof ICVariable ) {
|
||||
return CDebugUIUtils.getVariableTypeName( ((ICVariable)variable).getType() );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getVariableName( IVariable variable, IPresentationContext context ) throws CoreException {
|
||||
return CDebugUIUtils.getVariableName( variable );
|
||||
}
|
||||
|
||||
protected String getColumnText( IVariable variable, IValue value, IPresentationContext context, String columnId ) throws CoreException {
|
||||
if ( VariableColumnPresentation.COLUMN_VARIABLE_NAME.equals( columnId ) ) {
|
||||
return getVariableName( variable, context );
|
||||
}
|
||||
else if ( VariableColumnPresentation.COLUMN_VARIABLE_TYPE.equals( columnId ) ) {
|
||||
return getVariableTypeName( variable, context );
|
||||
}
|
||||
else if ( VariableColumnPresentation.COLUMN_VARIABLE_VALUE.equals( columnId ) ) {
|
||||
return getValueText( variable, value, context );
|
||||
}
|
||||
return null; // super.getColumnText( variable, value, context, columnId );
|
||||
}
|
||||
|
||||
protected ImageDescriptor getImageDescriptor( TreePath elementPath, IPresentationContext presentationContext, String columnId ) throws CoreException {
|
||||
if ( columnId == null || VariableColumnPresentation.COLUMN_VARIABLE_NAME.equals( columnId ) ) {
|
||||
return super.getImageDescriptor( elementPath, presentationContext, columnId );
|
||||
}
|
||||
return null; // super.getImageDescriptor( elementPath, presentationContext, columnId );
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2007 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* ARM Limited - https://bugs.eclipse.org/bugs/show_bug.cgi?id=186981
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.ui;
|
||||
|
||||
|
@ -16,6 +17,7 @@ import java.util.Map;
|
|||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.model.ICModule;
|
||||
import org.eclipse.cdt.debug.core.model.ICRegister;
|
||||
import org.eclipse.cdt.debug.core.model.ICVariable;
|
||||
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
|
||||
import org.eclipse.cdt.debug.internal.ui.CBreakpointUpdater;
|
||||
|
@ -26,6 +28,7 @@ import org.eclipse.cdt.debug.internal.ui.ColorManager;
|
|||
import org.eclipse.cdt.debug.internal.ui.EvaluationContextManager;
|
||||
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
|
||||
import org.eclipse.cdt.debug.internal.ui.elements.adapters.CDebugElementAdapterFactory;
|
||||
import org.eclipse.cdt.debug.internal.ui.elements.adapters.CDebugElementLabelProviderFactory;
|
||||
import org.eclipse.cdt.debug.internal.ui.elements.adapters.CMemoryAdapterFactory;
|
||||
import org.eclipse.cdt.debug.internal.ui.elements.adapters.CWatchExpressionFactoryAdapterFactory;
|
||||
import org.eclipse.cdt.debug.ui.sourcelookup.DefaultSourceLocator;
|
||||
|
@ -288,7 +291,13 @@ public class CDebugUIPlugin extends AbstractUIPlugin {
|
|||
manager.registerAdapters( elementAdapterFactory, IModuleRetrieval.class );
|
||||
manager.registerAdapters( elementAdapterFactory, ICModule.class );
|
||||
manager.registerAdapters( elementAdapterFactory, ICElement.class );
|
||||
|
||||
|
||||
CDebugElementLabelProviderFactory labelProviderFactory = new CDebugElementLabelProviderFactory();
|
||||
manager.registerAdapters( labelProviderFactory, ICVariable.class );
|
||||
manager.registerAdapters( labelProviderFactory, ICRegister.class );
|
||||
manager.registerAdapters( labelProviderFactory, ICModule.class );
|
||||
manager.registerAdapters( labelProviderFactory, ICElement.class );
|
||||
|
||||
CWatchExpressionFactoryAdapterFactory watchExpressionAdapterFactory = new CWatchExpressionFactoryAdapterFactory();
|
||||
manager.registerAdapters( watchExpressionAdapterFactory, ICVariable.class );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue