mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup: remove deprecated breakpoint methods and add annotations
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.jetbrains.python.debugger;
|
||||
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PyStackFrameInfo {
|
||||
|
||||
private final String myThreadId;
|
||||
@@ -15,6 +17,7 @@ public class PyStackFrameInfo {
|
||||
myPosition = position;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getThreadId() {
|
||||
return myThreadId;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public abstract class LineBreakpointCommand extends AbstractCommand {
|
||||
protected final int myLine;
|
||||
|
||||
|
||||
public LineBreakpointCommand(RemoteDebugger debugger,
|
||||
public LineBreakpointCommand(@NotNull RemoteDebugger debugger,
|
||||
String type, int commandCode,
|
||||
@NotNull final String file,
|
||||
final int line) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.intellij.xdebugger.frame.XValueChildrenList;
|
||||
import com.jetbrains.python.console.pydev.PydevCompletionVariant;
|
||||
import com.jetbrains.python.debugger.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
@@ -365,35 +366,37 @@ public class MultiProcessDebugger implements ProcessDebugger {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTempBreakpoint(String type, String file, int line) {
|
||||
public void setTempBreakpoint(@NotNull String type, @NotNull String file, int line) {
|
||||
for (ProcessDebugger d : allDebuggers()) {
|
||||
d.setTempBreakpoint(type, file, line);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTempBreakpoint(String file, int line) {
|
||||
public void removeTempBreakpoint(@NotNull String file, int line) {
|
||||
for (ProcessDebugger d : allDebuggers()) {
|
||||
d.removeTempBreakpoint(file, line);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBreakpoint(String typeId, String file, int line, String condition, String logExpression) {
|
||||
public void setBreakpoint(@NotNull String typeId, @NotNull String file, int line, @Nullable String condition,
|
||||
@Nullable String logExpression) {
|
||||
for (ProcessDebugger d : allDebuggers()) {
|
||||
d.setBreakpoint(typeId, file, line, condition, logExpression);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBreakpointWithFuncName(String typeId, String file, int line, String condition, String logExpression, String funcName) {
|
||||
public void setBreakpointWithFuncName(@NotNull String typeId, @NotNull String file, int line, @Nullable String condition,
|
||||
@Nullable String logExpression, @Nullable String funcName) {
|
||||
for (ProcessDebugger d : allDebuggers()) {
|
||||
d.setBreakpointWithFuncName(typeId, file, line, condition, logExpression, funcName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBreakpoint(String typeId, String file, int line) {
|
||||
public void removeBreakpoint(@NotNull String typeId, @NotNull String file, int line) {
|
||||
for (ProcessDebugger d : allDebuggers()) {
|
||||
d.removeBreakpoint(typeId, file, line);
|
||||
}
|
||||
|
||||
@@ -71,15 +71,16 @@ public interface ProcessDebugger {
|
||||
|
||||
void resumeOrStep(String threadId, ResumeOrStepCommand.Mode mode);
|
||||
|
||||
void setTempBreakpoint(String type, String file, int line);
|
||||
void setTempBreakpoint(@NotNull String type, @NotNull String file, int line);
|
||||
|
||||
void removeTempBreakpoint(String file, int line);
|
||||
void removeTempBreakpoint(@NotNull String file, int line);
|
||||
|
||||
void setBreakpoint(String typeId, String file, int line, String condition, String logExpression);
|
||||
void setBreakpoint(@NotNull String typeId, @NotNull String file, int line, @Nullable String condition, @Nullable String logExpression);
|
||||
|
||||
void setBreakpointWithFuncName(String typeId, String file, int line, String condition, String logExpression, String funcName);
|
||||
void setBreakpointWithFuncName(@NotNull String typeId, @NotNull String file, int line, @Nullable String condition,
|
||||
@Nullable String logExpression, @Nullable String funcName);
|
||||
|
||||
void removeBreakpoint(String typeId, String file, int line);
|
||||
void removeBreakpoint(@NotNull String typeId, @NotNull String file, int line);
|
||||
|
||||
void addCloseListener(RemoteDebuggerCloseListener remoteDebuggerCloseListener);
|
||||
|
||||
|
||||
@@ -433,7 +433,7 @@ public class RemoteDebugger implements ProcessDebugger {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTempBreakpoint(String type, String file, int line) {
|
||||
public void setTempBreakpoint(@NotNull String type, @NotNull String file, int line) {
|
||||
final SetBreakpointCommand command =
|
||||
new SetBreakpointCommand(this, type, file, line);
|
||||
execute(command); // set temp. breakpoint
|
||||
@@ -441,7 +441,7 @@ public class RemoteDebugger implements ProcessDebugger {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTempBreakpoint(String file, int line) {
|
||||
public void removeTempBreakpoint(@NotNull String file, int line) {
|
||||
String type = myTempBreakpoints.get(Pair.create(file, line));
|
||||
if (type != null) {
|
||||
final RemoveBreakpointCommand command = new RemoveBreakpointCommand(this, type, file, line);
|
||||
@@ -453,7 +453,8 @@ public class RemoteDebugger implements ProcessDebugger {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBreakpoint(String typeId, String file, int line, String condition, String logExpression) {
|
||||
public void setBreakpoint(@NotNull String typeId, @NotNull String file, int line, @Nullable String condition,
|
||||
@Nullable String logExpression) {
|
||||
final SetBreakpointCommand command =
|
||||
new SetBreakpointCommand(this, typeId, file, line,
|
||||
condition,
|
||||
@@ -462,7 +463,8 @@ public class RemoteDebugger implements ProcessDebugger {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBreakpointWithFuncName(String typeId, String file, int line, String condition, String logExpression, String funcName) {
|
||||
public void setBreakpointWithFuncName(@NotNull String typeId, @NotNull String file, int line, @Nullable String condition,
|
||||
@Nullable String logExpression, @Nullable String funcName) {
|
||||
final SetBreakpointCommand command =
|
||||
new SetBreakpointCommand(this, typeId, file, line,
|
||||
condition,
|
||||
@@ -472,7 +474,7 @@ public class RemoteDebugger implements ProcessDebugger {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBreakpoint(String typeId, String file, int line) {
|
||||
public void removeBreakpoint(@NotNull String typeId, @NotNull String file, int line) {
|
||||
final RemoveBreakpointCommand command =
|
||||
new RemoveBreakpointCommand(this, typeId, file, line);
|
||||
execute(command);
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class RemoveBreakpointCommand extends LineBreakpointCommand {
|
||||
|
||||
public RemoveBreakpointCommand(final RemoteDebugger debugger, @NotNull final String type, final String file, final int line) {
|
||||
public RemoveBreakpointCommand(final RemoteDebugger debugger, @NotNull final String type, @NotNull final String file, final int line) {
|
||||
super(debugger, type, REMOVE_BREAKPOINT, file, line);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class SetBreakpointCommand extends LineBreakpointCommand {
|
||||
public SetBreakpointCommand(@NotNull final RemoteDebugger debugger,
|
||||
@NotNull final String type,
|
||||
@NotNull final String file,
|
||||
@NotNull final int line) {
|
||||
final int line) {
|
||||
this(debugger, type, file, line, null, null, null);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class SetBreakpointCommand extends LineBreakpointCommand {
|
||||
public SetBreakpointCommand(@NotNull final RemoteDebugger debugger,
|
||||
@NotNull final String type,
|
||||
@NotNull final String file,
|
||||
@NotNull final int line,
|
||||
final int line,
|
||||
@Nullable final String condition,
|
||||
@Nullable final String logExpression) {
|
||||
super(debugger, type, SET_BREAKPOINT, file, line);
|
||||
@@ -32,7 +32,7 @@ public class SetBreakpointCommand extends LineBreakpointCommand {
|
||||
public SetBreakpointCommand(@NotNull final RemoteDebugger debugger,
|
||||
@NotNull final String type,
|
||||
@NotNull final String file,
|
||||
@NotNull final int line,
|
||||
final int line,
|
||||
@Nullable final String condition,
|
||||
@Nullable final String logExpression,
|
||||
@Nullable final String funcName) {
|
||||
|
||||
@@ -614,7 +614,7 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
|
||||
return PyDebugSupportUtils.canSaveToTemp(project, name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
private PyStackFrame currentFrame() throws PyDebuggerException {
|
||||
if (!isConnected()) {
|
||||
throw new PyDebuggerException("Disconnected");
|
||||
@@ -633,24 +633,27 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
|
||||
return frame;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getFunctionName(final XLineBreakpoint breakpoint) {
|
||||
if (breakpoint.getSourcePosition() == null) {
|
||||
return null;
|
||||
}
|
||||
final VirtualFile file = breakpoint.getSourcePosition().getFile();
|
||||
AccessToken lock = ApplicationManager.getApplication().acquireReadActionLock();
|
||||
try {
|
||||
final Document document = FileDocumentManager.getInstance().getDocument(file);
|
||||
final Project project = getSession().getProject();
|
||||
final String[] funcName = new String[1];
|
||||
if (document != null) {
|
||||
if (file.getFileType() == PythonFileType.INSTANCE) {
|
||||
PsiElement psiElement = XDebuggerUtil.getInstance().findContextElement(file, breakpoint.getSourcePosition().getOffset(),
|
||||
project, false);
|
||||
PyFunction function = PsiTreeUtil.getParentOfType(psiElement, PyFunction.class);
|
||||
if (function != null) {
|
||||
funcName[0] = function.getName();
|
||||
return function.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
return funcName[0];
|
||||
return null;
|
||||
}
|
||||
finally {
|
||||
lock.finish();
|
||||
@@ -660,9 +663,15 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
|
||||
public void addBreakpoint(final PySourcePosition position, final XLineBreakpoint breakpoint) {
|
||||
myRegisteredBreakpoints.put(position, breakpoint);
|
||||
if (isConnected()) {
|
||||
final String conditionExpression = breakpoint.getConditionExpression() == null
|
||||
? null
|
||||
: breakpoint.getConditionExpression().getExpression();
|
||||
final String logExpression = breakpoint.getLogExpressionObject() == null
|
||||
? null
|
||||
: breakpoint.getLogExpressionObject().getExpression();
|
||||
myDebugger.setBreakpointWithFuncName(breakpoint.getType().getId(), position.getFile(), position.getLine(),
|
||||
breakpoint.getCondition(),
|
||||
breakpoint.getLogExpression(),
|
||||
conditionExpression,
|
||||
logExpression,
|
||||
getFunctionName(breakpoint));
|
||||
}
|
||||
}
|
||||
@@ -824,7 +833,7 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
|
||||
try {
|
||||
PyStackFrame frame = currentFrame();
|
||||
|
||||
return frame != null ? frame.getSourcePosition() : null;
|
||||
return frame.getSourcePosition();
|
||||
}
|
||||
catch (PyDebuggerException e) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user