/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package com.intellij.xdebugger.impl.frame.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.util.ObjectUtils;
import com.intellij.xdebugger.XExpression;
import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
import com.intellij.xdebugger.impl.frame.XWatchesView;
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl;
import org.jetbrains.annotations.NotNull;
-import java.util.List;
-
/**
* @author egor
*/
@Override
protected void perform(@NotNull AnActionEvent e, @NotNull XDebuggerTree tree, @NotNull XWatchesView watchesView) {
XDebuggerTreeNode root = tree.getRoot();
- List<? extends XValueNodeImpl> nodes = getSelectedNodes(tree, XValueNodeImpl.class);
- for (XValueNodeImpl node : nodes) {
- int index = root.getIndex(node);
- boolean isWatch = node instanceof WatchNode;
- XExpression expression = isWatch ? ((WatchNode)node).getExpression() :
- XExpressionImpl.fromText(node.getName());
- if (expression == null) continue;
- node.getValueContainer().calculateEvaluationExpression().done(
- expr -> DebuggerUIUtil.invokeLater(
- () -> watchesView.addWatchExpression(ObjectUtils.notNull(expr, expression), isWatch ? index + 1 : -1, true)));
-
+ for (XValueNodeImpl node : getSelectedNodes(tree, XValueNodeImpl.class)) {
+ node.getValueContainer().calculateEvaluationExpression().done(expr -> {
+ XExpression watchExpression = expr != null ? expr : XExpressionImpl.fromText(node.getName());
+ if (watchExpression != null) {
+ DebuggerUIUtil.invokeLater(
+ () -> watchesView.addWatchExpression(watchExpression, node instanceof WatchNode ? root.getIndex(node) + 1 : -1, true));
+ }
+ });
}
}
}