@Nullable private String getWorkerID(@Nullable XSuspendContext context) { if (context != null) { XExecutionStack activeExecutionStack = context.getActiveExecutionStack(); if (activeExecutionStack instanceof BallerinaSuspendContext.BallerinaExecutionStack) { return ((BallerinaSuspendContext.BallerinaExecutionStack) activeExecutionStack).getMyWorkerID(); } } getSession().getConsoleView().print("Error occurred while getting the thread ID.", ConsoleViewContentType.ERROR_OUTPUT); getSession().stop(); return null; }
if (myConnector.isConnected()) { if (isRemoteDebugMode) { getSession().getConsoleView().print("Connected to the remote server at " + myConnector.getDebugServerAddress() + ".\n", ConsoleViewContentType.SYSTEM_OUTPUT); getSession().getConsoleView().print("Connection to debug server at " + myConnector.getDebugServerAddress() + " could not be established.\n", ConsoleViewContentType.ERROR_OUTPUT);
session.stop(); getSession().getConsoleView().print("Remote debugging finished.\n", ConsoleViewContentType.SYSTEM_OUTPUT);
@Override public void stop() { // If we don't call this using the executeOnPooledThread(), the UI will hang until the debug server is stopped. ApplicationManager.getApplication().executeOnPooledThread(() -> { XDebugSession session = getSession(); if (!isRemoteDebugMode) { XSuspendContext suspendContext = session.getSuspendContext(); if (suspendContext != null) { XExecutionStack activeExecutionStack = suspendContext.getActiveExecutionStack(); if (activeExecutionStack instanceof BallerinaSuspendContext.BallerinaExecutionStack) { String workerID = ((BallerinaSuspendContext.BallerinaExecutionStack) activeExecutionStack) .getMyWorkerID(); if (workerID != null) { myConnector.sendCommand(Command.STOP, workerID); } } } else { session.stop(); return; } } else { myConnector.sendCommand(Command.STOP); session.stop(); getSession().getConsoleView().print("Disconnected from the debug server.\n", ConsoleViewContentType.SYSTEM_OUTPUT); } isDisconnected = true; myConnector.close(); }); }