@Override public void unregisterBreakpoint(@NotNull XLineBreakpoint<DlvBreakpointProperties> breakpoint, boolean temporary) { XSourcePosition breakpointPosition = breakpoint.getSourcePosition(); if (breakpointPosition == null) return; Integer id = breakpoint.getUserData(ID); if (id == null) return; // obsolete breakpoint.putUserData(ID, null); breakpoints.remove(id); send(new DlvRequest.ClearBreakpoint(id)); } }
@Override public void unregisterBreakpoint(@NotNull XLineBreakpoint<BallerinaBreakpointProperties> breakpoint, boolean temporary) { XSourcePosition breakpointPosition = breakpoint.getSourcePosition(); if (breakpointPosition == null) { return; } breakpoints.remove(breakpoint); sendBreakpoints(); }
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; }
@Override public void registerBreakpoint(@NotNull XLineBreakpoint<DlvBreakpointProperties> breakpoint) { XSourcePosition breakpointPosition = breakpoint.getSourcePosition(); if (breakpointPosition == null) return; VirtualFile file = breakpointPosition.getFile(); int line = breakpointPosition.getLine(); send(new DlvRequest.CreateBreakpoint(file.getPath(), line + 1)) .done(b -> { breakpoint.putUserData(ID, b.id); breakpoints.put(b.id, breakpoint); getSession().updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_verified_breakpoint, null); }) .rejected(t -> { String message = t == null ? null : t.getMessage(); getSession().updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, message); }); }
@Override protected void processBreakPoint(@NotNull XLineBreakpoint breakpoint, XDebugSession session) { XDebuggerManager.getInstance(session.getProject()).getBreakpointManager().updateBreakpointPresentation( breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, "You can't set a breakpoint here" ); } }
@Override public void unregisterBreakpoint( @NotNull XLineBreakpoint<CloudLineBreakpointProperties> ideBreakpoint, boolean temporary) { // If the state was set to disabled as a result of a server update, // then we do not need to update the server side. if (!ideBreakpoint.getProperties().isDisabledByServer()) { String breakpointId = ideBreakpoint.getUserData(CLOUD_ID); if (!Strings.isNullOrEmpty(breakpointId)) { process.getStateController().deleteBreakpointAsync(breakpointId); } else { LOG.warn("could not delete breakpoint because it was not added through the cloud handler."); } } // reset this flag: either it has been disabled by the server or the client has deleted it, in // both cases we need to add it again, if it is re-enabled ideBreakpoint.getProperties().setAddedOnServer(false); } }
@Override public void run() { if (finalserverBreakpoint.getExpressions() != null && finalserverBreakpoint.getExpressions().size() > 0) { properties.setWatchExpressions( finalserverBreakpoint .getExpressions() .toArray(new String[finalserverBreakpoint.getExpressions().size()])); } XLineBreakpoint<CloudLineBreakpointProperties> newxIdeBreakpoint = manager.addLineBreakpoint( CloudLineBreakpointType.getInstance(), file.getUrl(), line, properties); // Condition, watches. if (!Strings.isNullOrEmpty(finalserverBreakpoint.getCondition())) { newxIdeBreakpoint.setCondition(finalserverBreakpoint.getCondition()); } } });
@Override public void stop() { myDebugThread.setStop(); ApplicationManager.getApplication().runReadAction( () -> { XBreakpointManager breakpointManager = XDebuggerManager.getInstance(getSession().getProject()).getBreakpointManager(); Collection<? extends XLineBreakpoint<PerlLineBreakpointProperties>> breakpoints = breakpointManager.getBreakpoints(PerlLineBreakpointType.class); for (XLineBreakpoint<PerlLineBreakpointProperties> breakpoint : breakpoints) { breakpointManager.updateBreakpointPresentation(breakpoint, null, null); } } ); }
@Nullable public static XLineBreakpoint findBreakpoint(final Project project, final PerlDebuggingEventBreakpoint breakpointBase) { final XLineBreakpoint[] result = new XLineBreakpoint[]{null}; ApplicationManager.getApplication().runReadAction(() -> { String path = breakpointBase.getPath(); VirtualFile virtualFile; String virtualFileUrl; virtualFile = VfsUtil.findFileByIoFile(new File(breakpointBase.getDebugThread().getDebugProfileState().mapPathToLocal(path)), true); if (virtualFile == null) { virtualFileUrl = PerlRemoteFileSystem.PROTOCOL_PREFIX + path; } else { virtualFileUrl = virtualFile.getUrl(); } Collection<? extends XLineBreakpoint<PerlLineBreakpointProperties>> breakpoints = XDebuggerManager.getInstance(project).getBreakpointManager().getBreakpoints(PerlLineBreakpointType.class); for (XLineBreakpoint<PerlLineBreakpointProperties> breakpoint : breakpoints) { if (StringUtil.equals(breakpoint.getFileUrl(), virtualFileUrl) && breakpoint.getLine() == breakpointBase.getLine()) { result[0] = breakpoint; return; } } }); return result[0]; }
@Override public void run() { manager.removeBreakpoint(existing); } });
/** * 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; }
@Override public void registerBreakpoint(@NotNull XLineBreakpoint<BallerinaBreakpointProperties> breakpoint) { XSourcePosition breakpointPosition = breakpoint.getSourcePosition(); if (breakpointPosition == null) { return; } breakpoints.add(breakpoint); sendBreakpoints(); getSession().updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_verified_breakpoint, null); }
@Override protected void processBreakPoint(@NotNull XLineBreakpoint breakpoint, XDebugSession session) { XDebuggerManager.getInstance(session.getProject()).getBreakpointManager().updateBreakpointPresentation( breakpoint, AllIcons.Debugger.Db_verified_breakpoint, "Breakpoint set" ); } }
int size = breakpoints.size(); for (int i = 0; i < size; i++) { XSourcePosition breakpointPosition = breakpoints.get(i).getSourcePosition(); if (breakpointPosition == null) { return;
@Override public void run() { manager.removeBreakpoint(existingXIdeBreakpoint); } });
/** 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; }
@Nullable private static Language getFileTypeLanguage( XLineBreakpoint<CloudLineBreakpointProperties> breakpoint) { if (breakpoint.getSourcePosition() != null) { FileType fileType = breakpoint.getSourcePosition().getFile().getFileType(); if (fileType instanceof LanguageFileType) { return ((LanguageFileType) fileType).getLanguage(); } } return null; }
void updateBreakpointPresentation(CloudLineBreakpoint cloudLineBreakpoint) { final XBreakpointManager manager = getXBreakpointManager(getXDebugSession().getProject()); manager.updateBreakpointPresentation( getXBreakpoint(cloudLineBreakpoint), cloudLineBreakpoint.getSetIcon(areBreakpointsMuted()), cloudLineBreakpoint.getErrorMessage()); }