View | Details | Raw Unified | Return to bug 306553 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.cdt/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/viewmodel/DsfCastToTypeSupport.java (-1 / +47 lines)
Lines 13-22 Link Here
13
13
14
import java.util.HashMap;
14
import java.util.HashMap;
15
import java.util.Map;
15
import java.util.Map;
16
import java.util.concurrent.ExecutionException;
16
17
17
import org.eclipse.cdt.debug.core.model.ICastToArray;
18
import org.eclipse.cdt.debug.core.model.ICastToArray;
18
import org.eclipse.cdt.debug.core.model.ICastToType;
19
import org.eclipse.cdt.debug.core.model.ICastToType;
20
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
19
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
21
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
22
import org.eclipse.cdt.dsf.concurrent.Query;
20
import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent;
23
import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent;
21
import org.eclipse.cdt.dsf.datamodel.DMContexts;
24
import org.eclipse.cdt.dsf.datamodel.DMContexts;
22
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionChangedDMEvent;
25
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionChangedDMEvent;
Lines 57-64 Link Here
57
			this.memento = createCastedExpressionMemento(exprDMC);
60
			this.memento = createCastedExpressionMemento(exprDMC);
58
    	}
61
    	}
59
		
62
		
63
	    public class TestExpressions2Query extends Query<Boolean> {
64
65
	        public TestExpressions2Query() {
66
	            super();
67
	        }
68
69
	        @Override
70
	        protected void execute(final DataRequestMonitor<Boolean> rm) {
71
	            /*
72
	             * We're in another dispatch, so we must guard against executor
73
	             * shutdown again.
74
	             */
75
	            final DsfSession session = DsfSession.getSession(
76
	            		dmvmProvider.getSession().getId());
77
	            if (session == null) {
78
	                cancel(false);
79
	                rm.done();
80
	                return;
81
	            }
82
83
                DsfServicesTracker tracker = new DsfServicesTracker(
84
                		DsfUIPlugin.getBundleContext(), dmvmProvider.getSession().getId());
85
                IExpressions2 expressions2 = tracker.getService(IExpressions2.class);
86
                rm.setData(expressions2 != null);
87
                rm.done();
88
                tracker.dispose();
89
	        }
90
	    }
91
60
		private boolean isValid() {
92
		private boolean isValid() {
61
			return (serviceTracker.getService(IExpressions2.class) != null && exprDMC != null); 
93
	        TestExpressions2Query query = new TestExpressions2Query();
94
	        dmvmProvider.getSession().getExecutor().execute(query);
95
96
			try {
97
				/*
98
				 * Return value is irrelevant, any error would come through with an
99
				 * exception.
100
				 */
101
				return query.get();
102
			} catch (InterruptedException e) {
103
				assert false;
104
				return false;
105
			} catch (ExecutionException e) {
106
				return false;
107
			}
62
		}
108
		}
63
		
109
		
64
		private void throwIfNotValid() throws DebugException {
110
		private void throwIfNotValid() throws DebugException {
(-)a/org.eclipse.cdt/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/expression/ExpressionVMProvider.java (-6 / +23 lines)
Lines 248-259 Link Here
248
        VariableVMNode variableNode =  new VariableVMNode(this, getSession(), syncvarDataAccess);
248
        VariableVMNode variableNode =  new VariableVMNode(this, getSession(), syncvarDataAccess);
249
        addChildNodes(variableNode, new IExpressionVMNode[] {variableNode});
249
        addChildNodes(variableNode, new IExpressionVMNode[] {variableNode});
250
        
250
        
251
        /* Wire up the casting support if the IExpressions2 service is available. */
251
        /*
252
        DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), getSession().getId());
252
         * Hook up IExpressions2 if it exists.
253
        IExpressions2 expressions2 = tracker.getService(IExpressions2.class);
253
         */
254
        if (expressions2 != null) {
254
        hookUpCastingSupport(syncvarDataAccess, variableNode);
255
        	variableNode.setCastToTypeSupport(new DsfCastToTypeSupport(getSession(), this, syncvarDataAccess));
256
        }
257
255
258
        /*
256
        /*
259
         *  Tell the expression node which sub-nodes it will directly support.  It is very important
257
         *  Tell the expression node which sub-nodes it will directly support.  It is very important
Lines 273-278 Link Here
273
         */
271
         */
274
        setRootNode(rootNode);
272
        setRootNode(rootNode);
275
    }
273
    }
274
275
	private void hookUpCastingSupport(final SyncVariableDataAccess syncvarDataAccess,
276
			final VariableVMNode variableNode) {
277
		 try {
278
            getSession().getExecutor().execute(new DsfRunnable() {
279
                public void run() {
280
                    DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), getSession().getId());
281
                    IExpressions2 expressions2 = tracker.getService(IExpressions2.class);
282
                    if (expressions2 != null) {
283
                    	variableNode.setCastToTypeSupport(new DsfCastToTypeSupport(
284
                    			getSession(), ExpressionVMProvider.this, syncvarDataAccess));
285
                    }
286
                    tracker.dispose();
287
                }
288
            });
289
        } catch (RejectedExecutionException e) {
290
            // Session disposed, ignore.
291
        }
292
	}
276
    
293
    
277
    /**
294
    /**
278
     * Finds the expression node which can parse the given expression.  This 
295
     * Finds the expression node which can parse the given expression.  This 
(-)a/org.eclipse.cdt/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/variable/VariableVMProvider.java (-5 / +21 lines)
Lines 101-117 Link Here
101
        addChildNodes(rootNode, new IVMNode[] { subExpressioNode });
101
        addChildNodes(rootNode, new IVMNode[] { subExpressioNode });
102
        
102
        
103
        // Wire up the casting support if the IExpressions2 service is available.
103
        // Wire up the casting support if the IExpressions2 service is available.
104
        DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), getSession().getId());
104
        hookUpCastingSupport(varAccess, subExpressioNode);
105
        IExpressions2 expressions2 = tracker.getService(IExpressions2.class);
106
        if (expressions2 != null) {
107
        	subExpressioNode.setCastToTypeSupport(new DsfCastToTypeSupport(getSession(), this, varAccess));
108
        }
109
105
110
        // Configure the sub-expression node to be a child of itself.  This way the content
106
        // Configure the sub-expression node to be a child of itself.  This way the content
111
        // provider will recursively drill-down the variable hierarchy.
107
        // provider will recursively drill-down the variable hierarchy.
112
        addChildNodes(subExpressioNode, new IVMNode[] { subExpressioNode });
108
        addChildNodes(subExpressioNode, new IVMNode[] { subExpressioNode });
113
    }
109
    }
114
110
111
	private void hookUpCastingSupport(final SyncVariableDataAccess syncvarDataAccess,
112
			final VariableVMNode variableNode) {
113
		 try {
114
            getSession().getExecutor().execute(new DsfRunnable() {
115
                public void run() {
116
                    DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), getSession().getId());
117
                    IExpressions2 expressions2 = tracker.getService(IExpressions2.class);
118
                    if (expressions2 != null) {
119
                    	variableNode.setCastToTypeSupport(new DsfCastToTypeSupport(
120
                    			getSession(), VariableVMProvider.this, syncvarDataAccess));
121
                    }
122
                    tracker.dispose();
123
                }
124
            });
125
        } catch (RejectedExecutionException e) {
126
            // Session disposed, ignore.
127
        }
128
	}
129
    
130
115
    @Override
131
    @Override
116
    public IColumnPresentation createColumnPresentation(IPresentationContext context, Object element) {
132
    public IColumnPresentation createColumnPresentation(IPresentationContext context, Object element) {
117
        return new VariableColumnPresentation();
133
        return new VariableColumnPresentation();

Return to bug 306553