How to set breakpoints with line and filepath
Answered
I am developing a plugin.
I have the filename and a line number which I want to use to set a breakpoint in the program corresponding to that file (like I can do it as a use by clicking on the left side of the line in the editor). For now it can be specific to Java programs.
I tried the following, but it doesn't seem to have any effect (though also no error or exceptions as far as I can see):
static void addBreakpoints(@NotNull Project project){
Runnable r = ()-> {
var breakPointManager = XDebuggerManager.getInstance(project).getBreakpointManager();
XLineBreakpointType<?> lineBreakPointType = null;
for (var type : XDebuggerUtil.getInstance().getLineBreakpointTypes()) {
if (type.getId().equals("java-line")) {
lineBreakPointType = type;
}
}
if (lineBreakPointType == null)
return;
breakPointManager.addLineBreakpoint(
lineBreakPointType,
"/home/user/IdeaProjects/untitled1/src/Main.java",
14,
null,
true
);
};
WriteCommandAction.runWriteCommandAction(project, r);
}
What am I missing?
Please sign in to leave a comment.
Okay, I am now using
which works fine.