1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 22:22:11 +02:00

Bug 173253: Create Watch Expression of member variable or struct.

This commit is contained in:
Mikhail Khodjaiants 2007-02-13 23:42:50 +00:00
parent c2d6547a5d
commit d692d9d650
6 changed files with 90 additions and 11 deletions

View file

@ -33,4 +33,12 @@ public interface ICVariable extends IVariable, ICDebugElement, IFormatSupport, I
* @return whether this variable is an argument
*/
boolean isArgument();
/**
* Returns the text presentation of this variable as an expression.
*
* @return the text presentation of this variable as an expression
* @throws DebugException
*/
public String getExpressionString() throws DebugException;
}

View file

@ -62,14 +62,6 @@ public abstract class AbstractCVariable extends CDebugElement implements ICVaria
return super.getAdapter( adapter );
}
/**
* Returns the text presentation of this variable as an expression.
*
* @return the text presentation of this variable as an expression
* @throws DebugException
*/
public abstract String getExpressionString() throws DebugException;
public abstract void dispose();
protected abstract void resetValue();

View file

@ -18,7 +18,6 @@ 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.core.model.IStackFrame;
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;

View file

@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2007 ARM 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 - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
import org.eclipse.cdt.debug.core.model.ICVariable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapterExtension;
public class CWatchExpressionFactoryAdapter implements IWatchExpressionFactoryAdapterExtension {
/* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapterExtension#canCreateWatchExpression(org.eclipse.debug.core.model.IVariable)
*/
public boolean canCreateWatchExpression( IVariable variable ) {
return ( variable instanceof ICVariable );
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapter#createWatchExpression(org.eclipse.debug.core.model.IVariable)
*/
public String createWatchExpression( IVariable variable ) throws CoreException {
return ( variable instanceof ICVariable ) ? ((ICVariable)variable).getExpressionString() : null;
}
}

View file

@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2007 ARM 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 - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.elements.adapters;
import org.eclipse.cdt.debug.core.model.ICVariable;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapter;
public class CWatchExpressionFactoryAdapterFactory implements IAdapterFactory {
private static IWatchExpressionFactoryAdapter fgWatchExpressionFactoryAdapter = new CWatchExpressionFactoryAdapter();
/* (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( IWatchExpressionFactoryAdapter.class ) ) {
if ( adaptableObject instanceof ICVariable ) {
return fgWatchExpressionFactoryAdapter;
}
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
*/
public Class[] getAdapterList() {
return new Class[] {
IWatchExpressionFactoryAdapter.class,
};
}
}

View file

@ -12,9 +12,11 @@ package org.eclipse.cdt.debug.ui;
import java.util.HashMap;
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.ICVariable;
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
import org.eclipse.cdt.debug.internal.ui.CBreakpointUpdater;
import org.eclipse.cdt.debug.internal.ui.CDebugImageDescriptorRegistry;
@ -25,9 +27,10 @@ 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.CMemoryAdapterFactory;
import org.eclipse.cdt.debug.internal.ui.elements.adapters.CWatchExpressionFactoryAdapterFactory;
import org.eclipse.cdt.debug.ui.sourcelookup.DefaultSourceLocator;
import org.eclipse.cdt.debug.ui.sourcelookup.OldDefaultSourceLocator;
import org.eclipse.cdt.internal.ui.editor.SharedTextColors;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@ -277,6 +280,9 @@ public class CDebugUIPlugin extends AbstractUIPlugin {
manager.registerAdapters( elementAdapterFactory, IModuleRetrieval.class );
manager.registerAdapters( elementAdapterFactory, ICModule.class );
manager.registerAdapters( elementAdapterFactory, ICElement.class );
CWatchExpressionFactoryAdapterFactory watchExpressionAdapterFactory = new CWatchExpressionFactoryAdapterFactory();
manager.registerAdapters( watchExpressionAdapterFactory, ICVariable.class );
CMemoryAdapterFactory memoryAdapterFactory = new CMemoryAdapterFactory();
manager.registerAdapters( memoryAdapterFactory, IMemoryBlockRetrievalExtension.class );
@ -308,7 +314,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin {
*/
public ISharedTextColors getSharedTextColors() {
if ( fSharedTextColors == null )
fSharedTextColors = new SharedTextColors();
fSharedTextColors = CUIPlugin.getDefault().getSharedTextColors();
return fSharedTextColors;
}
}