Search in sources :

Example 1 with BreakPoint

use of org.ballerinalang.plugins.idea.debugger.dto.BreakPoint in project ballerina by ballerina-lang.

the class BallerinaDebugProcess method findBreakPoint.

private XBreakpoint<BallerinaBreakpointProperties> findBreakPoint(@NotNull BreakPoint breakPoint) {
    String fileName = breakPoint.getFileName();
    String packagePath = breakPoint.getPackagePath();
    String relativeFilePathInProject;
    // If the package is ".", full path of the file will be sent as the filename.
    if (".".equals(packagePath)) {
        // Then we need to get the actual filename from the path.
        int index = fileName.lastIndexOf("/");
        if (index <= -1) {
            return null;
        }
        relativeFilePathInProject = fileName.substring(index);
    } else {
        // If the absolute path is not sent, we need to construct the relative file path in the project.
        relativeFilePathInProject = packagePath.replaceAll("\\.", "/") + "/" + fileName;
    }
    int lineNumber = breakPoint.getLineNumber();
    for (XBreakpoint<BallerinaBreakpointProperties> breakpoint : breakpoints) {
        XSourcePosition breakpointPosition = breakpoint.getSourcePosition();
        if (breakpointPosition == null) {
            continue;
        }
        VirtualFile fileInBreakpoint = breakpointPosition.getFile();
        int line = breakpointPosition.getLine() + 1;
        if (fileInBreakpoint.getPath().endsWith(relativeFilePathInProject) && line == lineNumber) {
            return breakpoint;
        }
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XSourcePosition(com.intellij.xdebugger.XSourcePosition) BallerinaBreakpointProperties(org.ballerinalang.plugins.idea.debugger.breakpoint.BallerinaBreakpointProperties) BreakPoint(org.ballerinalang.plugins.idea.debugger.dto.BreakPoint) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 XSourcePosition (com.intellij.xdebugger.XSourcePosition)1 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)1 XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)1 BallerinaBreakpointProperties (org.ballerinalang.plugins.idea.debugger.breakpoint.BallerinaBreakpointProperties)1 BreakPoint (org.ballerinalang.plugins.idea.debugger.dto.BreakPoint)1