Search in sources :

Example 6 with RunMode

use of io.flutter.run.common.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 Workspace workspace = fields.getWorkspace(getProject());
    final VirtualFile workspaceRoot = workspace.getRoot();
    final RunMode mode = RunMode.fromEnv(env);
    final Module module = ModuleUtil.findModuleForFile(workspaceRoot, env.getProject());
    final LaunchState.CreateAppCallback createAppCallback = (@Nullable FlutterDevice device) -> {
        if (device == null)
            return null;
        final GeneralCommandLine command = getCommand(env, device);
        return FlutterApp.start(env, env.getProject(), module, mode, device, command, StringUtil.capitalize(mode.mode()) + "BazelApp", "StopBazelApp");
    };
    return new LaunchState(env, workspaceRoot, workspaceRoot, this, createAppCallback);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FlutterDevice(io.flutter.run.FlutterDevice) RunMode(io.flutter.run.common.RunMode) LaunchState(io.flutter.run.LaunchState) ExecutionException(com.intellij.execution.ExecutionException) Module(com.intellij.openapi.module.Module) Workspace(io.flutter.bazel.Workspace) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

RunMode (io.flutter.run.common.RunMode)6 NotNull (org.jetbrains.annotations.NotNull)6 ExecutionException (com.intellij.execution.ExecutionException)4 Module (com.intellij.openapi.module.Module)3 Project (com.intellij.openapi.project.Project)3 RefactoringElementListener (com.intellij.refactoring.listeners.RefactoringElementListener)2 FlutterApp (io.flutter.run.daemon.FlutterApp)2 FlutterSdkManager (io.flutter.sdk.FlutterSdkManager)2 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Workspace (io.flutter.bazel.Workspace)1 FlutterDevice (io.flutter.run.FlutterDevice)1 LaunchState (io.flutter.run.LaunchState)1 FlutterCommandStartResult (io.flutter.sdk.FlutterCommandStartResult)1 IOException (java.io.IOException)1