IDEA-121738 Shift-click in gutter doesn't create 'no suspend' breakpoint anymore

This commit is contained in:
Egor.Ushakov
2014-03-06 19:43:41 +04:00
parent a0a8fe71db
commit 364298f46a
3 changed files with 28 additions and 7 deletions
@@ -47,7 +47,7 @@ public abstract class XDebuggerUtil {
toggleLineBreakpoint(project, file, line, false);
}
public abstract void toggleLineBreakpoint(@NotNull Project project,
public abstract XLineBreakpoint toggleLineBreakpoint(@NotNull Project project,
@NotNull VirtualFile file,
int line,
boolean temporary);
@@ -59,7 +59,7 @@ public abstract class XDebuggerUtil {
toggleLineBreakpoint(project, type, file, line, false);
}
public abstract <P extends XBreakpointProperties> void toggleLineBreakpoint(@NotNull Project project,
public abstract <P extends XBreakpointProperties> XLineBreakpoint toggleLineBreakpoint(@NotNull Project project,
@NotNull XLineBreakpointType<P> type,
@NotNull VirtualFile file,
int line,
@@ -25,6 +25,7 @@ import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
@@ -74,7 +75,7 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
}
@Override
public void toggleLineBreakpoint(@NotNull final Project project, @NotNull final VirtualFile file, final int line, boolean temporary) {
public XLineBreakpoint toggleLineBreakpoint(@NotNull final Project project, @NotNull final VirtualFile file, final int line, boolean temporary) {
XLineBreakpointType<?> typeWinner = null;
for (XLineBreakpointType<?> type : getLineBreakpointTypes()) {
if (type.canPutAt(file, line, project) && (typeWinner == null || type.getPriority() > typeWinner.getPriority())) {
@@ -82,8 +83,9 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
}
}
if (typeWinner != null) {
toggleLineBreakpoint(project, typeWinner, file, line, temporary);
return toggleLineBreakpoint(project, typeWinner, file, line, temporary);
}
return null;
}
@Override
@@ -97,11 +99,12 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
}
@Override
public <P extends XBreakpointProperties> void toggleLineBreakpoint(@NotNull final Project project,
public <P extends XBreakpointProperties> XLineBreakpoint toggleLineBreakpoint(@NotNull final Project project,
@NotNull final XLineBreakpointType<P> type,
@NotNull final VirtualFile file,
final int line,
final boolean temporary) {
final Ref<XLineBreakpoint> res = new Ref<XLineBreakpoint>();
new WriteAction() {
@Override
protected void run(@NotNull final Result result) {
@@ -112,10 +115,11 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
}
else {
P properties = type.createBreakpointProperties(file, line);
breakpointManager.addLineBreakpoint(type, file.getUrl(), line, properties, temporary);
res.set(breakpointManager.addLineBreakpoint(type, file.getUrl(), line, properties, temporary));
}
}
}.execute();
return res.get();
}
@Override
@@ -26,6 +26,7 @@ import com.intellij.openapi.editor.colors.EditorColorsAdapter;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.event.*;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.util.EditorUtil;
import com.intellij.openapi.editor.markup.MarkupEditorFilterFactory;
import com.intellij.openapi.editor.markup.RangeHighlighter;
@@ -49,7 +50,10 @@ import com.intellij.util.ui.update.MergingUpdateQueue;
import com.intellij.util.ui.update.Update;
import com.intellij.xdebugger.XDebuggerManager;
import com.intellij.xdebugger.XDebuggerUtil;
import com.intellij.xdebugger.breakpoints.SuspendPolicy;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import gnu.trove.TIntHashSet;
import org.jetbrains.annotations.NotNull;
@@ -271,7 +275,20 @@ public class XLineBreakpointManager {
@Override
public void run() {
if (!myProject.isDisposed() && myProject.isInitialized() && file.isValid()) {
XDebuggerUtil.getInstance().toggleLineBreakpoint(myProject, file, line, mouseEvent.isAltDown());
XLineBreakpoint breakpoint =
XDebuggerUtil.getInstance().toggleLineBreakpoint(myProject, file, line, mouseEvent.isAltDown());
if (!mouseEvent.isAltDown() && mouseEvent.isShiftDown() && breakpoint != null) {
breakpoint.setSuspendPolicy(SuspendPolicy.NONE);
String selection = editor.getSelectionModel().getSelectedText();
if (selection != null) {
breakpoint.setLogExpression(selection);
}
else {
breakpoint.setLogMessage(true);
}
// edit breakpoint
DebuggerUIUtil.showXBreakpointEditorBalloon(myProject, mouseEvent.getPoint(), ((EditorEx)editor).getGutterComponentEx(), false, breakpoint);
}
}
}
});