Skip to content
Draft
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
/** 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[] lambdaIndex = 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[] getLambdaIndex() {
return lambdaIndex.clone();
}

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

li = li.clone();

synchronized (this) {
if (li == lambdaIndex) {
return;
}
old = lambdaIndex;
lambdaIndex = 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 + (lambdaIndex.length > 0 ? " lambda indices: " + Arrays.toString(lambdaIndex) : "");
}

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 &Index\:
ACSD_L_Line_Breakpoint_Lambda_Index=Lambda Index
ACSD_TF_Line_Breakpoint_Lambda_Index=Lambda Index
TTT_TF_Line_Breakpoint_Lambda_Index=Lambda Index to stop at

L_Line_Breakpoint_Condition=Co&ndition:
ACSD_L_Line_Breakpoint_Condition=Condition
ACSD_TF_Line_Breakpoint_Condition=Condition
Expand Down
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,44 @@
</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="tfLambdaIndex"/>
</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="tfLambdaIndex">
<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" value="Lambda index"/>
<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()));
tfLambdaIndex.setText(Arrays.stream(b.getLambdaIndex()).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);
tfLambdaIndex.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();
tfLambdaIndex = 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(tfLambdaIndex);
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

tfLambdaIndex.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(tfLambdaIndex, gridBagConstraints);
tfLambdaIndex.getAccessibleContext().setAccessibleName("Lambda index");
tfLambdaIndex.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 tfLambdaIndex;
private javax.swing.JTextField tfLineNumber;
// End of variables declaration//GEN-END:variables

Expand Down Expand Up @@ -319,6 +350,12 @@ public boolean ok () {
logger.fine(" => URL = '"+url+"'");
breakpoint.setURL((url != null) ? url.toString() : path);
breakpoint.setLineNumber(Integer.parseInt(tfLineNumber.getText().trim()));
String lambdaIndexText = tfLambdaIndex.getText().trim();
if (lambdaIndexText.isEmpty()) {
breakpoint.setLambdaIndex(new int[0]);
} else {
breakpoint.setLambdaIndex(Arrays.stream(lambdaIndexText.split(", *")).mapToInt(v -> Integer.parseInt(v)).toArray());
}
breakpoint.setCondition (conditionsPanel.getCondition());
breakpoint.setHitCountFilter(conditionsPanel.getHitCount(),
conditionsPanel.getHitCountFilteringStyle());
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.getLambdaIndex().length > 0 ?
NbBundle.getMessage (
BreakpointsNodeModel.class,
"CTL_Line_Lambda_Breakpoint",
EditorContextBridge.getFileName (b),
line,
Arrays.stream(b.getLambdaIndex())
.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.setLambdaIndex(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.getLambdaIndex()).mapToObj(v -> v).toArray()
);
properties.setString (
LineBreakpoint.PROP_CONDITION,
lb.getCondition ()
Expand Down
Loading
Loading