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));
}
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;
}
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;
}
}
Aggregations