mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-158467 Check that selection in the editor is changed
This commit is contained in:
+18
-9
@@ -26,7 +26,6 @@ import com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import com.intellij.xdebugger.XDebuggerBundle;
|
||||
@@ -46,13 +45,13 @@ import com.intellij.xdebugger.impl.ui.tree.XDebuggerTreeRestorer;
|
||||
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTreeState;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XStackFrameNode;
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.XValueContainerNode;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -130,7 +129,7 @@ public abstract class XVariablesViewBase extends XDebugView {
|
||||
if (fileEditor instanceof PsiAwareTextEditorImpl) {
|
||||
final Editor editor = ((PsiAwareTextEditorImpl)fileEditor).getEditor();
|
||||
removeSelectionListener();
|
||||
mySelectionListener = new MySelectionListener(editor, stackFrame, project);
|
||||
mySelectionListener = new MySelectionListener(editor, stackFrame, project, myTreePanel);
|
||||
editor.getSelectionModel().addSelectionListener(mySelectionListener);
|
||||
}
|
||||
}
|
||||
@@ -178,15 +177,23 @@ public abstract class XVariablesViewBase extends XDebugView {
|
||||
DnDManager.getInstance().unregisterSource(myTreePanel, getTree());
|
||||
}
|
||||
|
||||
private class MySelectionListener implements SelectionListener {
|
||||
private static class MySelectionListener implements SelectionListener {
|
||||
private static final Collection<String> SIDE_EFFECT_PRODUCERS = StreamEx.of("exec(", "++", "--", "=").toList();
|
||||
private static final Set<String> IGNORED_TEXTS = StreamEx.of("", ";", "()").toSet();
|
||||
|
||||
private final Editor myEditor;
|
||||
private final XStackFrame myStackFrame;
|
||||
private final Project myProject;
|
||||
private final XDebuggerTreePanel myTreePanel;
|
||||
|
||||
public MySelectionListener(Editor editor, XStackFrame stackFrame, Project project) {
|
||||
public MySelectionListener(Editor editor,
|
||||
XStackFrame stackFrame,
|
||||
Project project,
|
||||
XDebuggerTreePanel panel) {
|
||||
myEditor = editor;
|
||||
myStackFrame = stackFrame;
|
||||
myProject = project;
|
||||
myTreePanel = panel;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
@@ -198,9 +205,11 @@ public abstract class XVariablesViewBase extends XDebugView {
|
||||
if (!Registry.is("debugger.valueTooltipAutoShowOnSelection") || myEditor.getCaretModel().getCaretCount() > 1) {
|
||||
return;
|
||||
}
|
||||
final String text = myEditor.getDocument().getText(e.getNewRange());
|
||||
if (!StringUtil.isEmpty(text) && !(text.contains("exec(") || text.contains("++") || text.contains("--") || text.contains("="))) {
|
||||
final XDebugSession session = getSession(getTree());
|
||||
|
||||
final String text = myEditor.getDocument().getText(e.getNewRange()).trim();
|
||||
final boolean isSelectionChanged = e.getNewRanges().length == 1 && !Objects.equals(e.getNewRange(), e.getOldRange());
|
||||
if (isSelectionChanged && !IGNORED_TEXTS.contains(text) && SIDE_EFFECT_PRODUCERS.stream().noneMatch(text::contains)) {
|
||||
final XDebugSession session = getSession(myTreePanel.getTree());
|
||||
if (session == null) return;
|
||||
XDebuggerEvaluator evaluator = myStackFrame.getEvaluator();
|
||||
if (evaluator == null) return;
|
||||
|
||||
Reference in New Issue
Block a user