Search in sources :

Example 1 with FlutterSdk

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));
}
Also used : Project(com.intellij.openapi.project.Project) FlutterSdk(io.flutter.sdk.FlutterSdk) Workspace(io.flutter.bazel.Workspace)

Example 2 with FlutterSdk

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FlutterSdk(io.flutter.sdk.FlutterSdk) PubRoot(io.flutter.pub.PubRoot) ExecutionException(com.intellij.execution.ExecutionException)

Example 3 with FlutterSdk

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FlutterSdk(io.flutter.sdk.FlutterSdk) PubRoot(io.flutter.pub.PubRoot) ExecutionException(com.intellij.execution.ExecutionException) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Example 4 with FlutterSdk

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);
        });
    }
}
Also used : FlutterSdk(io.flutter.sdk.FlutterSdk)

Example 5 with FlutterSdk

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);
    });
}
Also used : FlutterSdk(io.flutter.sdk.FlutterSdk)

Aggregations

FlutterSdk (io.flutter.sdk.FlutterSdk)15 PubRoot (io.flutter.pub.PubRoot)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 ExecutionException (com.intellij.execution.ExecutionException)4 Project (com.intellij.openapi.project.Project)4 Nullable (org.jetbrains.annotations.Nullable)3 OutputListener (com.intellij.execution.OutputListener)2 Module (com.intellij.openapi.module.Module)2 Workspace (io.flutter.bazel.Workspace)2 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)1 ScratchRootType (com.intellij.ide.scratch.ScratchRootType)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 ApplicationInfo (com.intellij.openapi.application.ApplicationInfo)1 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)1 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)1 PluginId (com.intellij.openapi.extensions.PluginId)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1