protected ProjectRepositoryValidator getRepositoryValidator() { if (repoValidator == null) { repoValidator = new ProjectRepositoryValidator(getProcessState()); } return repoValidator; }
/** Returns true if this state has a valid debug client that can poll for snapshot information. */ @Transient public boolean isValidDebuggee() { SyncResult result = checkSyncStashState(); return result.isValidDebuggee(); }
@Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); getStateController().initialize(CloudDebugProcess.this.processState); getRepositoryValidator().hardRefresh(); } }.queue();
@Test public void testCheckSyncStashState_nullProject() { ProjectRepositoryValidator validator = new ProjectRepositoryValidator(state); SyncResult result = validator.checkSyncStashState(); Assert.assertFalse(result.isValidDebuggee()); Assert.assertFalse(result.needsStash()); Assert.assertFalse(result.needsSync()); Assert.assertFalse(result.hasLocalRepository()); Assert.assertFalse(result.hasRemoteRepository()); Assert.assertNull(result.getTargetSyncSha()); Assert.assertNull(result.getRepositoryType()); } }
validator = new ProjectRepositoryValidator(state); if (!attachDialog.isOK() || state == null || !validator.isValidDebuggee()) { throw new RunCanceledByUserException();
@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); } }
handler.addParameters("apply"); handler.addParameters("--index"); addStashParameter(project, handler, targetStash.get().getStash()); final AtomicBoolean conflict = new AtomicBoolean();
if (getCloudDebuggerClient() != null && !com.google.common.base.Strings.isNullOrEmpty(processState.getProjectNumber())) { try { ListDebuggeesResponse debuggeesResponse = getCloudDebuggerClient() .debuggees() .list()
? new ProjectRepositoryValidator(processResultState).checkSyncStashState() : projectRepositoryValidator.checkSyncStashState();
/** * After selecting a module that requires sync/stash, any subsequent module that is selected that * has no remote repository is shown the sync/stash checkbox regardless of its state. The * visibility of this option needs to be properly reset. */ public void testSyncStashReset() { mockLoggedInUser(); binding = mock(ProjectDebuggeeBinding.class); when(binding.buildResult(any(Project.class))).thenReturn(new CloudDebugProcessState()); // Step 1 - select a debuggable module that requires stashing // The stash checkbox should be visible to the user boolean needsStash = true; boolean hasRemoteRepository = true; ProjectRepositoryValidator repositoryValidator = mock(ProjectRepositoryValidator.class); SyncResult syncResult = mockSyncResult(needsStash, hasRemoteRepository); when(repositoryValidator.checkSyncStashState()).thenReturn(syncResult); CloudAttachDialog dialog = initDialog(); dialog.setProjectRepositoryValidator(repositoryValidator); selectProjectWithDebuggableModules(); assertTrue(syncStashCheckbox.isVisible()); // Step 2 - select a project with no remote repo that does NOT require stashing // The stash checkbox should now be hidden from the user needsStash = false; hasRemoteRepository = false; syncResult = mockSyncResult(needsStash, hasRemoteRepository); when(repositoryValidator.checkSyncStashState()).thenReturn(syncResult); selectEmptyProject(); assertFalse(syncStashCheckbox.isVisible()); dialog.close(0); }
public void testDebuggableModuleSelected() { mockLoggedInUser(); binding = mock(ProjectDebuggeeBinding.class); when(binding.buildResult(any(Project.class))).thenReturn(new CloudDebugProcessState()); ProjectRepositoryValidator repositoryValidator = mock(ProjectRepositoryValidator.class); SyncResult syncResult = mockSyncResult(false, true); when(repositoryValidator.checkSyncStashState()).thenReturn(syncResult); CloudAttachDialog dialog = initDialog(); dialog.setProjectRepositoryValidator(repositoryValidator); selectProjectWithDebuggableModules(); ValidationInfo error = dialog.doValidate(); assertNull(error); assertFalse(warningMessage.isVisible()); assertFalse(warningHeader.isVisible()); assertFalse(syncStashCheckbox.isVisible()); assertTrue(targetSelector.isEnabled()); dialog.close(0); }