Search in sources :

Example 36 with RuntimeConfigurationError

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

the class FlexBuildTargetScopeProvider method getModulesAndBCsToCompile.

static Collection<Pair<Module, FlexBuildConfiguration>> getModulesAndBCsToCompile(final CompileScope scope) throws ConfigurationException {
    final Collection<Pair<Module, FlexBuildConfiguration>> result = new HashSet<>();
    final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCsToCompile = FlexResourceBuildTargetScopeProvider.getBCsToCompileForPackaging(scope);
    final RunConfiguration runConfiguration = CompileStepBeforeRun.getRunConfiguration(scope);
    if (modulesAndBCsToCompile != null) {
        for (Pair<Module, FlexBuildConfiguration> moduleAndBC : modulesAndBCsToCompile) {
            if (!moduleAndBC.second.isSkipCompile()) {
                final FlexBuildConfiguration bcWithForcedDebugStatus = forceDebugStatus(moduleAndBC.first.getProject(), moduleAndBC.second);
                result.add(Pair.create(moduleAndBC.first, bcWithForcedDebugStatus));
                appendBCDependencies(result, moduleAndBC.first, moduleAndBC.second);
            }
        }
    } else if (runConfiguration instanceof FlashRunConfiguration || runConfiguration instanceof FlexUnitRunConfiguration) {
        final BCBasedRunnerParameters params = runConfiguration instanceof FlashRunConfiguration ? ((FlashRunConfiguration) runConfiguration).getRunnerParameters() : ((FlexUnitRunConfiguration) runConfiguration).getRunnerParameters();
        final Pair<Module, FlexBuildConfiguration> moduleAndBC;
        final Ref<RuntimeConfigurationError> exceptionRef = new Ref<>();
        moduleAndBC = ApplicationManager.getApplication().runReadAction((NullableComputable<Pair<Module, FlexBuildConfiguration>>) () -> {
            try {
                return params.checkAndGetModuleAndBC(runConfiguration.getProject());
            } catch (RuntimeConfigurationError e) {
                exceptionRef.set(e);
                return null;
            }
        });
        if (!exceptionRef.isNull()) {
            throw new ConfigurationException(exceptionRef.get().getMessage(), FlexBundle.message("run.configuration.0", runConfiguration.getName()));
        }
        if (!moduleAndBC.second.isSkipCompile()) {
            result.add(moduleAndBC);
            appendBCDependencies(result, moduleAndBC.first, moduleAndBC.second);
        }
    } else {
        for (final Module module : scope.getAffectedModules()) {
            if (module.isDisposed() || ModuleType.get(module) != FlexModuleType.getInstance())
                continue;
            for (final FlexBuildConfiguration bc : FlexBuildConfigurationManager.getInstance(module).getBuildConfigurations()) {
                if (!bc.isSkipCompile()) {
                    result.add(Pair.create(module, bc));
                }
            }
        }
    }
    return result;
}
Also used : BCBasedRunnerParameters(com.intellij.lang.javascript.flex.run.BCBasedRunnerParameters) FlexUnitRunConfiguration(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Ref(com.intellij.openapi.util.Ref) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FlexUnitRunConfiguration(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) ConfigurationException(com.intellij.openapi.options.ConfigurationException) Module(com.intellij.openapi.module.Module) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) Pair(com.intellij.openapi.util.Pair)

Example 37 with RuntimeConfigurationError

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

the class DartTestRunningState method createConsole.

private static ConsoleView createConsole(@NotNull ExecutionEnvironment env) {
    final Project project = env.getProject();
    final DartRunConfiguration runConfiguration = (DartRunConfiguration) env.getRunProfile();
    final DartTestRunnerParameters runnerParameters = (DartTestRunnerParameters) runConfiguration.getRunnerParameters();
    final TestConsoleProperties testConsoleProperties = new DartConsoleProperties(runConfiguration, env);
    final ConsoleView consoleView = SMTestRunnerConnectionUtil.createConsole(DART_FRAMEWORK_NAME, testConsoleProperties);
    try {
        final VirtualFile dartFile = runnerParameters.getDartFileOrDirectory();
        consoleView.addMessageFilter(new DartConsoleFilter(project, dartFile));
        consoleView.addMessageFilter(new DartRelativePathsConsoleFilter(project, runnerParameters.computeProcessWorkingDirectory(project)));
        consoleView.addMessageFilter(new UrlFilter());
    } catch (RuntimeConfigurationError ignore) {
    /* can't happen because already checked */
    }
    Disposer.register(project, consoleView);
    return consoleView;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DartRelativePathsConsoleFilter(com.jetbrains.lang.dart.ide.runner.DartRelativePathsConsoleFilter) Project(com.intellij.openapi.project.Project) DartRunConfiguration(com.jetbrains.lang.dart.ide.runner.base.DartRunConfiguration) SMTRunnerConsoleView(com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView) ConsoleView(com.intellij.execution.ui.ConsoleView) DartConsoleFilter(com.jetbrains.lang.dart.ide.runner.DartConsoleFilter) UrlFilter(com.intellij.execution.filters.UrlFilter) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) TestConsoleProperties(com.intellij.execution.testframework.TestConsoleProperties)

Example 38 with RuntimeConfigurationError

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

the class FlashRunnerParameters method checkAdlAndAirRuntime.

public static void checkAdlAndAirRuntime(@NotNull final Sdk sdk) throws RuntimeConfigurationError {
    final String adlPath = FlexSdkUtils.getAdlPath(sdk);
    if (StringUtil.isEmpty(adlPath)) {
        throw new RuntimeConfigurationError(FlexBundle.message("adl.not.set.check.sdk.settings", sdk.getName()));
    }
    final VirtualFile adlFile = LocalFileSystem.getInstance().findFileByPath(adlPath);
    if (adlFile == null || adlFile.isDirectory()) {
        throw new RuntimeConfigurationError(sdk.getSdkType() instanceof FlexmojosSdkType ? FlexBundle.message("adl.not.found.check.sdk.settings", adlPath, sdk.getName()) : FlexBundle.message("adl.not.found.check.sdk.installation", adlPath, sdk.getName()));
    }
    if (sdk.getSdkType() instanceof FlexmojosSdkType) {
        final String airRuntimePath = FlexSdkUtils.getAirRuntimePathForFlexmojosSdk(sdk);
        if (StringUtil.isEmpty(airRuntimePath)) {
            throw new RuntimeConfigurationError(FlexBundle.message("air.runtime.not.set.check.sdk.settings", sdk.getName()));
        }
        final VirtualFile airRuntimeDir = LocalFileSystem.getInstance().findFileByPath(airRuntimePath);
        if (airRuntimeDir == null) {
            throw new RuntimeConfigurationError(FlexBundle.message("air.runtime.not.found.check.sdk.settings", airRuntimePath, sdk.getName()));
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FlexmojosSdkType(com.intellij.lang.javascript.flex.sdk.FlexmojosSdkType) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Example 39 with RuntimeConfigurationError

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

the class FlashRunnerParameters method checkCustomDescriptor.

public static void checkCustomDescriptor(final AirPackagingOptions packagingOptions, final String bcName, final String moduleName) throws RuntimeConfigurationError {
    final boolean android = packagingOptions instanceof AndroidPackagingOptions;
    final boolean ios = packagingOptions instanceof IosPackagingOptions;
    if (android && !((AndroidPackagingOptions) packagingOptions).isEnabled()) {
        throw new RuntimeConfigurationError(FlexBundle.message("android.disabled.in.bc", bcName, moduleName));
    }
    if (ios && !((IosPackagingOptions) packagingOptions).isEnabled()) {
        throw new RuntimeConfigurationError(FlexBundle.message("ios.disabled.in.bc", bcName, moduleName));
    }
    if (!packagingOptions.isUseGeneratedDescriptor()) {
        if (packagingOptions.getCustomDescriptorPath().isEmpty()) {
            final String key = android ? "bc.0.module.1.android.custom.descriptor.not.set" : ios ? "bc.0.module.1.ios.custom.descriptor.not.set" : "bc.0.module.1.custom.descriptor.not.set";
            throw new RuntimeConfigurationError(FlexBundle.message(key, bcName, moduleName));
        } else {
            final VirtualFile descriptorFile = LocalFileSystem.getInstance().findFileByPath(packagingOptions.getCustomDescriptorPath());
            if (descriptorFile == null || descriptorFile.isDirectory()) {
                final String key = android ? "bc.0.module.1.android.custom.descriptor.not.found" : ios ? "bc.0.module.1.ios.custom.descriptor.not.found" : "bc.0.module.1.custom.descriptor.not.found";
                throw new RuntimeConfigurationError(FlexBundle.message(key, bcName, moduleName, FileUtil.toSystemDependentName(packagingOptions.getCustomDescriptorPath())));
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Example 40 with RuntimeConfigurationError

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

the class TestCategory method checkConfiguration.

@Override
public void checkConfiguration() throws RuntimeConfigurationException {
    JavaParametersUtil.checkAlternativeJRE(getConfiguration());
    ProgramParametersUtil.checkWorkingDirectoryExist(getConfiguration(), getConfiguration().getProject(), getConfiguration().getConfigurationModule().getModule());
    final String category = getConfiguration().getPersistentData().getCategory();
    if (category == null || category.isEmpty()) {
        throw new RuntimeConfigurationError("Category is not specified");
    }
    final JavaRunConfigurationModule configurationModule = getConfiguration().getConfigurationModule();
    if (getSourceScope() == null) {
        configurationModule.checkForWarning();
    }
    final Module module = configurationModule.getModule();
    if (module != null) {
        final PsiClass psiClass = JavaExecutionUtil.findMainClass(getConfiguration().getProject(), category, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module));
        if (psiClass == null) {
            throw new RuntimeConfigurationWarning(ExecutionBundle.message("class.not.found.in.module.error.message", category, configurationModule.getModuleName()));
        }
    }
}
Also used : RuntimeConfigurationWarning(com.intellij.execution.configurations.RuntimeConfigurationWarning) JavaRunConfigurationModule(com.intellij.execution.configurations.JavaRunConfigurationModule) Module(com.intellij.openapi.module.Module) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) JavaRunConfigurationModule(com.intellij.execution.configurations.JavaRunConfigurationModule)

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