mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-17 21:25:58 +02:00
Bug 303737 - [hover] The debug expression hover does not work for "this"
This commit is contained in:
parent
bead75a3d1
commit
e1c516fe2c
1 changed files with 10 additions and 4 deletions
|
@ -201,12 +201,18 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText
|
||||||
IASTName name= ast.getNodeSelector(null).findEnclosingName(offset, length);
|
IASTName name= ast.getNodeSelector(null).findEnclosingName(offset, length);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
computeExpressionExtent(name, expressionPosition);
|
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;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
private void computeExpressionExtent(IASTName name, Position pos) {
|
private void computeExpressionExtent(IASTNode node0, Position pos) {
|
||||||
IASTNode node = name;
|
IASTNode node = node0;
|
||||||
while (node != null && !(node instanceof IASTExpression) && !(node instanceof IASTDeclaration)) {
|
while (node != null && !(node instanceof IASTExpression) && !(node instanceof IASTDeclaration)) {
|
||||||
node = node.getParent();
|
node = node.getParent();
|
||||||
}
|
}
|
||||||
|
@ -217,9 +223,9 @@ public abstract class AbstractDebugTextHover implements ICEditorTextHover, IText
|
||||||
pos.offset = loc.getNodeOffset();
|
pos.offset = loc.getNodeOffset();
|
||||||
pos.length = loc.getNodeLength();
|
pos.length = loc.getNodeLength();
|
||||||
}
|
}
|
||||||
} else {
|
} else if (node0 instanceof IASTName) {
|
||||||
// fallback: use simple name
|
// fallback: use simple name
|
||||||
IASTNodeLocation loc = name.getFileLocation();
|
IASTNodeLocation loc = node0.getFileLocation();
|
||||||
pos.offset = loc.getNodeOffset();
|
pos.offset = loc.getNodeOffset();
|
||||||
pos.length = loc.getNodeLength();
|
pos.length = loc.getNodeLength();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue