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

Bug 315677 - [variables] Add "hasSubExpressions" method to IExpressions

This commit is contained in:
Mikhail Khodjaiants 2010-06-24 17:28:17 +00:00
parent e930dca1e9
commit 5a7c2c617e
4 changed files with 115 additions and 48 deletions

View file

@ -26,11 +26,12 @@ import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.ICachingService; import org.eclipse.cdt.dsf.debug.service.ICachingService;
import org.eclipse.cdt.dsf.debug.service.IExpressions; import org.eclipse.cdt.dsf.debug.service.IExpressions;
import org.eclipse.cdt.dsf.debug.service.IExpressions2; import org.eclipse.cdt.dsf.debug.service.IExpressions2;
import org.eclipse.cdt.dsf.debug.service.IExpressions3;
import org.eclipse.cdt.dsf.debug.service.IFormattedValues; import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
import org.eclipse.cdt.dsf.debug.service.IRunControl;
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent; import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent;
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext; import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryDMContext;
import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext; import org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl;
import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason; import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext; import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.cdt.dsf.debug.service.command.CommandCache; import org.eclipse.cdt.dsf.debug.service.command.CommandCache;
@ -67,7 +68,7 @@ import org.osgi.framework.BundleContext;
* *
* @since 2.0 * @since 2.0
*/ */
public class MIExpressions extends AbstractDsfService implements IExpressions2, ICachingService { public class MIExpressions extends AbstractDsfService implements IExpressions3, ICachingService {
/** /**
* A format that gives more details about an expression and supports pretty-printing * A format that gives more details about an expression and supports pretty-printing
@ -318,7 +319,7 @@ public class MIExpressions extends AbstractDsfService implements IExpressions2,
* such as its type and number of children; it does not contain the value or format * such as its type and number of children; it does not contain the value or format
* of the expression. * of the expression.
*/ */
protected static class ExpressionDMData implements IExpressionDMData { protected static class ExpressionDMData implements IExpressionDMDataExtension {
// This is the relative expression, such as the name of a field within a structure, // This is the relative expression, such as the name of a field within a structure,
// in contrast to the fully-qualified expression contained in the ExpressionDMC, // in contrast to the fully-qualified expression contained in the ExpressionDMC,
// which refers to the full name, including parent structure. // which refers to the full name, including parent structure.
@ -387,7 +388,14 @@ public class MIExpressions extends AbstractDsfService implements IExpressions2,
public boolean isEditable() { public boolean isEditable() {
return editable; return editable;
} }
/**
* @since 3.1
*/
public boolean hasChildren() {
return getNumChildren() > 0;
}
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other instanceof ExpressionDMData) { if (other instanceof ExpressionDMData) {
@ -1132,4 +1140,17 @@ public class MIExpressions extends AbstractDsfService implements IExpressions2,
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.dsf.debug.service.IExpressions3#getExpressionDataExtension(org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor)
*/
/** @since 3.1 */
public void getExpressionDataExtension(IExpressionDMContext dmc, final DataRequestMonitor<IExpressionDMDataExtension> rm) {
getExpressionData(dmc, new DataRequestMonitor<IExpressionDMData>(getExecutor(), rm) {
@Override
protected void handleSuccess() {
rm.setData((IExpressionDMDataExtension)getData());
super.handleSuccess();
}
});
}
} }

View file

@ -1652,36 +1652,15 @@ public class MIVariableManager implements ICommandControl {
new DataRequestMonitor<MIVariableObject>(fSession.getExecutor(), drm) { new DataRequestMonitor<MIVariableObject>(fSession.getExecutor(), drm) {
@Override @Override
protected void handleSuccess() { protected void handleSuccess() {
final MIVariableObject varObj = getData(); drm.setData(
if (varObj.isNumChildrenHintTrustworthy()) { new ExprMetaGetVarInfo(
drm.setData( exprCtx.getRelativeExpression(),
new ExprMetaGetVarInfo( getData().getNumChildrenHint(),
exprCtx.getRelativeExpression(), getData().getType(),
getData().getNumChildrenHint(), getData().getGDBType(),
getData().getType(), !getData().isComplex()));
getData().getGDBType(), drm.done();
!getData().isComplex())); processCommandDone(token, drm.getData());
drm.done();
processCommandDone(token, drm.getData());
} else {
// We have to ask for the children count because the hint could be wrong
varObj.getChildrenCount(
exprCtx,
new DataRequestMonitor<Integer>(fSession.getExecutor(), drm) {
@Override
protected void handleSuccess() {
drm.setData(
new ExprMetaGetVarInfo(
exprCtx.getRelativeExpression(),
getData(),
varObj.getType(),
varObj.getGDBType(),
!varObj.isComplex()));
drm.done();
processCommandDone(token, drm.getData());
}
});
}
} }
}); });
} else if (command instanceof ExprMetaGetAttributes) { } else if (command instanceof ExprMetaGetAttributes) {

View file

@ -38,6 +38,8 @@ import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData; import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData;
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMLocation; import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMLocation;
import org.eclipse.cdt.dsf.debug.service.IExpressions2; import org.eclipse.cdt.dsf.debug.service.IExpressions2;
import org.eclipse.cdt.dsf.debug.service.IExpressions3;
import org.eclipse.cdt.dsf.debug.service.IExpressions3.IExpressionDMDataExtension;
import org.eclipse.cdt.dsf.debug.service.IFormattedValues; import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent; import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent;
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent; import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
@ -893,7 +895,7 @@ public class VariableVMNode extends AbstractExpressionVMNode
final IExpressionDMContext expressionDMC = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExpressionDMContext.class); final IExpressionDMContext expressionDMC = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExpressionDMContext.class);
if ( expressionDMC != null ) { if (expressionDMC != null) {
final IExpressions expressionService = getServicesTracker().getService(IExpressions.class); final IExpressions expressionService = getServicesTracker().getService(IExpressions.class);
if (expressionService == null) { if (expressionService == null) {
@ -901,19 +903,37 @@ public class VariableVMNode extends AbstractExpressionVMNode
return; return;
} }
expressionService.getSubExpressionCount( if (expressionService instanceof IExpressions3) {
expressionDMC, ((IExpressions3)expressionService).getExpressionDataExtension(
new ViewerDataRequestMonitor<Integer>(getExecutor(), update) { expressionDMC,
@Override new ViewerDataRequestMonitor<IExpressionDMDataExtension>(getExecutor(), update) {
public void handleCompleted() { @Override
if (!isSuccess()) { protected void handleCompleted() {
handleFailedUpdate(update); if (!isSuccess()) {
return; handleFailedUpdate(update);
} return;
update.setHasChilren(getData() > 0); }
update.done(); IExpressionDMDataExtension data = getData();
} update.setHasChilren(data.hasChildren());
}); update.done();
}
});
}
else {
expressionService.getSubExpressionCount(
expressionDMC,
new ViewerDataRequestMonitor<Integer>(getExecutor(), update) {
@Override
public void handleCompleted() {
if (!isSuccess()) {
handleFailedUpdate(update);
return;
}
update.setHasChilren(getData() > 0);
update.done();
}
});
}
} }
else { else {
super.updateHasElementsInSessionThread(update); super.updateHasElementsInSessionThread(update);

View file

@ -0,0 +1,47 @@
/*******************************************************************************
* Copyright (c) 2010 CodeSourcery 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:
* CodeSourcery - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.service;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
/**
* This interface extends the expressions service with support for
* model data extension requests.
*
* @since 2.2
*/
public interface IExpressions3 extends IExpressions2 {
/**
* The model data interface extension.
*/
public interface IExpressionDMDataExtension extends IExpressionDMData {
/**
* @return Whether the expression has children.
*/
boolean hasChildren();
}
/**
* Retrieves the expression data extension object for the given
* expression context(<tt>dmc</tt>).
*
* @param dmc
* The ExpressionDMC for the expression to be evaluated.
* @param rm
* The data request monitor that will contain the requested data
*/
void getExpressionDataExtension(
IExpressionDMContext dmc,
DataRequestMonitor<IExpressionDMDataExtension> rm);
}