From e1c516fe2c0a74c3b70b832ed0b00f4c90072709 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Wed, 24 Feb 2010 10:07:08 +0000 Subject: [PATCH] Bug 303737 - [hover] The debug expression hover does not work for "this" --- .../debug/ui/editors/AbstractDebugTextHover.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/editors/AbstractDebugTextHover.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/editors/AbstractDebugTextHover.java index 7cee3f80b2b..e76ccbb6eba 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/editors/AbstractDebugTextHover.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/editors/AbstractDebugTextHover.java @@ -201,12 +201,18 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText IASTName name= ast.getNodeSelector(null).findEnclosingName(offset, length); if (name != null) { computeExpressionExtent(name, expressionPosition); + } else { + // not a name, but might still be an expression (e.g. this) + IASTNode node = ast.getNodeSelector(null).findFirstContainedNode(offset, length); + if (node instanceof IASTExpression) { + computeExpressionExtent(node, expressionPosition); + } } } return Status.OK_STATUS; } - private void computeExpressionExtent(IASTName name, Position pos) { - IASTNode node = name; + private void computeExpressionExtent(IASTNode node0, Position pos) { + IASTNode node = node0; while (node != null && !(node instanceof IASTExpression) && !(node instanceof IASTDeclaration)) { node = node.getParent(); } @@ -217,9 +223,9 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText pos.offset = loc.getNodeOffset(); pos.length = loc.getNodeLength(); } - } else { + } else if (node0 instanceof IASTName) { // fallback: use simple name - IASTNodeLocation loc = name.getFileLocation(); + IASTNodeLocation loc = node0.getFileLocation(); pos.offset = loc.getNodeOffset(); pos.length = loc.getNodeLength(); }