Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.WeakHashMap;
Expand Down Expand Up @@ -67,6 +68,8 @@ public class LineBreakpoint extends JPDABreakpoint {
/** Property name constant */
public static final String PROP_LINE_NUMBER = "lineNumber"; // NOI18N
/** Property name constant */
public static final String PROP_LAMBDA_INDEX = "lambdaIndex"; // NOI18N
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think property name/constant should match getter/setter:

Suggested change
public static final String PROP_LAMBDA_INDEX = "lambdaIndex"; // NOI18N
public static final String PROP_LAMBDA_INDEXES = "lambdaIndexes"; // NOI18N

/** Property name constant */
public static final String PROP_URL = "url"; // NOI18N
/** Property name constant. */
public static final String PROP_CONDITION = "condition"; // NOI18N
Expand All @@ -83,6 +86,9 @@ public class LineBreakpoint extends JPDABreakpoint {
/** Property name constant */
public static final String PROP_THREAD_FILTERS = "threadFilters"; // NOI18N

/**Lambda index value meaning the debugger should stop at locations outside of any lambda.*/
public static final int LAMBDA_INDEX_STOP_OUTSIDE = -1;

private static final Logger LOG = Logger.getLogger(LineBreakpoint.class.getName());

private String url = ""; // NOI18N
Expand All @@ -94,6 +100,7 @@ public class LineBreakpoint extends JPDABreakpoint {
private String className = null;
private Map<JPDADebugger,ObjectVariable[]> instanceFilters;
private Map<JPDADebugger,JPDAThread[]> threadFilters;
private int[] lambdaIndexes = new int[0];


private LineBreakpoint (String url) {
Expand Down Expand Up @@ -182,6 +189,29 @@ public void setLineNumber (int ln) {
Integer.valueOf(ln)
);
}

public int[] getLambdaIndexes() {
return lambdaIndexes.clone();
}

public void setLambdaIndexes(int[] li) {
int[] old;

li = li.clone();

synchronized (this) {
if (li == lambdaIndexes) {
return;
}
old = lambdaIndexes;
lambdaIndexes = li;
}
firePropertyChange (
PROP_LAMBDA_INDEX,
old,
li
);
}

/**
* Get the instance filter for a specific debugger session.
Expand Down Expand Up @@ -423,7 +453,7 @@ public String toString () {
if (fileName == null) {
fileName = url;
}
return "LineBreakpoint " + fileName + " : " + lineNumber;
return "LineBreakpoint " + fileName + " : " + lineNumber + (lambdaIndexes.length > 0 ? " lambda indices: " + Arrays.toString(lambdaIndexes) : "");
}

private static class LineBreakpointImpl extends LineBreakpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@
ACSD_TF_Line_Breakpoint_Line_Number=Line number
TTT_TF_Line_Breakpoint_Line_Number=Line number to stop at

L_Line_Breakpoint_Lambda_Index=Lambda &Indexes\:
ACSD_L_Line_Breakpoint_Lambda_Index=Lambda Indexes
ACSD_TF_Line_Breakpoint_Lambda_Index=Lambda Indexes
TTT_TF_Line_Breakpoint_Lambda_Index=Comma seperated lambda indexes to stop at\nempty: all locations\n-1: stop outside of lambda\n0-based index: break in that lambda expression

L_Line_Breakpoint_Condition=Co&ndition:
ACSD_L_Line_Breakpoint_Condition=Condition
ACSD_TF_Line_Breakpoint_Condition=Condition
Expand All @@ -242,6 +247,7 @@
MSG_No_Line_Number_Spec=Line number should be specified.
MSG_TooBig_Line_Number_Spec=The line number {0} is too big. Maximum line number is {1}.
MSG_NonPositive_Line_Number_Spec=A positive line number should be specified.
MSG_Invalid_Lambda_Index=Lambda index {0} is not a number.

MSG_Bad_Hit_Count_Filter_Spec=Wrong value of hit count filter: ''{0}''.
MSG_NonPositive_Hit_Count_Filter_Spec=A positive hit count filter should be specified.
Expand Down Expand Up @@ -317,3 +323,4 @@ ACSN_LineBreakpoint=Line Breakpoint properties
ACSN_FieldBreakpoint=Field Breakpoint properties
ACSN_ExceptionBreakpoint=Exception Breakpoint properties
TTT_ExceptionClassName=The class name representing the exception.
ACSN_TF_Line_Breakpoint_Lambda_Index=Lambda index
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.1" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>

<!--

Expand Down Expand Up @@ -135,6 +135,46 @@
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="tfLambdaIndexes"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="L_Line_Breakpoint_Lambda_Index" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
<AccessibilityProperties>
<Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="ACSD_L_Line_Breakpoint_Lambda_Index" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
</AccessibilityProperties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="4" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="3" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="17" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JTextField" name="tfLambdaIndexes">
<Properties>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="TTT_TF_Line_Breakpoint_Lambda_Index" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
<AccessibilityProperties>
<Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="ACSN_TF_Line_Breakpoint_Lambda_Index" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/debugger/jpda/ui/breakpoints/Bundle.properties" key="ACSD_TF_Line_Breakpoint_Lambda_Index" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
</AccessibilityProperties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="4" gridWidth="2" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="3" insetsLeft="3" insetsBottom="3" insetsRight="3" anchor="10" weightX="1.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="cPanel">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
Expand Down Expand Up @@ -130,6 +132,7 @@ public LineBreakpointPanel (LineBreakpoint b, boolean createBreakpoint) {
tfFileName.getPreferredSize().height));

tfLineNumber.setText(Integer.toString(b.getLineNumber()));
tfLambdaIndexes.setText(Arrays.stream(b.getLambdaIndexes()).mapToObj(String::valueOf).collect(Collectors.joining(", ")));
conditionsPanel = new ConditionsPanel(HELP_ID);
setupConditionPane();
conditionsPanel.showClassFilter(false);
Expand All @@ -143,6 +146,7 @@ public LineBreakpointPanel (LineBreakpoint b, boolean createBreakpoint) {

tfFileName.getDocument().addDocumentListener(validityDocumentListener);
tfLineNumber.getDocument().addDocumentListener(validityDocumentListener);
tfLambdaIndexes.getDocument().addDocumentListener(validityDocumentListener);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
controller.checkValid();
Expand Down Expand Up @@ -192,6 +196,8 @@ private void initComponents() {
tfFileName = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
tfLineNumber = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
tfLambdaIndexes = new javax.swing.JTextField();
cPanel = new javax.swing.JPanel();
pActions = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
Expand Down Expand Up @@ -248,6 +254,29 @@ private void initComponents() {
tfLineNumber.getAccessibleContext().setAccessibleName("Line number");
tfLineNumber.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TF_Line_Breakpoint_Line_Number")); // NOI18N

jLabel4.setLabelFor(tfLambdaIndexes);
org.openide.awt.Mnemonics.setLocalizedText(jLabel4, bundle.getString("L_Line_Breakpoint_Lambda_Index")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
pSettings.add(jLabel4, gridBagConstraints);
jLabel4.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_L_Line_Breakpoint_Lambda_Index")); // NOI18N

tfLambdaIndexes.setToolTipText(bundle.getString("TTT_TF_Line_Breakpoint_Lambda_Index")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 4;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);
pSettings.add(tfLambdaIndexes, gridBagConstraints);
tfLambdaIndexes.getAccessibleContext().setAccessibleName(bundle.getString("ACSN_TF_Line_Breakpoint_Lambda_Index")); // NOI18N
tfLambdaIndexes.getAccessibleContext().setAccessibleDescription(bundle.getString("ACSD_TF_Line_Breakpoint_Lambda_Index")); // NOI18N

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
Expand Down Expand Up @@ -286,10 +315,12 @@ private void initComponents() {
private javax.swing.JPanel cPanel;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel pActions;
private javax.swing.JPanel pSettings;
private javax.swing.JTextField tfFileName;
private javax.swing.JTextField tfLambdaIndexes;
private javax.swing.JTextField tfLineNumber;
// End of variables declaration//GEN-END:variables

Expand Down Expand Up @@ -319,6 +350,14 @@ public boolean ok () {
logger.fine(" => URL = '"+url+"'");
breakpoint.setURL((url != null) ? url.toString() : path);
breakpoint.setLineNumber(Integer.parseInt(tfLineNumber.getText().trim()));
String lambdaIndexText = tfLambdaIndexes.getText().trim();
if (lambdaIndexText.isEmpty()) {
breakpoint.setLambdaIndexes(new int[0]);
} else {
breakpoint.setLambdaIndexes(Arrays.stream(lambdaIndexText.split(", *"))
.mapToInt(v -> Integer.parseInt(v))
.toArray());
}
breakpoint.setCondition (conditionsPanel.getCondition());
breakpoint.setHitCountFilter(conditionsPanel.getHitCount(),
conditionsPanel.getHitCountFilteringStyle());
Expand Down Expand Up @@ -385,6 +424,18 @@ private void checkValid() {
setValid(false);
return ;
}
String lambdaIndexText = tfLambdaIndexes.getText().trim();
if (!lambdaIndexText.isEmpty()) {
for (String index : lambdaIndexText.split(", *")) {
try {
Integer.parseInt(index);
} catch (NumberFormatException e) {
setErrorMessage(NbBundle.getMessage(LineBreakpointPanel.class, "MSG_Invalid_Lambda_Index", index));
setValid(false);
return ;
}
}
}
setErrorMessage(null);
setValid(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@

package org.netbeans.modules.debugger.jpda.ui.models;

import java.util.Arrays;
import java.util.Map;
import java.util.Vector;
import java.util.WeakHashMap;
import java.util.stream.Collectors;
import org.netbeans.api.debugger.Breakpoint;
import org.netbeans.api.debugger.Breakpoint.VALIDITY;
import org.netbeans.api.debugger.DebuggerManager;
Expand Down Expand Up @@ -107,12 +109,26 @@ public String getDisplayName (Object o) throws UnknownTypeException {
}
return bold (
b,
NbBundle.getMessage (
BreakpointsNodeModel.class,
"CTL_Line_Breakpoint",
EditorContextBridge.getFileName (b),
line
)
b.getLambdaIndexes().length > 0 ?
NbBundle.getMessage (
BreakpointsNodeModel.class,
"CTL_Line_Lambda_Breakpoint",
EditorContextBridge.getFileName (b),
line,
Arrays.stream(b.getLambdaIndexes())
.mapToObj(i -> switch (i) {
case LineBreakpoint.LAMBDA_INDEX_STOP_OUTSIDE -> NbBundle.getMessage(BreakpointsNodeModel.class, "CTL_Line_Lambda_Breakpoint_Outside");
default -> NbBundle.getMessage(BreakpointsNodeModel.class, "CTL_Line_Lambda_Breakpoint_OnLambda", i + 1);
})
.collect(Collectors.joining(", "))
)
:
NbBundle.getMessage (
BreakpointsNodeModel.class,
"CTL_Line_Breakpoint",
EditorContextBridge.getFileName (b),
line
)
);
} else
if (o instanceof ThreadBreakpoint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ ACSD_Breakpoint_Customizer_Dialog=Customize this breakpoint's properties

#BreakpointsNodeModel
CTL_Line_Breakpoint=Line {0}:{1}
CTL_Line_Lambda_Breakpoint=Line {0}:{1}, stopping: {2}
CTL_Line_Lambda_Breakpoint_Outside=outside lambdas
CTL_Line_Lambda_Breakpoint_OnLambda=on {0}. lambda
CTL_Thread_Started_Breakpoint=Thread started
CTL_Thread_Death_Breakpoint=Thread death
CTL_Thread_Breakpoint=Thread start / death
Expand Down
3 changes: 2 additions & 1 deletion java/debugger.jpda/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,11 @@
</test-type>
</test-dependencies>
<friend-packages>
<friend>org.netbeans.modules.javafx.debugger</friend>
<friend>org.netbeans.modules.debugger.jpda.truffle</friend>
<friend>org.netbeans.modules.debugger.jpda.ui</friend>
<friend>org.netbeans.modules.debugger.jpda.visual</friend>
<friend>org.netbeans.modules.java.lsp.server</friend>
<friend>org.netbeans.modules.javafx.debugger</friend>
<friend>org.netbeans.modules.jshell.support</friend>
<package>org.netbeans.modules.debugger.jpda</package>
<package>org.netbeans.modules.debugger.jpda.actions</package>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -108,6 +109,7 @@ public Object read (String typeID, Properties properties) {
LineBreakpoint lb = LineBreakpoint.create ("", 0);
lb.setURL(properties.getString (LineBreakpoint.PROP_URL, null));
lb.setLineNumber(properties.getInt (LineBreakpoint.PROP_LINE_NUMBER, 1));
lb.setLambdaIndexes(Arrays.stream(properties.getArray(LineBreakpoint.PROP_LAMBDA_INDEX, new Object[0])).mapToInt(v -> (Integer) v).toArray());
lb.setCondition (
properties.getString (LineBreakpoint.PROP_CONDITION, "")
);
Expand Down Expand Up @@ -370,6 +372,10 @@ public void write (Object object, Properties properties) {
LineBreakpoint.PROP_LINE_NUMBER,
lb.getLineNumber ()
);
properties.setArray(
LineBreakpoint.PROP_LAMBDA_INDEX,
Arrays.stream(lb.getLambdaIndexes()).mapToObj(v -> v).toArray()
);
properties.setString (
LineBreakpoint.PROP_CONDITION,
lb.getCondition ()
Expand Down
Loading
Loading