Search in sources :

Example 1 with RuntimeConfigurationWarning

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

the class JsonSchemaConfigurable method doValidation.

private void doValidation() throws ConfigurationException {
    final File file = new File(myProject.getBasePath(), myView.getSchemaSubPath());
    VirtualFile vFile = null;
    if (!file.exists() || (vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file)) == null) {
        throw new ConfigurationException((!StringUtil.isEmptyOrSpaces(myDisplayName) ? (myDisplayName + ": ") : "") + "Schema file does not exist");
    }
    final String filename = file.getName();
    if (StringUtil.isEmptyOrSpaces(myDisplayName))
        throw new ConfigurationException(filename + ": Schema name is empty");
    if (StringUtil.isEmptyOrSpaces(myView.getSchemaSubPath()))
        throw new ConfigurationException(filename + ": Schema path is empty");
    final CollectConsumer<String> collectConsumer = new CollectConsumer<>();
    final JsonSchemaService service = JsonSchemaService.Impl.get(myProject);
    if (service != null && !service.isSchemaFile(vFile, collectConsumer)) {
        final String message;
        if (collectConsumer.getResult().isEmpty())
            message = filename + ": Can not read JSON schema from file (Unknown reason)";
        else
            message = filename + ": Can not read JSON schema from file: " + StringUtil.join(collectConsumer.getResult(), "; ");
        logErrorForUser(message);
        throw new RuntimeConfigurationWarning(message);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ConfigurationException(com.intellij.openapi.options.ConfigurationException) CollectConsumer(com.intellij.util.CollectConsumer) RuntimeConfigurationWarning(com.intellij.execution.configurations.RuntimeConfigurationWarning) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) JsonSchemaService(com.jetbrains.jsonSchema.ide.JsonSchemaService)

Example 2 with RuntimeConfigurationWarning

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

the class JstdRunConfigurationVerifier method verifyTestCase.

@Nullable
private static TestFileStructurePack verifyTestCase(@NotNull Project project, @NotNull JstdRunSettings runSettings) throws RuntimeConfigurationException {
    verifyJSFileType(runSettings);
    if (runSettings.getTestCaseName().isEmpty()) {
        throw new RuntimeConfigurationError("Test case name is empty.");
    }
    VirtualFile jsTestVirtualFile = VfsUtil.findFileByIoFile(new File(runSettings.getJsFilePath()), false);
    if (jsTestVirtualFile == null) {
        throw new RuntimeConfigurationWarning("Can't find JavaScript test file.");
    }
    JSFile jsFile = ObjectUtils.tryCast(PsiManager.getInstance(project).findFile(jsTestVirtualFile), JSFile.class);
    if (jsFile == null) {
        throw new RuntimeConfigurationWarning("Wrong JavaScript test file.");
    }
    TestFileStructurePack pack = TestFileStructureManager.fetchTestFileStructurePackByJsFile(jsFile);
    if (pack != null) {
        boolean found = pack.contains(runSettings.getTestCaseName(), null, JstdTestMethodNameRefiner.INSTANCE);
        if (!found) {
            throw new RuntimeConfigurationWarning("Can't find test case with name '" + runSettings.getTestCaseName() + "'.");
        }
        return pack;
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TestFileStructurePack(com.intellij.javascript.testFramework.TestFileStructurePack) RuntimeConfigurationWarning(com.intellij.execution.configurations.RuntimeConfigurationWarning) JSFile(com.intellij.lang.javascript.psi.JSFile) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) JSFile(com.intellij.lang.javascript.psi.JSFile) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with RuntimeConfigurationWarning

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

the class FlashRunnerParameters method reportWarnings.

public void reportWarnings(final Project project) throws RuntimeConfigurationWarning {
    try {
        final Pair<Module, FlexBuildConfiguration> moduleAndBC = super.checkAndGetModuleAndBC(project);
        final Module module = moduleAndBC.first;
        final FlexBuildConfiguration bc = moduleAndBC.second;
        final Ref<String> errorMessageRef = new Ref<>(null);
        final Consumer<FlashProjectStructureProblem> consumer = problem -> errorMessageRef.set(problem.errorMessage);
        if (bc.getTargetPlatform() == TargetPlatform.Desktop) {
            checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getAirDesktopPackagingOptions(), consumer, true, getBCName());
        } else if (bc.getTargetPlatform() == TargetPlatform.Mobile) {
            switch(myMobileRunTarget) {
                case Emulator:
                    switch(myAppDescriptorForEmulator) {
                        case Android:
                            checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getAndroidPackagingOptions(), consumer, true, getBCName());
                            break;
                        case IOS:
                            checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getIosPackagingOptions(), consumer, true, getBCName());
                            break;
                    }
                    break;
                case AndroidDevice:
                    checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getAndroidPackagingOptions(), consumer, true, getBCName());
                    break;
                case iOSSimulator:
                case iOSDevice:
                    checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getIosPackagingOptions(), consumer, true, getBCName());
                    break;
            }
        }
        if (!errorMessageRef.isNull()) {
            throw new RuntimeConfigurationWarning(errorMessageRef.get());
        }
    } catch (RuntimeConfigurationError e) {
    /* should be already checked somewhere else */
    }
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) OutputType(com.intellij.flex.model.bc.OutputType) ArrayUtil(com.intellij.util.ArrayUtil) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) XmlFile(com.intellij.psi.xml.XmlFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) TargetPlatform(com.intellij.flex.model.bc.TargetPlatform) ActionScriptClassResolver(com.intellij.javascript.flex.resolve.ActionScriptClassResolver) PsiManager(com.intellij.psi.PsiManager) FlexCommonUtils(com.intellij.flex.FlexCommonUtils) AirPackagingConfigurableBase(com.intellij.lang.javascript.flex.projectStructure.ui.AirPackagingConfigurableBase) BCUtils(com.intellij.lang.javascript.flex.projectStructure.options.BCUtils) Factory(com.intellij.lang.javascript.flex.projectStructure.model.impl.Factory) FlexmojosSdkType(com.intellij.lang.javascript.flex.sdk.FlexmojosSdkType) PsiElement(com.intellij.psi.PsiElement) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) FileUtil(com.intellij.openapi.util.io.FileUtil) FlexSdkUtils(com.intellij.lang.javascript.flex.sdk.FlexSdkUtils) Module(com.intellij.openapi.module.Module) ProjectStructureProblemType(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemType) FlexCommonBundle(com.intellij.flex.FlexCommonBundle) EnumSet(java.util.EnumSet) XmlTag(com.intellij.psi.xml.XmlTag) FlexSdkComboBoxWithBrowseButton(com.intellij.lang.javascript.flex.sdk.FlexSdkComboBoxWithBrowseButton) MalformedURLException(java.net.MalformedURLException) StringUtil(com.intellij.openapi.util.text.StringUtil) BrowserUtil(com.intellij.ide.BrowserUtil) FlexBundle(com.intellij.lang.javascript.flex.FlexBundle) com.intellij.lang.javascript.flex.projectStructure.model(com.intellij.lang.javascript.flex.projectStructure.model) Sdk(com.intellij.openapi.projectRoots.Sdk) SystemInfo(com.intellij.openapi.util.SystemInfo) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) File(java.io.File) LinkageType(com.intellij.flex.model.bc.LinkageType) FlashProjectStructureProblem(com.intellij.lang.javascript.flex.build.FlashProjectStructureProblem) Nullable(org.jetbrains.annotations.Nullable) AirPackageUtil(com.intellij.lang.javascript.flex.actions.airpackage.AirPackageUtil) List(java.util.List) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) Pair(com.intellij.openapi.util.Pair) RuntimeConfigurationWarning(com.intellij.execution.configurations.RuntimeConfigurationWarning) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) Collections(java.util.Collections) Consumer(com.intellij.util.Consumer) Ref(com.intellij.openapi.util.Ref) RuntimeConfigurationWarning(com.intellij.execution.configurations.RuntimeConfigurationWarning) FlashProjectStructureProblem(com.intellij.lang.javascript.flex.build.FlashProjectStructureProblem) Module(com.intellij.openapi.module.Module) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Example 4 with RuntimeConfigurationWarning

use of com.intellij.execution.configurations.RuntimeConfigurationWarning in project liferay-ide by liferay.

the class LiferayServerConfiguration method checkConfiguration.

@Override
public void checkConfiguration() throws RuntimeConfigurationException {
    JavaParametersUtil.checkAlternativeJRE(this);
    ProgramParametersUtil.checkWorkingDirectoryExist(this, getProject(), null);
    File liferayHome = new File(getLiferayBundle());
    if (!liferayHome.exists()) {
        throw new RuntimeConfigurationWarning("Unable to detect liferay bundle from '" + liferayHome.toPath() + "', you need to run gradle task 'initBundle' first.");
    }
    JavaRunConfigurationExtensionManager.checkConfigurationIsValid(this);
}
Also used : RuntimeConfigurationWarning(com.intellij.execution.configurations.RuntimeConfigurationWarning) File(java.io.File)

Example 5 with RuntimeConfigurationWarning

use of com.intellij.execution.configurations.RuntimeConfigurationWarning in project moe-ide-integration by multi-os-engine.

the class MOEJUnitUtil method checkConfiguration.

public static void checkConfiguration(Module module, int TESTING_TYPE, String PACKAGE_NAME, String CLASS_NAME) throws RuntimeConfigurationException {
    JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
    switch(TESTING_TYPE) {
        case TEST_ALL_IN_PACKAGE:
            if (PACKAGE_NAME == null || PACKAGE_NAME.isEmpty()) {
                throw new RuntimeConfigurationWarning("No test package specified");
            }
            final PsiPackage testPackage = facade.findPackage(PACKAGE_NAME);
            if (testPackage == null) {
                throw new RuntimeConfigurationWarning(ExecutionBundle.message("package.does.not.exist.error.message", PACKAGE_NAME));
            }
            Vector<PsiClass> packageTestClasses = MOEJUnitUtil.getTestClasses(module, PACKAGE_NAME);
            if (packageTestClasses == null || packageTestClasses.size() == 0) {
                throw new RuntimeConfigurationWarning("Not found test class in package: " + PACKAGE_NAME);
            }
            break;
        case TEST_CLASS:
            JavaRunConfigurationModule configurationModule = new JavaRunConfigurationModule(module.getProject(), false);
            configurationModule.setModule(module);
            final PsiClass testClass = configurationModule.checkModuleAndClassName(CLASS_NAME, ExecutionBundle.message("no.test.class.specified.error.text"));
            if (!JUnitUtil.isTestClass(testClass)) {
                throw new RuntimeConfigurationWarning(ExecutionBundle.message("class.isnt.test.class.error.message", CLASS_NAME));
            }
            break;
        case TEST_METHOD:
            // Already not used
            break;
    }
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) RuntimeConfigurationWarning(com.intellij.execution.configurations.RuntimeConfigurationWarning) PsiClass(com.intellij.psi.PsiClass) PsiPackage(com.intellij.psi.PsiPackage) JavaRunConfigurationModule(com.intellij.execution.configurations.JavaRunConfigurationModule)

Aggregations

RuntimeConfigurationWarning (com.intellij.execution.configurations.RuntimeConfigurationWarning)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 File (java.io.File)5 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)4 Module (com.intellij.openapi.module.Module)4 JavaRunConfigurationModule (com.intellij.execution.configurations.JavaRunConfigurationModule)2 Project (com.intellij.openapi.project.Project)2 Nullable (org.jetbrains.annotations.Nullable)2 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 FlexCommonBundle (com.intellij.flex.FlexCommonBundle)1 FlexCommonUtils (com.intellij.flex.FlexCommonUtils)1 LinkageType (com.intellij.flex.model.bc.LinkageType)1 OutputType (com.intellij.flex.model.bc.OutputType)1 TargetPlatform (com.intellij.flex.model.bc.TargetPlatform)1 BrowserUtil (com.intellij.ide.BrowserUtil)1 ActionScriptClassResolver (com.intellij.javascript.flex.resolve.ActionScriptClassResolver)1 TestFileStructurePack (com.intellij.javascript.testFramework.TestFileStructurePack)1 FlexBundle (com.intellij.lang.javascript.flex.FlexBundle)1 AirPackageUtil (com.intellij.lang.javascript.flex.actions.airpackage.AirPackageUtil)1 FlashProjectStructureProblem (com.intellij.lang.javascript.flex.build.FlashProjectStructureProblem)1