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; }
/** * Called when the server records a new snapshot, we find the IDE representation and disable it. */ public void setStateToDisabled(@NotNull Breakpoint serverBreakpoint) { final XBreakpoint ideBreakpoint = ideBreakpoints.get(serverBreakpoint.getId()); if (ideBreakpoint != null && ideBreakpoint.getProperties() instanceof CloudLineBreakpointProperties) { CloudLineBreakpointProperties properties = (CloudLineBreakpointProperties) ideBreakpoint.getProperties(); properties.setDisabledByServer(true); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { ideBreakpoint.setEnabled(false); } }); } }
@Override public void run() { ideBreakpoint.setEnabled(false); } });
/** * Returns the XBreakpoint corresponding to the given server breakpoint. * * @param serverBreakpoint the server breakpoint representation * @return the local IDE representation in x-breakpoint form, if enabled */ @Nullable public XBreakpoint getEnabledXBreakpoint(@NotNull Breakpoint serverBreakpoint) { XBreakpoint ideBreakpoint = getXBreakpoint(serverBreakpoint); return (ideBreakpoint == null || !ideBreakpoint.isEnabled()) ? null : ideBreakpoint; }
/** Get the watch expressions from the breakpoint. */ @Nullable public List<String> getWatchExpressions() { CloudLineBreakpointProperties properties = (CloudLineBreakpointProperties) getXBreakpoint().getProperties(); if (properties.getWatchExpressions() != null && properties.getWatchExpressions().length > 0) { return Arrays.asList(properties.getWatchExpressions()); } 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); } }