Search in sources :

Example 26 with RuntimeConfigurationError

use of com.intellij.execution.configurations.RuntimeConfigurationError in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineServerModel method checkConfiguration.

@Override
public void checkConfiguration() throws RuntimeConfigurationException {
    if (artifactPointer == null || artifactPointer.getArtifact() == null) {
        throw new RuntimeConfigurationError(GctBundle.message("appengine.run.server.artifact.missing"));
    }
    // do not check SDK if it supports dynamic install - the deployment runner will block itself
    // until installation is done.
    CloudSdkService cloudSdkService = CloudSdkService.getInstance();
    SdkStatus sdkStatus = cloudSdkService.getStatus();
    if (sdkStatus != SdkStatus.READY && !cloudSdkService.isInstallSupported()) {
        if (!CloudSdkValidator.getInstance().isValidCloudSdk()) {
            throw new RuntimeConfigurationError(GctBundle.message("appengine.run.server.sdk.misconfigured.panel.message"));
        }
    }
    if (ProjectRootManager.getInstance(commonModel.getProject()).getProjectSdk() == null) {
        throw new RuntimeConfigurationError(GctBundle.getString("appengine.run.server.nosdk"));
    }
}
Also used : CloudSdkService(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus)

Example 27 with RuntimeConfigurationError

use of com.intellij.execution.configurations.RuntimeConfigurationError 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);
    }
    FileDocumentManager.getInstance().saveAllDocuments();
    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 28 with RuntimeConfigurationError

use of com.intellij.execution.configurations.RuntimeConfigurationError in project flutter-intellij by flutter.

the class SdkAttachConfig method getState.

@NotNull
@Override
public LaunchState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
    try {
        checkRunnable(env.getProject());
    } catch (RuntimeConfigurationError e) {
        throw new ExecutionException(e);
    }
    final SdkFields launchFields = getFields();
    final MainFile mainFile = MainFile.verify(launchFields.getFilePath(), env.getProject()).get();
    final Project project = env.getProject();
    final RunMode mode = RunMode.fromEnv(env);
    final Module module = ModuleUtilCore.findModuleForFile(mainFile.getFile(), env.getProject());
    final LaunchState.CreateAppCallback createAppCallback = (@Nullable FlutterDevice device) -> {
        if (device == null)
            return null;
        final GeneralCommandLine command = getCommand(env, device);
        final FlutterApp app = FlutterApp.start(env, project, module, mode, device, command, StringUtil.capitalize(mode.mode()) + "App", "StopApp");
        // Stop the app if the Flutter SDK changes.
        final FlutterSdkManager.Listener sdkListener = new FlutterSdkManager.Listener() {

            @Override
            public void flutterSdkRemoved() {
                app.shutdownAsync();
            }
        };
        FlutterSdkManager.getInstance(project).addListener(sdkListener);
        Disposer.register(project, () -> FlutterSdkManager.getInstance(project).removeListener(sdkListener));
        return app;
    };
    final LaunchState launcher = new AttachState(env, mainFile.getAppDir(), mainFile.getFile(), this, createAppCallback);
    addConsoleFilters(launcher, env, mainFile, module);
    return launcher;
}
Also used : FlutterApp(io.flutter.run.daemon.FlutterApp) RefactoringElementListener(com.intellij.refactoring.listeners.RefactoringElementListener) Project(com.intellij.openapi.project.Project) FlutterSdkManager(io.flutter.sdk.FlutterSdkManager) RunMode(io.flutter.run.common.RunMode) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ExecutionException(com.intellij.execution.ExecutionException) Module(com.intellij.openapi.module.Module) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) NotNull(org.jetbrains.annotations.NotNull)

Example 29 with RuntimeConfigurationError

use of com.intellij.execution.configurations.RuntimeConfigurationError in project flutter-intellij by flutter.

the class BazelFields method getLaunchCommand.

/**
 * Returns the command to use to launch the Flutter app. (Via running the Bazel target.)
 */
GeneralCommandLine getLaunchCommand(@NotNull Project project, @Nullable FlutterDevice device, @NotNull RunMode mode) throws ExecutionException {
    try {
        checkRunnable(project);
    } catch (RuntimeConfigurationError e) {
        throw new ExecutionException(e);
    }
    final Workspace workspace = getWorkspace(project);
    final String launchingScript = getRunScriptFromWorkspace(project);
    // already checked
    assert launchingScript != null;
    // if the workspace is null, then so is the launching script, therefore this was already checked.
    assert workspace != null;
    final String target = getTarget();
    // already checked
    assert target != null;
    final String additionalArgs = getAdditionalArgs();
    final GeneralCommandLine commandLine = new GeneralCommandLine().withWorkDirectory(workspace.getRoot().getPath());
    commandLine.setCharset(StandardCharsets.UTF_8);
    commandLine.setExePath(FileUtil.toSystemDependentName(launchingScript));
    final String inputBazelArgs = StringUtil.notNullize(bazelArgs);
    if (!inputBazelArgs.isEmpty()) {
        commandLine.addParameter(String.format("--bazel-options=%s", inputBazelArgs));
    }
    // Potentially add the flag related to build mode.
    if (enableReleaseMode) {
        commandLine.addParameter("--release");
    } else if (mode.equals(PROFILE)) {
        commandLine.addParameter("--profile");
    }
    // Tell the flutter command-line tools that we want a machine interface on stdio.
    commandLine.addParameter("--machine");
    // Pause the app at startup in order to set breakpoints.
    if (!enableReleaseMode && mode == DEBUG) {
        commandLine.addParameter("--start-paused");
    }
    // User specified additional target arguments.
    final CommandLineTokenizer additionalArgsTokenizer = new CommandLineTokenizer(StringUtil.notNullize(additionalArgs));
    while (additionalArgsTokenizer.hasMoreTokens()) {
        commandLine.addParameter(additionalArgsTokenizer.nextToken());
    }
    final String enableBazelHotRestartParam = "--enable-google3-hot-reload";
    final String disableBazelHotRestartParam = "--no-enable-google3-hot-reload";
    final boolean hasEnabledArg = StringUtil.notNullize(additionalArgs).contains(enableBazelHotRestartParam);
    final boolean hasDisabledArg = StringUtil.notNullize(additionalArgs).contains(disableBazelHotRestartParam);
    if (!FlutterSettings.getInstance().isEnableBazelHotRestart() && hasDisabledArg) {
        final Notification notification = new Notification(FlutterMessages.FLUTTER_NOTIFICATION_GROUP_ID, "Google3-specific hot restart is disabled by default", "You can now remove this flag from your configuration's additional args: " + disableBazelHotRestartParam, NotificationType.INFORMATION);
        Notifications.Bus.notify(notification, project);
    } else if (FlutterSettings.getInstance().isEnableBazelHotRestart() && !hasEnabledArg && !hasDisabledArg) {
        commandLine.addParameter(enableBazelHotRestartParam);
    }
    // Send in the deviceId.
    if (device != null) {
        commandLine.addParameter("-d");
        commandLine.addParameter(device.deviceId());
    }
    try {
        final ProgressManager progress = ProgressManager.getInstance();
        final CompletableFuture<DevToolsInstance> devToolsFuture = new CompletableFuture<>();
        progress.runProcessWithProgressSynchronously(() -> {
            progress.getProgressIndicator().setIndeterminate(true);
            try {
                final DevToolsService service = this.devToolsService == null ? DevToolsService.getInstance(project) : this.devToolsService;
                devToolsFuture.complete(service.getDevToolsInstance().get(30, TimeUnit.SECONDS));
            } catch (Exception e) {
                LOG.error(e);
            }
        }, "Starting DevTools", false, project);
        final DevToolsInstance instance = devToolsFuture.get();
        commandLine.addParameter("--devtools-server-address=http://" + instance.host + ":" + instance.port);
    } catch (Exception e) {
        LOG.error(e);
    }
    commandLine.addParameter(target);
    return commandLine;
}
Also used : Notification(com.intellij.notification.Notification) ExecutionException(com.intellij.execution.ExecutionException) InvalidDataException(com.intellij.openapi.util.InvalidDataException) CompletableFuture(java.util.concurrent.CompletableFuture) DevToolsService(io.flutter.run.daemon.DevToolsService) ProgressManager(com.intellij.openapi.progress.ProgressManager) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) DevToolsInstance(io.flutter.run.daemon.DevToolsInstance) ExecutionException(com.intellij.execution.ExecutionException) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) Workspace(io.flutter.bazel.Workspace) CommandLineTokenizer(com.intellij.execution.configurations.CommandLineTokenizer)

Example 30 with RuntimeConfigurationError

use of com.intellij.execution.configurations.RuntimeConfigurationError in project flutter-intellij by flutter.

the class BazelTestFields method getLaunchCommand.

/**
 * Returns the command to use to launch the Flutter app. (Via running the Bazel target.)
 */
@NotNull
GeneralCommandLine getLaunchCommand(@NotNull final Project project, @NotNull final RunMode mode) throws ExecutionException {
    try {
        checkRunnable(project);
    } catch (RuntimeConfigurationError e) {
        throw new ExecutionException(e);
    }
    final Workspace workspace = getWorkspace(project);
    final String launchingScript = getTestScriptFromWorkspace(project);
    // already checked
    assert launchingScript != null;
    final GeneralCommandLine commandLine = new GeneralCommandLine().withWorkDirectory(workspace.getRoot().getPath());
    commandLine.setCharset(StandardCharsets.UTF_8);
    commandLine.setExePath(FileUtil.toSystemDependentName(launchingScript));
    final String nonNullArgs = StringUtil.notNullize(additionalArgs);
    // User specified additional target arguments.
    final CommandLineTokenizer testArgsTokenizer = new CommandLineTokenizer(nonNullArgs);
    while (testArgsTokenizer.hasMoreTokens()) {
        commandLine.addParameter(testArgsTokenizer.nextToken());
    }
    commandLine.addParameter(Flags.noColor);
    // If the user did not turn the --machine flag off, we will pass it to the test runner.
    if (!nonNullArgs.contains(Flags.noMachine)) {
        commandLine.addParameter(Flags.machine);
    }
    final String relativeEntryFilePath = entryFile == null ? null : FileUtil.getRelativePath(workspace.getRoot().getPath(), entryFile, '/');
    switch(getScope(project)) {
        case NAME:
            commandLine.addParameters(Flags.name, testName);
            commandLine.addParameter(relativeEntryFilePath);
            break;
        case FILE:
            commandLine.addParameter(relativeEntryFilePath);
            break;
        case TARGET_PATTERN:
            commandLine.addParameter(bazelTarget);
            break;
    }
    if (mode == RunMode.DEBUG) {
        commandLine.addParameters(Flags.separator, Flags.enableDebugging);
    }
    return commandLine;
}
Also used : GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ExecutionException(com.intellij.execution.ExecutionException) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) Workspace(io.flutter.bazel.Workspace) CommandLineTokenizer(com.intellij.execution.configurations.CommandLineTokenizer) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)57 VirtualFile (com.intellij.openapi.vfs.VirtualFile)22 Test (org.junit.Test)16 Module (com.intellij.openapi.module.Module)10 ExecutionException (com.intellij.execution.ExecutionException)7 File (java.io.File)7 DartSdk (com.jetbrains.lang.dart.sdk.DartSdk)6 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)5 PsiFile (com.intellij.psi.PsiFile)5 NotNull (org.jetbrains.annotations.NotNull)5 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)4 RuntimeConfigurationWarning (com.intellij.execution.configurations.RuntimeConfigurationWarning)4 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)4 Project (com.intellij.openapi.project.Project)4 Sdk (com.intellij.openapi.projectRoots.Sdk)4 CommandLineTokenizer (com.intellij.execution.configurations.CommandLineTokenizer)3 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 JSFile (com.intellij.lang.javascript.psi.JSFile)3 PsiElement (com.intellij.psi.PsiElement)3 UserSpecifiedPathDeploymentSource (com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource)2