|
13 | 13 | import org.eclipse.core.runtime.CoreException; |
14 | 14 | import org.eclipse.debug.core.model.IBreakpoint; |
15 | 15 | import org.eclipse.debug.core.model.LineBreakpoint; |
| 16 | +import org.eclipse.jdt.annotation.Nullable; |
16 | 17 | import org.eclipse.lsp4e.debug.DSPPlugin; |
17 | 18 |
|
18 | 19 | public class DSPLineBreakpoint extends LineBreakpoint { |
19 | 20 |
|
20 | 21 | public static final String ID = "org.eclipse.lsp4e.debug.breakpoints.markerType.lineBreakpoint"; |
21 | 22 |
|
| 23 | + /** Marker attribute key for a conditional expression. */ |
| 24 | + public static final String ATTR_CONDITION = "org.eclipse.lsp4e.debug.breakpoints.condition"; |
| 25 | + |
| 26 | + /** Marker attribute key for inline breakpoint column (1-based). */ |
| 27 | + public static final String ATTR_COLUMN = "org.eclipse.lsp4e.debug.breakpoints.column"; |
| 28 | + |
| 29 | + /** Marker attribute key for hit condition expression. */ |
| 30 | + public static final String ATTR_HIT_CONDITION = "org.eclipse.lsp4e.debug.breakpoints.hitCondition"; |
| 31 | + |
22 | 32 | public DSPLineBreakpoint() { |
23 | 33 | } |
24 | 34 |
|
@@ -48,4 +58,59 @@ public DSPLineBreakpoint(final IResource resource, String fileName, final int li |
48 | 58 | public String getModelIdentifier() { |
49 | 59 | return DSPPlugin.ID_DSP_DEBUG_MODEL; |
50 | 60 | } |
| 61 | + |
| 62 | + /** |
| 63 | + * @return the inline breakpoint column (1-based) or {@code -1} if unset. |
| 64 | + */ |
| 65 | + public int getColumn() { |
| 66 | + final IMarker m = getMarker(); |
| 67 | + return m == null ? -1 : m.getAttribute(ATTR_COLUMN, -1); |
| 68 | + } |
| 69 | + |
| 70 | + /** |
| 71 | + * Sets or clears the inline breakpoint column. Values <= 0 clear the column. |
| 72 | + */ |
| 73 | + public void setColumn(final int column) throws CoreException { |
| 74 | + final IMarker m = getMarker(); |
| 75 | + if (m != null) { |
| 76 | + m.setAttribute(ATTR_COLUMN, column <= 0 ? null : column); |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * @return the breakpoint condition or {@code null} if none. |
| 82 | + */ |
| 83 | + public @Nullable String getCondition() { |
| 84 | + final IMarker m = getMarker(); |
| 85 | + return m == null ? null : m.getAttribute(ATTR_CONDITION, (String) null); |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Sets or clears the breakpoint condition. A {@code null} or blank value clears |
| 90 | + * the condition. |
| 91 | + */ |
| 92 | + public void setCondition(final @Nullable String condition) throws CoreException { |
| 93 | + final IMarker m = getMarker(); |
| 94 | + if (m != null) { |
| 95 | + m.setAttribute(ATTR_CONDITION, condition == null || condition.isBlank() ? null : condition); |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + /** |
| 100 | + * @return the hit condition or {@code null} if none. |
| 101 | + */ |
| 102 | + public @Nullable String getHitCondition() { |
| 103 | + final IMarker m = getMarker(); |
| 104 | + return m == null ? null : m.getAttribute(ATTR_HIT_CONDITION, (String) null); |
| 105 | + } |
| 106 | + |
| 107 | + /** |
| 108 | + * Sets or clears the hit condition. A {@code null} or blank value clears it. |
| 109 | + */ |
| 110 | + public void setHitCondition(final @Nullable String hitCondition) throws CoreException { |
| 111 | + final IMarker m = getMarker(); |
| 112 | + if (m != null) { |
| 113 | + m.setAttribute(ATTR_HIT_CONDITION, hitCondition == null || hitCondition.isBlank() ? null : hitCondition); |
| 114 | + } |
| 115 | + } |
51 | 116 | } |
0 commit comments