@Nullable private VirtualFile findFile() { String url = myLocation.file; VirtualFile file = LocalFileSystem.getInstance().findFileByPath(url); if (file == null && SystemInfo.isWindows) { Project project = myProcess.getSession().getProject(); RunProfile profile = myProcess.getSession().getRunProfile(); Module module = profile instanceof ModuleBasedConfiguration ? ((ModuleBasedConfiguration)profile).getConfigurationModule().getModule() : null; String sdkHomePath = GoSdkService.getInstance(project).getSdkHomePath(module); if (sdkHomePath == null) return null; String newUrl = StringUtil.replaceIgnoreCase(url, "c:/go", sdkHomePath); return LocalFileSystem.getInstance().findFileByPath(newUrl); } return file; }
@VisibleForTesting boolean notStoppedAndHasRunProfile(XDebugSession session) { return !session.isStopped() && session.getRunProfile() != null; }
@NotNull @VisibleForTesting Set<RunProfile> getProfilesWithActiveDebugSession(Project project) { Set<RunProfile> debuggingProfiles = new HashSet<RunProfile>(); XDebuggerManager debugManager = XDebuggerManager.getInstance(project); for (XDebugSession session : debugManager.getDebugSessions()) { if (notStoppedAndHasRunProfile(session)) { debuggingProfiles.add(session.getRunProfile()); } } return debuggingProfiles; }
@NotNull private XDebugSession createMockSession(boolean isStopped, RunProfile runProfile) { XDebugSession debugSession = mock(XDebugSession.class); when(debugSession.isStopped()).thenReturn(isStopped); if (runProfile != null) { when(debugSession.getRunProfile()).thenReturn(runProfile); } return debugSession; } }
@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); } }