XDebuggerBreakpointType

Answered

I've registered a custom XDebuggerBreakpoint type for JavaScript files with the following code. I've also registered the type in plugin.xml. I realized that what is happening now is there is a choice of breakpoint when clicking the gutter to set the breakpoints.

This is not what I would like to happen. I would like to extend/override the line breakpoint for a particular module type when the JavaScript files are contained in specific directories. Is that possible?

I'm essentially trying to create a debugger that can debug JS files (Rhino implementation) on a remote server using an HTTP client.

https://github.com/nek4life/sfcc-studio/blob/debugger/src/com/binarysushi/studio/debugger/breakpoint/StudioDebuggerBreakpointType.java

package com.binarysushi.studio.debugger.breakpoint;

import com.intellij.lang.javascript.JavaScriptFileType;
import com.intellij.openapi.fileTypes.FileTypeRegistry;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.xdebugger.breakpoints.XBreakpointProperties;
import com.intellij.xdebugger.breakpoints.XLineBreakpointType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class StudioDebuggerBreakpointType extends XLineBreakpointType<XBreakpointProperties> {
private static final String ID = "StudioDebuggerBreakpoint";
private static final String TITLE = "Studio Debugger Breakpoint";


protected StudioDebuggerBreakpointType() {
super(ID, TITLE);
}

@Nullable
@Override
public XBreakpointProperties createBreakpointProperties(@NotNull VirtualFile file, int line) {
return null;
}

@Override
public boolean canPutAt(@NotNull VirtualFile file, int line, @NotNull Project project) {
return FileTypeRegistry.getInstance().isFileOfType(file, JavaScriptFileType.INSTANCE);
}
}
0
4 comments

Am I right that you do not want to disable the JavaScriptBreakpointType all together, but replace it with your type for some files?

0

Yes that is exactly right. We have both server side JS files in our project as well as front end JS files in the project, but unfortunately they all use the same file extension.

My thought was to keep the JS debugger available, but perhaps it is not needed for client side JS files.

0

Currently there's no way to replace default JS breakpoints, you may try using them directly instead of your own, writing your own JSLineBreakpointHandler for your debug process (provide in com.intellij.xdebugger.XDebugProcess#getBreakpointHandlers).

0

OK thanks, Egor!

I'll give that a shot and see how it goes. I was able to have my new breakpoints show up in the directories that would contain the server side script, however it has both Breakpoint types. Perhaps this solution would allow me to only have the one type.

0

Please sign in to leave a comment.