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(File.separator); 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("\\.", File.separator) + File.separator + 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; }
int size = breakpoints.size(); for (int i = 0; i < size; i++) { XSourcePosition breakpointPosition = breakpoints.get(i).getSourcePosition(); if (breakpointPosition == null) { return;
/** * Called when the user clicks a pending breakpoint. We find the local IDE representation and * navigate to its line of code. */ public void navigateTo(@NotNull Breakpoint serverBreakpoint) { final XBreakpoint xIdeBreakpoint = ideBreakpoints.get(serverBreakpoint.getId()); if (xIdeBreakpoint != null && xIdeBreakpoint.getSourcePosition() != null && process.getXDebugSession() != null) { xIdeBreakpoint .getSourcePosition() .createNavigatable(process.getXDebugSession().getProject()) .navigate(true); } }