Search in sources :

Example 31 with RuntimeConfigurationError

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

the class FlexUnitRunnerParameters method doCheck.

private void doCheck(final Project project, final Pair<Module, FlexBuildConfiguration> moduleAndBC) throws RuntimeConfigurationError {
    if (DumbService.getInstance(project).isDumb())
        return;
    final FlexBuildConfiguration bc = moduleAndBC.second;
    final Sdk sdk = bc.getSdk();
    if (sdk == null) {
        throw new RuntimeConfigurationError(FlexCommonBundle.message("sdk.not.set.for.bc.0.of.module.1", bc.getName(), moduleAndBC.first.getName()));
    }
    switch(bc.getTargetPlatform()) {
        case Web:
            break;
        case Desktop:
            FlashRunnerParameters.checkAdlAndAirRuntime(sdk);
            if (bc.getOutputType() == OutputType.Application) {
                FlashRunnerParameters.checkCustomDescriptor(bc.getAirDesktopPackagingOptions(), getBCName(), getModuleName());
            }
            break;
        case Mobile:
            FlashRunnerParameters.checkAdlAndAirRuntime(sdk);
            switch(myAppDescriptorForEmulator) {
                case Android:
                    if (bc.getOutputType() == OutputType.Application) {
                        FlashRunnerParameters.checkCustomDescriptor(bc.getAndroidPackagingOptions(), getBCName(), getModuleName());
                    }
                    break;
                case IOS:
                    if (bc.getOutputType() == OutputType.Application) {
                        FlashRunnerParameters.checkCustomDescriptor(bc.getIosPackagingOptions(), getBCName(), getModuleName());
                    }
                    break;
            }
            break;
    }
    final FlexUnitSupport support = FlexUnitSupport.getSupport(bc, moduleAndBC.first);
    if (support == null) {
        throw new RuntimeConfigurationError(FlexBundle.message("flexunit.not.found.for.bc", bc.getName()));
    }
    if (!support.flexUnit4Present && bc.isPureAs()) {
        throw new RuntimeConfigurationError(FlexBundle.message("cant.execute.flexunit1.for.pure.as.bc"));
    }
    final GlobalSearchScope searchScope = FlexUtils.getModuleWithDependenciesAndLibrariesScope(moduleAndBC.first, bc, true);
    switch(getScope()) {
        case Class:
            getClassToTest(getClassName(), searchScope, support, true);
            break;
        case Method:
            final JSClass classToTest = getClassToTest(getClassName(), searchScope, support, false);
            if (StringUtil.isEmpty(getMethodName())) {
                throw new RuntimeConfigurationError(FlexBundle.message("no.test.method.specified"));
            }
            final JSFunction methodToTest = classToTest.findFunctionByNameAndKind(getMethodName(), JSFunction.FunctionKind.SIMPLE);
            if (methodToTest == null || !support.isTestMethod(methodToTest)) {
                throw new RuntimeConfigurationError(FlexBundle.message("method.not.valid", getMethodName()));
            }
            break;
        case Package:
            if (!JSUtils.packageExists(getPackageName(), searchScope)) {
                throw new RuntimeConfigurationError(FlexBundle.message("package.not.valid", getPackageName()));
            }
            break;
        default:
            assert false : "Unknown scope: " + getScope();
    }
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) JSFunction(com.intellij.lang.javascript.psi.JSFunction) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration) Sdk(com.intellij.openapi.projectRoots.Sdk) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass)

Example 32 with RuntimeConfigurationError

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

the class FlexUnitRunConfigurationForm method createUIComponents.

private void createUIComponents() {
    myBCCombo = new BCCombo(myProject);
    myWhatToTestForm = new WhatToTestForm(myProject, () -> {
        final Module module = myBCCombo.getModule();
        if (module != null)
            return module;
        throw new RuntimeConfigurationError(FlexBundle.message("bc.not.specified"));
    }, () -> {
        final FlexBuildConfiguration bc = myBCCombo.getBC();
        if (bc == null)
            throw new RuntimeConfigurationError(FlexBundle.message("bc.not.specified"));
        final FlexUnitSupport support = FlexUnitSupport.getSupport(bc, myBCCombo.getModule());
        if (support != null)
            return support;
        throw new RuntimeConfigurationError(FlexBundle.message("flexunit.not.found.for.bc", bc.getName()));
    });
}
Also used : FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Module(com.intellij.openapi.module.Module) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Example 33 with RuntimeConfigurationError

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

the class JstdRunConfigurationVerifier method verifyJSFilePath.

private static void verifyJSFilePath(@NotNull JstdRunSettings runSettings) throws RuntimeConfigurationError {
    String fileStr = runSettings.getJsFilePath();
    if (fileStr.trim().isEmpty()) {
        throw new RuntimeConfigurationError("JavaScript file name is empty.");
    }
    File configFile = new File(fileStr);
    if (!configFile.exists()) {
        throw new RuntimeConfigurationError("JavaScript file does not exist.");
    }
    if (configFile.isDirectory()) {
        throw new RuntimeConfigurationError("You have specified directory, but file was expected.");
    }
    if (!configFile.isFile()) {
        throw new RuntimeConfigurationError("Please specify JavaScript file correctly.");
    }
}
Also used : RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) JSFile(com.intellij.lang.javascript.psi.JSFile)

Example 34 with RuntimeConfigurationError

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

the class JstdRunConfigurationVerifier method verifyConfigFile.

private static void verifyConfigFile(@NotNull JstdRunSettings runSettings) throws RuntimeConfigurationError {
    String fileStr = runSettings.getConfigFile();
    if (fileStr.trim().isEmpty()) {
        throw new RuntimeConfigurationError("Configuration file name is empty.");
    }
    File configFile = new File(fileStr);
    if (!configFile.exists()) {
        throw new RuntimeConfigurationError("Configuration file does not exist.");
    }
    if (configFile.isDirectory()) {
        throw new RuntimeConfigurationError("You have specified directory, but file was expected.");
    }
    if (!configFile.isFile()) {
        throw new RuntimeConfigurationError("Please specify configuration file correctly.");
    }
}
Also used : RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) JSFile(com.intellij.lang.javascript.psi.JSFile)

Example 35 with RuntimeConfigurationError

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

the class JstdRunConfigurationVerifier method verifyAllInDirectory.

private static void verifyAllInDirectory(@NotNull JstdRunSettings runSettings) throws RuntimeConfigurationError {
    String directory = runSettings.getDirectory();
    if (directory.trim().isEmpty()) {
        throw new RuntimeConfigurationError("Directory name is empty.");
    }
    File dirFile = new File(directory);
    if (!dirFile.exists()) {
        throw new RuntimeConfigurationError("Specified directory '" + directory + "' does not exist.");
    }
    if (dirFile.isFile()) {
        throw new RuntimeConfigurationError("You have specified file, but directory was expected.");
    }
    if (!dirFile.isDirectory()) {
        throw new RuntimeConfigurationError("Please specify directory correctly.");
    }
}
Also used : RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) JSFile(com.intellij.lang.javascript.psi.JSFile)

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