Skip to content

Commit 3d75a26

Browse files
SougandhSMohananRahul
authored andcommitted
Fix ClassCastException in WatchHandler
This commit prevents ClassCastException when `Watch` creation is done from child of an expression in Expressions View. Fixes : #2602
1 parent 24a9df3 commit 3d75a26

File tree

1 file changed

+7
-4
lines changed
  • debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions

1 file changed

+7
-4
lines changed

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchHandler.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
5757
if (structuredSelection instanceof TreeSelection treeSelection) {
5858
for (TreePath path : treeSelection.getPaths()) {
5959
List<IVariable> variables = new ArrayList<>();
60-
if (path.getSegmentCount() > 1) {
61-
for (int e = 0; e < path.getSegmentCount(); e++) {
62-
IVariable variable = (IVariable) path.getSegment(e);
63-
variables.add(variable);
60+
int segments = path.getSegmentCount();
61+
if (segments > 1) {
62+
for (int e = 0; e < segments; e++) {
63+
Object sel = path.getSegment(e);
64+
if (sel instanceof IVariable variable) {
65+
variables.add(variable);
66+
}
6467
}
6568
IWatchExpressionFactoryAdapter2 factory = getFactory2(variables);
6669
if (factory != null) {

0 commit comments

Comments
 (0)