How to add breakpoints programmatically

I’m trying to add breakpoints programmatically using the following code snippet:

val breakpoint = XDebuggerManager.getInstance(project).breakpointManager.addLineBreakpoint(
                    PhpLineBreakpointType.getInstance(),
                    vFile.url,
                    lineIndex,
                    PhpLineBreakpointType.getInstance().createBreakpointProperties(vFile, lineIndex),
                    false
                ) as? XLineBreakpoint<*> ?: continue

                breakpoint.isEnabled = bp.isEnabled
                breakpoint.suspendPolicy = bp.suspend
                bp.condition?.let { breakpoint.conditionExpression = XExpressionImpl.fromText(it) }
                bp.logExpression?.let { breakpoint.logExpressionObject = XExpressionImpl.fromText(it) }
                breakpoint.isLogMessage = bp.logMessage

The breakpoints are created successfully and appear in Run | View Breakpoints, but they are not shown in the editor gutter right away. Interestingly, once I interact with any of the breakpoints in the dialog (e.g., select one in the tree), all of them are then displayed correctly in the editor.

I’ve looked into the IntelliJ IDEA Community Edition source code for a way to trigger a UI update, but many breakpoint-related mechanisms rely on internal APIs that aren’t accessible from plugin code. So far, I haven’t found a way to force the UI refresh for breakpoints after adding them programmatically.

Is there a recommended approach to programmatically refresh the editor UI or notify the system after breakpoints are added?

@bohdan.harniuk Can you please check whether it will work if you only add the breakpoint without configuring it (isEnabled, suspendPolicy, etc)?

If it does not, please debug inside addLineBreakpoint and check whether it will get to com.intellij.xdebugger.impl.breakpoints.XLineBreakpointManager#registerBreakpoint. If so, the value of initUI should be true

1 Like

@maksim.zuev Thank you for your response.

It seems to behave differently when the plugin is running on PS 2024.3.5 compared to PS 2025.1.4. Registration occurs for both IDE versions, but the results differ. In PS 2024.3.5, the issue is reproducible almost every time, whereas in PS 2025.1.4, registration always succeeds and I cannot reproduce the problem.

When debugging, everything appears similar in the method where XLineBreakpointManager#registerBreakpoint is called, so there may be some difference in how it works under the hood.

I’m not sure if it’s worth continuing the investigation, as everything works as expected in the newer IDE versions.

1 Like