Search in sources :

Example 11 with RuntimeConfigurationError

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

the class BCBasedRunnerParameters method checkAndGetModuleAndBC.

public Pair<Module, FlexBuildConfiguration> checkAndGetModuleAndBC(final Project project) throws RuntimeConfigurationError {
    if (myModuleName.isEmpty() || myBCName.isEmpty()) {
        throw new RuntimeConfigurationError(FlexBundle.message("bc.not.specified"));
    }
    final Module module = ModuleManager.getInstance(project).findModuleByName(myModuleName);
    if (module == null || !(ModuleType.get(module) instanceof FlexModuleType)) {
        throw new RuntimeConfigurationError(FlexBundle.message("bc.not.specified"));
    }
    final FlexBuildConfiguration bc = FlexBuildConfigurationManager.getInstance(module).findConfigurationByName(myBCName);
    if (bc == null) {
        throw new RuntimeConfigurationError(FlexBundle.message("module.does.not.contain.bc", myModuleName, myBCName));
    }
    final Sdk sdk = bc.getSdk();
    if (sdk == null) {
        throw new RuntimeConfigurationError(FlexCommonBundle.message("sdk.not.set.for.bc.0.of.module.1", bc.getName(), module.getName()));
    }
    return Pair.create(module, bc);
}
Also used : FlexModuleType(com.intellij.lang.javascript.flex.FlexModuleType) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Example 12 with RuntimeConfigurationError

use of com.intellij.execution.configurations.RuntimeConfigurationError in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoRunConfigurationWithMain method checkFileConfiguration.

protected void checkFileConfiguration() throws RuntimeConfigurationError {
    VirtualFile file = findFile(getFilePath());
    if (file == null) {
        throw new RuntimeConfigurationError("Main file is not specified");
    }
    PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
    if (!(psiFile instanceof GoFile)) {
        throw new RuntimeConfigurationError("Main file is invalid");
    }
    if (!GoRunUtil.isMainGoFile(psiFile)) {
        throw new RuntimeConfigurationError("Main file has non-main package or doesn't contain main function");
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GoFile(com.goide.psi.GoFile) PsiFile(com.intellij.psi.PsiFile) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Example 13 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 14 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 15 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)

Aggregations

RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)23 VirtualFile (com.intellij.openapi.vfs.VirtualFile)16 Module (com.intellij.openapi.module.Module)7 File (java.io.File)7 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)5 RuntimeConfigurationWarning (com.intellij.execution.configurations.RuntimeConfigurationWarning)4 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)4 Sdk (com.intellij.openapi.projectRoots.Sdk)4 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 JSFile (com.intellij.lang.javascript.psi.JSFile)3 Project (com.intellij.openapi.project.Project)3 PsiElement (com.intellij.psi.PsiElement)3 PsiFile (com.intellij.psi.PsiFile)3 NotNull (org.jetbrains.annotations.NotNull)3 ExecutionException (com.intellij.execution.ExecutionException)2 RunProfile (com.intellij.execution.configurations.RunProfile)2 XmlFile (com.intellij.psi.xml.XmlFile)2 Consumer (com.intellij.util.Consumer)2 DartRunConfigurationBase (com.jetbrains.lang.dart.ide.runner.base.DartRunConfigurationBase)2 DartSdk (com.jetbrains.lang.dart.sdk.DartSdk)2