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:
parent
e930dca1e9
commit
5a7c2c617e
4 changed files with 115 additions and 48 deletions
|
@ -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.IExpressions;
|
||||
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.IRunControl;
|
||||
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.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.IStack.IFrameDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.command.CommandCache;
|
||||
|
@ -67,7 +68,7 @@ import org.osgi.framework.BundleContext;
|
|||
*
|
||||
* @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
|
||||
|
@ -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
|
||||
* 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,
|
||||
// in contrast to the fully-qualified expression contained in the ExpressionDMC,
|
||||
// which refers to the full name, including parent structure.
|
||||
|
@ -388,6 +389,13 @@ public class MIExpressions extends AbstractDsfService implements IExpressions2,
|
|||
return editable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 3.1
|
||||
*/
|
||||
public boolean hasChildren() {
|
||||
return getNumChildren() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1652,8 +1652,6 @@ public class MIVariableManager implements ICommandControl {
|
|||
new DataRequestMonitor<MIVariableObject>(fSession.getExecutor(), drm) {
|
||||
@Override
|
||||
protected void handleSuccess() {
|
||||
final MIVariableObject varObj = getData();
|
||||
if (varObj.isNumChildrenHintTrustworthy()) {
|
||||
drm.setData(
|
||||
new ExprMetaGetVarInfo(
|
||||
exprCtx.getRelativeExpression(),
|
||||
|
@ -1663,25 +1661,6 @@ public class MIVariableManager implements ICommandControl {
|
|||
!getData().isComplex()));
|
||||
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) {
|
||||
|
|
|
@ -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.IExpressionDMLocation;
|
||||
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.IMemory.IMemoryChangedEvent;
|
||||
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);
|
||||
|
||||
if ( expressionDMC != null ) {
|
||||
if (expressionDMC != null) {
|
||||
final IExpressions expressionService = getServicesTracker().getService(IExpressions.class);
|
||||
|
||||
if (expressionService == null) {
|
||||
|
@ -901,6 +903,23 @@ public class VariableVMNode extends AbstractExpressionVMNode
|
|||
return;
|
||||
}
|
||||
|
||||
if (expressionService instanceof IExpressions3) {
|
||||
((IExpressions3)expressionService).getExpressionDataExtension(
|
||||
expressionDMC,
|
||||
new ViewerDataRequestMonitor<IExpressionDMDataExtension>(getExecutor(), update) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
if (!isSuccess()) {
|
||||
handleFailedUpdate(update);
|
||||
return;
|
||||
}
|
||||
IExpressionDMDataExtension data = getData();
|
||||
update.setHasChilren(data.hasChildren());
|
||||
update.done();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
expressionService.getSubExpressionCount(
|
||||
expressionDMC,
|
||||
new ViewerDataRequestMonitor<Integer>(getExecutor(), update) {
|
||||
|
@ -915,6 +934,7 @@ public class VariableVMNode extends AbstractExpressionVMNode
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.updateHasElementsInSessionThread(update);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
Loading…
Add table
Reference in a new issue