Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Fix python debugging #6847

Merged
merged 4 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
import com.jetbrains.python.debugger.PyDebugProcess;
import com.jetbrains.python.debugger.PyDebugRunner;
import com.jetbrains.python.run.PythonCommandLineState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.concurrency.Promise;
import org.jetbrains.concurrency.Promises;

import java.net.ServerSocket;

/** Blaze plugin specific {@link PyDebugRunner}. */
Expand All @@ -57,11 +61,11 @@ public boolean canRun(String executorId, RunProfile profile) {
}

@Override
protected PyDebugProcess createDebugProcess(
XDebugSession xDebugSession,
ServerSocket serverSocket,
ExecutionResult executionResult,
PythonCommandLineState pythonCommandLineState) {
protected @NotNull PyDebugProcess createDebugProcess(
@NotNull XDebugSession xDebugSession,
ServerSocket serverSocket,
ExecutionResult executionResult,
PythonCommandLineState pythonCommandLineState) {
PyDebugProcess process =
super.createDebugProcess(
xDebugSession, serverSocket, executionResult, pythonCommandLineState);
Expand All @@ -70,19 +74,14 @@ protected PyDebugProcess createDebugProcess(
}

@Override
protected RunContentDescriptor doExecute(RunProfileState state, ExecutionEnvironment environment)
throws ExecutionException {
protected @NotNull Promise<RunContentDescriptor> execute(
@NotNull ExecutionEnvironment environment,
@NotNull RunProfileState state) throws ExecutionException {
if (!(state instanceof BlazePyDummyRunProfileState)) {
return null;
return Promises.resolvedPromise();
}
EventLoggingService.getInstance().logEvent(getClass(), "debugging-python");
try {
state = ((BlazePyDummyRunProfileState) state).toNativeState(environment);
return super.doExecute(state, environment);
} catch (ExecutionException e) {
throw e;
} catch (Exception e) {
throw new ExecutionException(e);
}

return super.execute(environment, ((BlazePyDummyRunProfileState) state).toNativeState(environment));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import com.intellij.util.execution.ParametersListUtil;
import com.jetbrains.python.console.PyDebugConsoleBuilder;
import com.jetbrains.python.console.PythonDebugLanguageConsoleView;
import com.jetbrains.python.run.AbstractPythonRunConfiguration;
import com.jetbrains.python.run.CommandLinePatcher;
import com.jetbrains.python.run.PythonConfigurationType;
import com.jetbrains.python.run.PythonRunConfiguration;
Expand Down Expand Up @@ -125,7 +126,9 @@ PythonScriptCommandLineState toNativeState(ExecutionEnvironment env) throws Exec
if (sdk == null) {
throw new ExecutionException("Can't find a Python SDK when debugging a python target.");
}
nativeConfig.setModule(null);

var modules = AbstractPythonRunConfiguration.getValidModules(env.getProject());
nativeConfig.setModule(modules.get(0));
nativeConfig.setSdkHome(sdk.getHomePath());

BlazePyRunConfigState handlerState =
Expand Down
Loading