mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
xdebugger: (testing) Make XDebuggerTestUtil.toggleBreakpoint() return breakpoint
This commit is contained in:
@@ -100,6 +100,14 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
|
||||
|
||||
@Override
|
||||
public void toggleLineBreakpoint(@NotNull final Project project, @NotNull final VirtualFile file, final int line, boolean temporary) {
|
||||
toggleAndReturnLineBreakpoint(project, file, line, temporary);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Promise<XLineBreakpoint> toggleAndReturnLineBreakpoint(@NotNull final Project project,
|
||||
@NotNull final VirtualFile file,
|
||||
final int line,
|
||||
boolean temporary) {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
XLineBreakpointType<?> typeWinner = null;
|
||||
for (XLineBreakpointType<?> type : getLineBreakpointTypes()) {
|
||||
@@ -108,8 +116,9 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
|
||||
}
|
||||
}
|
||||
if (typeWinner != null) {
|
||||
toggleLineBreakpoint(project, typeWinner, file, line, temporary);
|
||||
return toggleAndReturnLineBreakpoint(project, typeWinner, file, line, temporary);
|
||||
}
|
||||
return rejectedPromise();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,10 +132,20 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
|
||||
@NotNull final VirtualFile file,
|
||||
final int line,
|
||||
final boolean temporary) {
|
||||
toggleAndReturnLineBreakpoint(project, type, file, line, temporary);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <P extends XBreakpointProperties> Promise<XLineBreakpoint> toggleAndReturnLineBreakpoint(@NotNull final Project project,
|
||||
@NotNull final XLineBreakpointType<P> type,
|
||||
@NotNull final VirtualFile file,
|
||||
final int line,
|
||||
final boolean temporary) {
|
||||
XSourcePositionImpl position = XSourcePositionImpl.create(file, line);
|
||||
if (position != null) {
|
||||
toggleAndReturnLineBreakpoint(project, type, position, temporary, null, true);
|
||||
return toggleAndReturnLineBreakpoint(project, type, position, temporary, null, true);
|
||||
}
|
||||
return rejectedPromise();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.intellij.xdebugger.breakpoints.*;
|
||||
import com.intellij.xdebugger.evaluation.XDebuggerEvaluator;
|
||||
import com.intellij.xdebugger.frame.*;
|
||||
import com.intellij.xdebugger.impl.XDebugSessionImpl;
|
||||
import com.intellij.xdebugger.impl.XDebuggerUtilImpl;
|
||||
import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil;
|
||||
import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl;
|
||||
import com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl;
|
||||
@@ -42,6 +43,7 @@ import com.intellij.xdebugger.impl.frame.XStackFrameContainerEx;
|
||||
import org.intellij.lang.annotations.Language;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.concurrency.Promise;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
@@ -74,13 +76,17 @@ public class XDebuggerTestUtil {
|
||||
assertEquals(errorMessage, breakpoint.getErrorMessage());
|
||||
}
|
||||
|
||||
public static void toggleBreakpoint(Project project, VirtualFile file, int line) {
|
||||
new WriteAction() {
|
||||
@Nullable
|
||||
public static XLineBreakpoint toggleBreakpoint(Project project, VirtualFile file, int line) {
|
||||
return new WriteAction<XLineBreakpoint>() {
|
||||
@Override
|
||||
protected void run(@NotNull Result result) throws Throwable {
|
||||
XDebuggerUtil.getInstance().toggleLineBreakpoint(project, file, line);
|
||||
protected void run(@NotNull Result<XLineBreakpoint> result) throws Throwable {
|
||||
Promise<XLineBreakpoint> promise =
|
||||
((XDebuggerUtilImpl)XDebuggerUtil.getInstance()).toggleAndReturnLineBreakpoint(project, file, line, false);
|
||||
|
||||
promise.done(result::setResult);
|
||||
}
|
||||
}.execute();
|
||||
}.execute().getResultObject();
|
||||
}
|
||||
|
||||
public static <P extends XBreakpointProperties> XBreakpoint<P> insertBreakpoint(final Project project,
|
||||
|
||||
Reference in New Issue
Block a user