Skip to content

Commit

Permalink
Make sure, that Java, Groovy and Truffle breakpoints are not clashing
Browse files Browse the repository at this point in the history
  • Loading branch information
lkishalmi committed Jul 28, 2022
1 parent 5ba8513 commit 8202967
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@DebuggerServiceRegistration(types=LazyDebuggerManagerListener.class)
public class GroovyBreakpointAnnotationListener extends DebuggerManagerAdapter {

private HashMap<LineBreakpoint, Object> breakpointToAnnotation = new HashMap<>();
private final HashMap<LineBreakpoint, Object> breakpointToAnnotation = new HashMap<>();
private boolean listen = true;

@Override
Expand Down Expand Up @@ -71,16 +71,22 @@ public void propertyChange (PropertyChangeEvent e) {
@Override
public void breakpointAdded (Breakpoint b) {
if (b instanceof LineBreakpoint) {
((LineBreakpoint) b).addPropertyChangeListener (this);
annotate ((LineBreakpoint) b);
LineBreakpoint lb = (LineBreakpoint) b;
if (GroovyBreakpointStratifier.GROOVY_STRATUM.equals(lb.getStratum())) {
lb.addPropertyChangeListener (this);
annotate(lb);
}
}
}

@Override
public void breakpointRemoved (Breakpoint b) {
if (b instanceof LineBreakpoint) {
((LineBreakpoint) b).removePropertyChangeListener (this);
removeAnnotation ((LineBreakpoint) b);
LineBreakpoint lb = (LineBreakpoint) b;
if (GroovyBreakpointStratifier.GROOVY_STRATUM.equals(lb.getStratum())) {
lb.removePropertyChangeListener (this);
removeAnnotation(lb);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
@ServiceProvider(service = BreakpointStratifier.class)
public final class GroovyBreakpointStratifier implements BreakpointStratifier {

public final static String GROOVY_STRATUM = "Groovy"; //NOI18N
private static final Logger LOGGER = Logger.getLogger(GroovyBreakpointStratifier.class.getName());

public GroovyBreakpointStratifier() {
Expand All @@ -78,7 +79,7 @@ public void stratify(JPDABreakpoint breakpoint) {
String printText = pt.replace("{groovyName}", (groovyName != null) ? groovyName : "?"); // NOI18N
String groovyPath = getGroovyPath(url, fo);

lb.setStratum("Groovy"); // NOI18N
lb.setStratum(GROOVY_STRATUM);
lb.setSourceName(groovyName);
lb.setSourcePath(groovyPath);
lb.setPreferredClassName(findGroovyClassName(groovyPath, fo, lineNumber));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ToggleBreakpointsInLanguagesActionProvider extends ActionsProviderS

private static final Set<String> IGNORED_MIME_TYPES = new HashSet<>(
// We have JSLineBreakpoint in JavaScript
Arrays.asList("text/javascript", "text/x-java")); // NOI18N
Arrays.asList("text/javascript", "text/x-java", "text/x-groovy")); // NOI18N

private volatile Line postedLine;

Expand Down

0 comments on commit 8202967

Please sign in to comment.