37
|
1 |
/*******************************************************************************
|
|
2 |
* Copyright (c) 2000, 2007 QNX Software Systems and others.
|
|
3 |
* All rights reserved. This program and the accompanying materials
|
|
4 |
* are made available under the terms of the Eclipse Public License v1.0
|
|
5 |
* which accompanies this distribution, and is available at
|
|
6 |
* http://www.eclipse.org/legal/epl-v10.html
|
|
7 |
*
|
|
8 |
* Contributors:
|
|
9 |
* QNX Software Systems - Initial API and implementation
|
110
|
10 |
* Nokia - Refactored into CDI specific implementation of AbstractDebugTextHover
|
|
11 |
|
37
|
12 |
*******************************************************************************/
|
|
13 |
package org.eclipse.cdt.debug.internal.ui.editors;
|
|
14 |
|
|
15 |
import org.eclipse.cdt.debug.core.model.ICStackFrame;
|
110
|
16 |
import org.eclipse.cdt.debug.ui.editors.AbstractDebugTextHover;
|
37
|
17 |
import org.eclipse.core.runtime.IAdaptable;
|
|
18 |
import org.eclipse.debug.core.DebugException;
|
|
19 |
|
|
20 |
/**
|
|
21 |
* The text hovering support for C/C++ debugger.
|
|
22 |
*/
|
|
23 |
|
110
|
24 |
public class DebugTextHover extends AbstractDebugTextHover {
|
37
|
25 |
|
|
26 |
/**
|
|
27 |
* Returns the evaluation stack frame, or <code>null</code> if none.
|
|
28 |
*
|
|
29 |
* @return the evaluation stack frame, or <code>null</code> if none
|
|
30 |
*/
|
|
31 |
protected ICStackFrame getFrame() {
|
111
|
32 |
IAdaptable adaptable = getSelectionAdaptable();
|
|
33 |
if (adaptable != null) {
|
|
34 |
return (ICStackFrame) adaptable.getAdapter(ICStackFrame.class);
|
|
35 |
}
|
|
36 |
return null;
|
37
|
37 |
}
|
|
38 |
|
110
|
39 |
@Override
|
|
40 |
protected boolean canEvaluate() {
|
|
41 |
ICStackFrame frame = getFrame();
|
|
42 |
if (frame != null)
|
|
43 |
return frame.canEvaluate();
|
|
44 |
|
|
45 |
return false;
|
37
|
46 |
}
|
|
47 |
|
110
|
48 |
@Override
|
|
49 |
protected String evaluateExpression(String expression) {
|
|
50 |
ICStackFrame frame = getFrame();
|
|
51 |
String result = null;
|
|
52 |
try {
|
|
53 |
result = frame.evaluateExpressionToString(expression);
|
|
54 |
} catch (DebugException e) {
|
|
55 |
// ignore
|
37
|
56 |
}
|
110
|
57 |
return result;
|
37
|
58 |
}
|
|
59 |
}
|