# How to add breakpoints programmatically

**URL:** <https://platform.jetbrains.com/t/how-to-add-breakpoints-programmatically/2456>\
**Category:** IntelliJ Platform\
**Created:** [August 6, 2025, 6:15am UTC](https://platform.jetbrains.com/t/how-to-add-breakpoints-programmatically/2456 "2025-08-06T06:15:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bohdan.harniuk](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/bohdan.harniuk/32/147_2.png) [@bohdan.harniuk](https://platform.jetbrains.com/u/bohdan.harniuk)\
**Post date:** [August 6, 2025, 6:15am UTC](https://platform.jetbrains.com/t/how-to-add-breakpoints-programmatically/2456/1 "2025-08-06T06:15:53Z")

</div>

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

```auto
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?

---

<div class="post-metadata">

**Author:** ![maksim.zuev](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/maksim.zuev/32/1787_2.png) [@maksim.zuev](https://platform.jetbrains.com/u/maksim.zuev)\
**Post date:** [August 14, 2025, 9:36am UTC](https://platform.jetbrains.com/t/how-to-add-breakpoints-programmatically/2456/3 "2025-08-14T09:36:34Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![bohdan.harniuk](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/bohdan.harniuk/32/147_2.png) [@bohdan.harniuk](https://platform.jetbrains.com/u/bohdan.harniuk)\
**Post date:** [August 14, 2025, 4:49pm UTC](https://platform.jetbrains.com/t/how-to-add-breakpoints-programmatically/2456/4 "2025-08-14T16:49:23Z")

</div>

@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.
