Search in sources :

Example 1 with Workspace

use of io.flutter.bazel.Workspace in project flutter-intellij by flutter.

the class FlutterSdkAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent event) {
    final Project project = DumbAwareAction.getEventProject(event);
    if (enableActionInBazelContext()) {
        // See if the Bazel workspace exists for this project.
        final Workspace workspace = FlutterModuleUtils.getFlutterBazelWorkspace(project);
        if (workspace != null) {
            FlutterInitializer.sendAnalyticsAction(this);
            FileDocumentManager.getInstance().saveAllDocuments();
            startCommandInBazelContext(project, workspace);
            return;
        }
    }
    final FlutterSdk sdk = project != null ? FlutterSdk.getFlutterSdk(project) : null;
    if (sdk == null) {
        showMissingSdkDialog(project);
        return;
    }
    FlutterInitializer.sendAnalyticsAction(this);
    FileDocumentManager.getInstance().saveAllDocuments();
    startCommand(project, sdk, PubRoot.forEventWithRefresh(event));
}
Also used : Project(com.intellij.openapi.project.Project) FlutterSdk(io.flutter.sdk.FlutterSdk) Workspace(io.flutter.bazel.Workspace)

Example 2 with Workspace

use of io.flutter.bazel.Workspace in project flutter-intellij by flutter.

the class BazelTestLaunchState method create.

public static BazelTestLaunchState create(@NotNull ExecutionEnvironment env, @NotNull BazelTestConfig config) throws ExecutionException {
    final BazelTestFields fields = config.getFields();
    try {
        fields.checkRunnable(env.getProject());
    } catch (RuntimeConfigurationError e) {
        throw new ExecutionException(e);
    }
    final VirtualFile virtualFile = fields.getFile();
    assert (virtualFile != null);
    final BazelTestLaunchState launcher = new BazelTestLaunchState(env, config, virtualFile);
    final Workspace workspace = FlutterModuleUtils.getFlutterBazelWorkspace(env.getProject());
    if (workspace != null) {
        DaemonConsoleView.install(launcher, env, workspace.getRoot());
    }
    return launcher;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExecutionException(com.intellij.execution.ExecutionException) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) Workspace(io.flutter.bazel.Workspace)

Example 3 with Workspace

use of io.flutter.bazel.Workspace in project flutter-intellij by flutter.

the class DeviceDaemon method chooseCommand.

/**
 * Returns the appropriate command to start the device daemon, if any.
 * <p>
 * A null means the device daemon should be shut down.
 */
@Nullable
static Command chooseCommand(@NotNull final Project project) {
    if (!usesFlutter(project)) {
        return null;
    }
    final String androidHome = IntelliJAndroidSdk.chooseAndroidHome(project, false);
    // See if the Bazel workspace provides a script.
    final Workspace workspace = WorkspaceCache.getInstance(project).getNow();
    if (workspace != null) {
        final String script = workspace.getDaemonScript();
        if (script != null) {
            return new Command(workspace.getRoot().getPath(), script, ImmutableList.of(), androidHome);
        }
    }
    // Otherwise, use the Flutter SDK.
    final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
    if (sdk == null) {
        return null;
    }
    try {
        final String path = FlutterSdkUtil.pathToFlutterTool(sdk.getHomePath());
        return new Command(sdk.getHomePath(), path, ImmutableList.of("daemon"), androidHome);
    } catch (ExecutionException e) {
        LOG.warn("Unable to calculate command to watch Flutter devices", e);
        return null;
    }
}
Also used : FlutterSdk(io.flutter.sdk.FlutterSdk) ExecutionException(com.intellij.execution.ExecutionException) Workspace(io.flutter.bazel.Workspace) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Workspace (io.flutter.bazel.Workspace)3 ExecutionException (com.intellij.execution.ExecutionException)2 FlutterSdk (io.flutter.sdk.FlutterSdk)2 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Nullable (org.jetbrains.annotations.Nullable)1