use of io.flutter.sdk.FlutterSdk 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.sdk.FlutterSdk in project flutter-intellij by flutter.
the class TestFields method run.
/**
* Starts running the tests.
*/
ProcessHandler run(@NotNull Project project, @NotNull RunMode mode) throws ExecutionException {
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
if (sdk == null) {
throw new ExecutionException("The Flutter SDK is not configured");
}
final VirtualFile fileOrDir = getFileOrDir();
if (fileOrDir == null) {
throw new ExecutionException("File or directory not found");
}
final String testName = getTestName();
final PubRoot root = getPubRoot(project);
if (root == null) {
throw new ExecutionException("Test file isn't within a Flutter pub root");
}
return sdk.flutterTest(root, fileOrDir, testName, mode).startProcess(project);
}
use of io.flutter.sdk.FlutterSdk in project flutter-intellij by flutter.
the class TestLaunchState method create.
static TestLaunchState create(@NotNull ExecutionEnvironment env, @NotNull TestConfig config) throws ExecutionException {
final TestFields fields = config.getFields();
try {
fields.checkRunnable(env.getProject());
} catch (RuntimeConfigurationError e) {
throw new ExecutionException(e);
}
final VirtualFile fileOrDir = fields.getFileOrDir();
assert (fileOrDir != null);
final PubRoot pubRoot = fields.getPubRoot(env.getProject());
assert (pubRoot != null);
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(env.getProject());
assert (sdk != null);
final boolean testConsoleEnabled = sdk.getVersion().flutterTestSupportsMachineMode();
final TestLaunchState launcher = new TestLaunchState(env, config, fileOrDir, pubRoot, testConsoleEnabled);
DaemonConsoleView.install(launcher, env, pubRoot.getRoot());
return launcher;
}
use of io.flutter.sdk.FlutterSdk in project flutter-intellij by flutter.
the class FlutterModuleUtils method enableDartSDK.
private static void enableDartSDK(@NotNull Module module) {
if (DartPlugin.isDartSdkEnabled(module)) {
return;
}
// parse the .packages file
String sdkPath = FlutterSdkUtil.guessFlutterSdkFromPackagesFile(module);
if (sdkPath != null) {
FlutterSdkUtil.updateKnownSdkPaths(sdkPath);
}
// try and locate flutter on the path
if (sdkPath == null) {
sdkPath = FlutterSdkUtil.locateSdkFromPath();
if (sdkPath != null) {
FlutterSdkUtil.updateKnownSdkPaths(sdkPath);
}
}
if (sdkPath == null) {
final String[] flutterSdkPaths = FlutterSdkUtil.getKnownFlutterSdkPaths();
if (flutterSdkPaths.length > 0) {
sdkPath = flutterSdkPaths[0];
}
}
if (sdkPath != null) {
final FlutterSdk flutterSdk = FlutterSdk.forPath(sdkPath);
if (flutterSdk == null) {
return;
}
final String dartSdkPath = flutterSdk.getDartSdkPath();
if (dartSdkPath == null) {
// Not cached. TODO(skybrian) call flutterSdk.sync() here?
return;
}
ApplicationManager.getApplication().runWriteAction(() -> {
DartPlugin.ensureDartSdkConfigured(module.getProject(), dartSdkPath);
DartPlugin.enableDartSdk(module);
});
}
}
use of io.flutter.sdk.FlutterSdk in project flutter-intellij by flutter.
the class FlutterModuleFixture method before.
@Override
protected void before() throws Exception {
Testing.runOnDispatchThread(() -> {
FlutterTestUtils.configureFlutterSdk(parent.getModule(), testRoot, true);
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(parent.getProject());
assert (sdk != null);
final String path = sdk.getHomePath();
final String dartSdkPath = path + "/bin/cache/dart-sdk";
System.setProperty("dart.sdk", dartSdkPath);
DartTestUtils.configureDartSdk(parent.getModule(), testRoot, true);
});
}
Aggregations