use of io.flutter.run.SdkAttachConfig in project flutter-intellij by flutter.
the class AttachDebuggerAction method onAttachTermination.
private static void onAttachTermination(@NotNull Project project, @NotNull Consumer<Project> runner) {
final MessageBusConnection connection = project.getMessageBus().connect();
// Need an ExecutionListener to clean up project-scoped state when the Stop button is clicked.
connection.subscribe(ExecutionManager.EXECUTION_TOPIC, new ExecutionListener() {
Object handler;
@Override
public void processStarted(@NotNull String executorId, @NotNull ExecutionEnvironment env, @NotNull ProcessHandler handler) {
if (env.getRunProfile() instanceof SdkAttachConfig) {
this.handler = handler;
}
}
@Override
public void processTerminated(@NotNull String executorId, @NotNull ExecutionEnvironment env, @NotNull ProcessHandler handler, int exitCode) {
if (this.handler == handler) {
runner.accept(project);
connection.disconnect();
}
}
});
}
use of io.flutter.run.SdkAttachConfig in project flutter-intellij by flutter.
the class AttachDebuggerAction method startCommand.
@Override
public void startCommand(@NotNull Project project, @NotNull FlutterSdk sdk, @Nullable PubRoot root, @NotNull DataContext context) {
// NOTE: When making changes here, consider making similar changes to RunFlutterAction.
FlutterInitializer.sendAnalyticsAction(this);
RunConfiguration configuration = findRunConfig(project);
if (configuration == null) {
final RunnerAndConfigurationSettings settings = RunManagerEx.getInstanceEx(project).getSelectedConfiguration();
if (settings == null) {
showSelectConfigDialog();
return;
}
configuration = settings.getConfiguration();
if (!(configuration instanceof SdkRunConfig)) {
if (project.isDefault() || !FlutterSdkUtil.hasFlutterModules(project)) {
return;
}
showSelectConfigDialog();
return;
}
}
final SdkAttachConfig sdkRunConfig = new SdkAttachConfig((SdkRunConfig) configuration);
final Executor executor = RunFlutterAction.getExecutor(ToolWindowId.DEBUG);
if (executor == null) {
return;
}
final ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.create(executor, sdkRunConfig);
final ExecutionEnvironment env = builder.activeTarget().dataContext(context).build();
FlutterLaunchMode.addToEnvironment(env, FlutterLaunchMode.DEBUG);
if (project.getUserData(ATTACH_IS_ACTIVE) == null) {
project.putUserData(ATTACH_IS_ACTIVE, ThreeState.fromBoolean(false));
onAttachTermination(project, (p) -> p.putUserData(ATTACH_IS_ACTIVE, null));
}
ProgramRunnerUtil.executeConfiguration(env, false, true);
}
Aggregations