@Override public void run() { getBreakpointHandler().createIdeRepresentationsIfNecessary(getCurrentBreakpointList()); } });
@VisibleForTesting int getSelection() { final List<Breakpoint> breakpointList = process.getCurrentBreakpointList(); int selection = -1; if (breakpointList != null) { for (int i = 0; i < breakpointList.size(); i++) { Breakpoint snapshot = process.getCurrentSnapshot(); if (snapshot != null && breakpointList.get(i).getId().equals(snapshot.getId())) { selection = i; break; } } } return selection; }
/** * The value returned from the method is immutable and is safe to access on multiple threads. * * <p>However, multiple successive calls to this method may return a different list. Therefore, * callers must store the return value locally to operate on it and should not call this method * repeatedly expecting the same list. */ // todo: can we declare this as ImmutableList? public List<Breakpoint> getCurrentBreakpointList() { return getProcessState().getCurrentServerBreakpointList(); }
void updateBreakpointPresentation(CloudLineBreakpoint cloudLineBreakpoint) { final XBreakpointManager manager = getXBreakpointManager(getXDebugSession().getProject()); manager.updateBreakpointPresentation( getXBreakpoint(cloudLineBreakpoint), cloudLineBreakpoint.getSetIcon(areBreakpointsMuted()), cloudLineBreakpoint.getErrorMessage()); }
when(debuggerManager.getBreakpointManager()).thenReturn(breakpointManager); doAnswer(invocationOnMock -> breakpointManager).when(process).getXBreakpointManager(any()); when(breakpointHandler.getEnabledXBreakpoint(breakpoint)).thenReturn(xLineBreakpointImpl); process.setBreakpointHandler(breakpointHandler); process.initialize(processState); process.onBreakpointListChanged(mock(CloudDebugProcessState.class)); verify(process, times(1)).getXBreakpoint(cloudLineBreakpoint); verify(cloudLineBreakpoint).getSetIcon(anyBoolean()); verify(cloudLineBreakpoint).getErrorMessage(); eq(xLineBreakpointImpl), any(Icon.class), eq(breakPointErrorMessage)); process.getStateController().stopBackgroundListening();
public void onBreakpointListChanged(CloudDebugProcessState state) { final List<Breakpoint> currentList = getCurrentBreakpointList(); if (currentList != null) { SwingUtilities.invokeLater( final XBreakpoint breakpointHit = getBreakpointHandler().getEnabledXBreakpoint(breakpoint); if (breakpointHit == null) { continue; && (breakpoint.getStatus() == null || !Boolean.TRUE.equals(breakpoint.getStatus().getIsError()))) { if (!getXDebugSession().isStopped()) { getBreakpointHandler().setStateToDisabled(breakpoint); cloudLineBreakpoint.setErrorMessage( BreakpointUtil.getUserErrorMessage(breakpoint.getStatus())); updateBreakpointPresentation(cloudLineBreakpoint);
@Test public void testOnBreakpointListChanged() throws InterruptedException { CloudDebugHistoricalSnapshots snapshots = new CloudDebugHistoricalSnapshots(handler); Breakpoint bp1 = new Breakpoint(); bp1.setId("an ID"); bp1.setFinalTime("2015-08-22T05:23:34.123Z"); bp1.setIsFinalState(true); SourceLocation location = new SourceLocation(); location.setPath("foo/bar/baz"); location.setLine(12); bp1.setLocation(location); List<Breakpoint> breakpoints = new ArrayList<Breakpoint>(); breakpoints.add(bp1); Mockito.when(mockProcess.getCurrentBreakpointList()).thenReturn(breakpoints); Mockito.when(mockProcess.getCurrentSnapshot()).thenReturn(bp1); CloudBreakpointHandler breakpointHandler = Mockito.mock(CloudBreakpointHandler.class); Mockito.when(mockProcess.getBreakpointHandler()).thenReturn(breakpointHandler); runModelSetter(snapshots); Assert.assertEquals(0, snapshots.table.getSelectedRow()); }
@Override public void stop() { getStateController().stopBackgroundListening(); RunProfile profile = getXDebugSession().getRunProfile(); if (profile instanceof CloudDebugRunConfiguration) { ((CloudDebugRunConfiguration) profile).setProcessState(processState); } getRepositoryValidator().restoreToOriginalState(getXDebugSession().getProject()); XBreakpointManager breakpointManager = XDebuggerManager.getInstance(getXDebugSession().getProject()).getBreakpointManager(); for (XBreakpoint bp : breakpointManager.getAllBreakpoints()) { com.intellij.debugger.ui.breakpoints.Breakpoint cloudBreakpoint = BreakpointManager.getJavaBreakpoint(bp); if (!(cloudBreakpoint instanceof CloudLineBreakpointType.CloudLineBreakpoint)) { continue; } CloudLineBreakpointType.CloudLineBreakpoint cloudLineBreakpoint = (CloudLineBreakpointType.CloudLineBreakpoint) cloudBreakpoint; cloudLineBreakpoint.setVerified(false); cloudLineBreakpoint.setErrorMessage(null); updateBreakpointPresentation(cloudLineBreakpoint); } }
when(process.getXDebugSession()).thenReturn(session); CloudDebugProcessState processState = mock(CloudDebugProcessState.class); existingBreakpoints = new ArrayList<Breakpoint>(); when(processState.getCurrentServerBreakpointList()) .thenReturn(ContainerUtil.immutableList(existingBreakpoints)); when(process.getProcessState()).thenReturn(processState); when(process.getStateController()).thenReturn(stateController);
private boolean areBreakpointsMuted() { return getXDebugSession() != null && getXDebugSession().areBreakpointsMuted(); }
TestUtils.installMockService(IntegratedGoogleLoginService.class); when(mockGoogleLoginService.getAllUsers()).thenReturn(users); process.initialize(state); XDebugTabLayouter layouter = process.createTabLayouter(); RunnerLayoutUi ui = mock(RunnerLayoutUi.class); }); process.getStateController().stopBackgroundListening();
public void removeListener(@NotNull CloudBreakpointListener listener) { getStateController().removeListener(listener); }
/** * Initializes the current state, synchronously checks for the latest set of changes and kicks off * the background job to poll for changes. */ public void initialize(@NotNull CloudDebugProcessState processState) { this.processState = processState; currentSnapshot = null; new Task.Modal( getXDebugSession().getProject(), StackdriverDebuggerBundle.getString("clouddebug.attachingtext"), false) { @Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); getStateController().initialize(CloudDebugProcess.this.processState); getRepositoryValidator().hardRefresh(); } }.queue(); // Start breakpoints refresh job on first use. getStateController().addListener(this); getStateController().startBackgroundListening(); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { getBreakpointHandler().createIdeRepresentationsIfNecessary(getCurrentBreakpointList()); } }); }
@Override public void mousePressed(MouseEvent event) { JTable table = (JTable) event.getSource(); Point point = event.getPoint(); Breakpoint breakpoint = getBreakPoint(point); int column = table.columnAtPoint(point); // todo: 4 and 1 here are magic numbers; use named constants for columns; maybe define // in CloudDebuggerTable class if (breakpoint != null && column == 4 && supportsMoreConfig(breakpoint)) { BreakpointsDialogFactory.getInstance(process.getXDebugSession().getProject()) .showDialog(process.getBreakpointHandler().getXBreakpoint(breakpoint)); } else if (event.getClickCount() == 1 && breakpoint != null && table.getSelectedRows().length == 1) { selectSnapshot(breakpoint, false); } } }
@Override public void run() { getBreakpointHandler().createIdeRepresentationsIfNecessary(currentList); } });
@Test public void testUpdateBreakpointRepresentationUsesBreakpointErrorMsgAndIcon() { XBreakpointManager breakpointManager = mock(XBreakpointManager.class); CloudDebugProcess cloudDebugProcess = mockCloudDebugProcess(breakpointManager, mock(XDebugSession.class)); XLineBreakpointImpl xBreakpoint = mock(XLineBreakpointImpl.class); CloudLineBreakpoint breakpoint = mockCloudLineBreakpoint(cloudDebugProcess, "mock error message", xBreakpoint); Icon icon = mock(Icon.class); when(breakpoint.getSetIcon(anyBoolean())).thenReturn(icon); cloudDebugProcess.updateBreakpointPresentation(breakpoint); verify(cloudDebugProcess, times(1)).getXBreakpoint(breakpoint); verify(breakpoint).getSetIcon(anyBoolean()); verify(breakpoint).getErrorMessage(); verify(breakpointManager).updateBreakpointPresentation(xBreakpoint, icon, "mock error message"); }
CloudDebugProcess process = new CloudDebugProcess(session); process.initialize(state); return process;
cloudIdeLineBreakpoint.setVerified(true); cloudIdeLineBreakpoint.setErrorMessage(null); process.updateBreakpointPresentation(cloudIdeLineBreakpoint); Project currentProject = process.getXDebugSession().getProject(); final XBreakpointManager manager = XDebuggerManager.getInstance(process.getXDebugSession().getProject()) .getBreakpointManager(); if (serverBreakpoint.getLocation() == null) {
@Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); getStateController().initialize(CloudDebugProcess.this.processState); getRepositoryValidator().hardRefresh(); } }.queue();
/** Initialize the panel. */ public CloudDebugHistoricalSnapshots(@NotNull CloudDebugProcessHandler processHandler) { super(new BorderLayout()); table = new CloudDebuggerTable(); configureToolbar(); process = processHandler.getProcess(); process.getXDebugSession().addSessionListener(this); process.addListener(this); }