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 @@ -67,6 +67,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 Down Expand Up @@ -94,6 +96,7 @@ public class LineBreakpoint extends JPDABreakpoint {
private String className = null;
private Map<JPDADebugger,ObjectVariable[]> instanceFilters;
private Map<JPDADebugger,JPDAThread[]> threadFilters;
private int lambdaIndex = -1; //line breakpoint by default


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

public int getLambdaIndex() {
return lambdaIndex;
}

public void setLambdaIndex(int li) {
int old;
synchronized (this) {
if (li == lambdaIndex) {
return;
}
old = lambdaIndex;
lambdaIndex = li;
}
firePropertyChange (
PROP_LAMBDA_INDEX,
Integer.valueOf(old),
Integer.valueOf(li)
);
}

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

private static class LineBreakpointImpl extends LineBreakpoint
Expand Down
8 changes: 8 additions & 0 deletions java/debugger.jpda.projectsui/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@
<specification-version>1.62</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.java.source</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>0.191</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.java.source.base</code-name-base>
<build-prerequisite/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ private void annotate (final FileObject fo) {
}
annotatedFiles.add(fo);
}
LambdaBreakpointManager.FactoryImpl.doRefresh(fo); //ensure spans of lambda breakpoints are updated
}

void setBreakpointsActive(boolean active) {
Expand Down Expand Up @@ -189,6 +190,7 @@ private void refreshAnnotation(JPDABreakpoint b) {
breakpointToAnnotations.put(b, Collections.newSetFromMap(new WeakHashMap<>()));
for (FileObject fo : annotatedFiles) {
addAnnotationTo(b, fo);
LambdaBreakpointManager.FactoryImpl.doRefresh(fo);
}
}
}
Expand All @@ -207,12 +209,17 @@ private static String getAnnotationType(JPDABreakpoint b, boolean isConditional,
boolean active) {
boolean isInvalid = b.getValidity() == VALIDITY.INVALID;
String annotationType;
if (b instanceof LineBreakpoint) {
annotationType = b.isEnabled () ?
(isConditional ? EditorContext.CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE :
EditorContext.BREAKPOINT_ANNOTATION_TYPE) :
(isConditional ? EditorContext.DISABLED_CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE :
EditorContext.DISABLED_BREAKPOINT_ANNOTATION_TYPE);
if (b instanceof LineBreakpoint lb) {
if (lb.getLambdaIndex() >= 0) {
annotationType = b.isEnabled() ? DebuggerBreakpointAnnotation.LAMBDA_BREAKPOINT
: DebuggerBreakpointAnnotation.DISABLED_LAMBDA_BREAKPOINT;
} else {
annotationType = b.isEnabled () ?
(isConditional ? EditorContext.CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE :
EditorContext.BREAKPOINT_ANNOTATION_TYPE) :
(isConditional ? EditorContext.DISABLED_CONDITIONAL_BREAKPOINT_ANNOTATION_TYPE :
EditorContext.DISABLED_BREAKPOINT_ANNOTATION_TYPE);
}
} else if (b instanceof FieldBreakpoint) {
annotationType = b.isEnabled () ?
EditorContext.FIELD_BREAKPOINT_ANNOTATION_TYPE :
Expand Down Expand Up @@ -475,6 +482,9 @@ static String getCondition(Breakpoint b) {
}
}

Set<Annotation> getAnnotationsForBreakpoint(JPDABreakpoint b) {
return breakpointToAnnotations.getOrDefault(b, Set.of());
}
/*
// Not used
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ TOOLTIP_DISABLED_METHOD_BREAKPOINT=Disabled Method Breakpoint
TOOLTIP_CLASS_BREAKPOINT=Class Breakpoint
TOOLTIP_DISABLED_CLASS_BREAKPOINT=Disabled Class Breakpoint
TOOLTIP_BREAKPOINT_STROKE=Deactivated breakpoint
TOOLTIP_LAMBDA_BREAKPOINT=Lambda Breakpoint
TOOLTIP_DISABLED_LAMBDA_BREAKPOINT=Lambda Breakpoint
# A condition expression follows this message on a next line
TOOLTIP_CONDITION=Hits when:
# {0} - a number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.List;
import org.netbeans.api.debugger.Breakpoint;
import org.netbeans.api.debugger.Breakpoint.HIT_COUNT_FILTERING_STYLE;
import org.netbeans.api.debugger.jpda.JPDABreakpoint;
import org.netbeans.spi.debugger.jpda.EditorContext;
import org.netbeans.spi.debugger.ui.BreakpointAnnotation;

Expand All @@ -39,6 +38,9 @@
*/
public class DebuggerBreakpointAnnotation extends BreakpointAnnotation {

public static final String LAMBDA_BREAKPOINT = "LambdaBreakpoint";
public static final String DISABLED_LAMBDA_BREAKPOINT = "DisabledLambdaBreakpoint";

private final Line line;
private final String type;
private final Breakpoint breakpoint;
Expand Down Expand Up @@ -163,6 +165,14 @@ private String getShortDescriptionIntern () {
if (type == EditorContext.DISABLED_CLASS_BREAKPOINT_ANNOTATION_TYPE) {
return NbBundle.getMessage
(DebuggerBreakpointAnnotation.class, "TOOLTIP_DISABLED_CLASS_BREAKPOINT"); // NOI18N
} else
if (type == LAMBDA_BREAKPOINT) {
return NbBundle.getMessage
(DebuggerBreakpointAnnotation.class, "TOOLTIP_LAMBDA_BREAKPOINT"); // NOI18N
} else
if (type == DISABLED_LAMBDA_BREAKPOINT) {
return NbBundle.getMessage
(DebuggerBreakpointAnnotation.class, "TOOLTIP_DISABLED_LAMBDA_BREAKPOINT"); // NOI18N
}
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, new IllegalStateException("Unknown breakpoint type '"+type+"'."));
return null;
Expand Down
Loading
Loading