|
Lines 13-23
Link Here
|
| 13 |
import java.util.regex.Matcher; |
13 |
import java.util.regex.Matcher; |
| 14 |
import java.util.regex.Pattern; |
14 |
import java.util.regex.Pattern; |
| 15 |
|
15 |
|
|
|
16 |
import org.eclipse.cdt.core.CCorePlugin; |
| 17 |
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; |
| 18 |
import org.eclipse.cdt.core.model.CoreModel; |
| 19 |
import org.eclipse.cdt.core.model.ITranslationUnit; |
| 16 |
import org.eclipse.cdt.debug.core.model.ICStackFrame; |
20 |
import org.eclipse.cdt.debug.core.model.ICStackFrame; |
|
|
21 |
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget; |
| 17 |
import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; |
22 |
import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; |
| 18 |
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; |
23 |
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; |
| 19 |
import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover; |
24 |
import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover; |
|
|
25 |
import org.eclipse.core.resources.IFile; |
| 26 |
import org.eclipse.core.resources.IProject; |
| 27 |
import org.eclipse.core.runtime.CoreException; |
| 20 |
import org.eclipse.core.runtime.IAdaptable; |
28 |
import org.eclipse.core.runtime.IAdaptable; |
|
|
29 |
import org.eclipse.core.runtime.Path; |
| 21 |
import org.eclipse.debug.core.DebugException; |
30 |
import org.eclipse.debug.core.DebugException; |
| 22 |
import org.eclipse.debug.ui.IDebugUIConstants; |
31 |
import org.eclipse.debug.ui.IDebugUIConstants; |
| 23 |
import org.eclipse.jface.text.BadLocationException; |
32 |
import org.eclipse.jface.text.BadLocationException; |
|
Lines 147-152
Link Here
|
| 147 |
if (match_found) { |
156 |
if (match_found) { |
| 148 |
return null; |
157 |
return null; |
| 149 |
} |
158 |
} |
|
|
159 |
if (!isValidHoverSymbol(hoverRegion)) |
| 160 |
return null; |
| 150 |
StringBuffer buffer = new StringBuffer(); |
161 |
StringBuffer buffer = new StringBuffer(); |
| 151 |
String result = evaluateExpression(frame, expression); |
162 |
String result = evaluateExpression(frame, expression); |
| 152 |
if (result == null) |
163 |
if (result == null) |
|
Lines 165-170
Link Here
|
| 165 |
} |
176 |
} |
| 166 |
return null; |
177 |
return null; |
| 167 |
} |
178 |
} |
|
|
179 |
|
| 180 |
/** |
| 181 |
* Checks if the hovered symbol is valid for evaluation. |
| 182 |
* |
| 183 |
*/ |
| 184 |
public boolean isValidHoverSymbol(IRegion hoverRegion){ |
| 185 |
boolean isValid = false; |
| 186 |
int offset = hoverRegion.getOffset(); |
| 187 |
int length = hoverRegion.getLength(); |
| 188 |
IProject project = ((CDebugTarget)(getFrame().getDebugTarget())).getProject(); |
| 189 |
IFile inputFile = project.getFile(new Path(getFrame().getFile().substring(getFrame().getFile().indexOf('/')))); |
| 190 |
DebugTextVisitor astVisitor = new DebugTextVisitor(); |
| 191 |
astVisitor.shouldVisitNames = true; |
| 192 |
astVisitor.shouldVisitExpressions = true; |
| 193 |
|
| 194 |
if (CoreModel.isTranslationUnit(inputFile)) { |
| 195 |
try { |
| 196 |
ITranslationUnit tu = (ITranslationUnit) CCorePlugin.getDefault().getCoreModel().create(inputFile); |
| 197 |
IASTTranslationUnit ast = tu.getAST(null,ITranslationUnit.AST_SKIP_ALL_HEADERS); |
| 198 |
ast.accept(astVisitor); |
| 199 |
} catch (CoreException x) { |
| 200 |
CDebugUIPlugin.log(x); |
| 201 |
} |
| 202 |
} |
| 203 |
if (astVisitor.containsExpression(offset, length)){ |
| 204 |
isValid = true; |
| 205 |
} |
| 206 |
return isValid; |
| 207 |
} |
| 168 |
|
208 |
|
| 169 |
/* |
209 |
/* |
| 170 |
* (non-Javadoc) |
210 |
* (non-Javadoc) |