use of io.flutter.run.daemon.RunMode in project flutter-intellij by flutter.
the class SdkRunConfig method getState.
@NotNull
@Override
public LaunchState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
final SdkFields launchFields = fields.copy();
try {
launchFields.checkRunnable(env.getProject());
} catch (RuntimeConfigurationError e) {
throw new ExecutionException(e);
}
final MainFile mainFile = MainFile.verify(launchFields.getFilePath(), env.getProject()).get();
final Project project = env.getProject();
final RunMode mode = RunMode.fromEnv(env);
final Module module = ModuleUtil.findModuleForFile(mainFile.getFile(), env.getProject());
final LaunchState.Callback callback = (device) -> {
if (device == null)
return null;
final GeneralCommandLine command = fields.createFlutterSdkRunCommand(project, device, mode);
final FlutterApp app = FlutterApp.start(env, project, module, mode, device, command, StringUtil.capitalize(mode.mode()) + "App", "StopApp");
// Stop the app if the Flutter SDK changes.
final FlutterSdkManager.Listener sdkListener = new FlutterSdkManager.Listener() {
@Override
public void flutterSdkRemoved() {
app.shutdownAsync();
}
};
FlutterSdkManager.getInstance(project).addListener(sdkListener);
Disposer.register(project, () -> FlutterSdkManager.getInstance(project).removeListener(sdkListener));
return app;
};
final LaunchState launcher = new LaunchState(env, mainFile.getAppDir(), mainFile.getFile(), this, callback);
// Set up additional console filters.
final TextConsoleBuilder builder = launcher.getConsoleBuilder();
builder.addFilter(new DartConsoleFilter(env.getProject(), mainFile.getFile()));
if (module != null) {
builder.addFilter(new FlutterConsoleFilter(module));
}
return launcher;
}
use of io.flutter.run.daemon.RunMode in project flutter-intellij by flutter.
the class BazelRunConfig method getState.
@NotNull
@Override
public LaunchState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
final BazelFields launchFields = fields.copy();
try {
launchFields.checkRunnable(env.getProject());
} catch (RuntimeConfigurationError e) {
throw new ExecutionException(e);
}
final MainFile main = MainFile.verify(launchFields.getEntryFile(), env.getProject()).get();
final RunMode mode = RunMode.fromEnv(env);
final Module module = ModuleUtil.findModuleForFile(main.getFile(), env.getProject());
final LaunchState.Callback callback = (device) -> {
if (device == null)
return null;
final GeneralCommandLine command = launchFields.getLaunchCommand(env.getProject(), device, mode);
return FlutterApp.start(env, env.getProject(), module, mode, device, command, StringUtil.capitalize(mode.mode()) + "BazelApp", "StopBazelApp");
};
return new LaunchState(env, main.getAppDir(), main.getFile(), this, callback);
}
Aggregations