Search in sources :

Example 36 with RunConfiguration

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

the class ValidateFlashConfigurationsPrecompileTask method getProblems.

static Collection<Trinity<Module, FlexBuildConfiguration, FlashProjectStructureProblem>> getProblems(final CompileScope scope, final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCsToCompile) {
    final Collection<Trinity<Module, FlexBuildConfiguration, FlashProjectStructureProblem>> problems = new ArrayList<>();
    for (final Pair<Module, FlexBuildConfiguration> moduleAndBC : modulesAndBCsToCompile) {
        final Module module = moduleAndBC.first;
        final FlexBuildConfiguration bc = moduleAndBC.second;
        final Consumer<FlashProjectStructureProblem> errorConsumer = problem -> problems.add(Trinity.create(module, bc, problem));
        checkConfiguration(module, bc, false, errorConsumer);
        final RunConfiguration runConfig = CompileStepBeforeRun.getRunConfiguration(scope);
        if (bc.getNature().isApp() && runConfig instanceof FlashRunConfiguration) {
            final FlashRunnerParameters params = ((FlashRunConfiguration) runConfig).getRunnerParameters();
            if (module.getName().equals(params.getModuleName()) && bc.getName().equals(params.getBCName())) {
                if (bc.getNature().isDesktopPlatform()) {
                    FlashRunnerParameters.checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getAirDesktopPackagingOptions(), errorConsumer, false, "does not matter");
                } else if (bc.getNature().isMobilePlatform()) {
                    switch(params.getMobileRunTarget()) {
                        case Emulator:
                            switch(params.getAppDescriptorForEmulator()) {
                                case Android:
                                    FlashRunnerParameters.checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getAndroidPackagingOptions(), errorConsumer, false, "does not matter");
                                    break;
                                case IOS:
                                    FlashRunnerParameters.checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getIosPackagingOptions(), errorConsumer, false, "does not matter");
                                    break;
                            }
                            break;
                        case AndroidDevice:
                            checkPackagingOptions(module, bc.getSdk(), bc.getAndroidPackagingOptions(), false, PathUtil.getParentPath(bc.getActualOutputFilePath()), errorConsumer);
                            break;
                        case iOSSimulator:
                            checkPackagingOptions(module, bc.getSdk(), bc.getIosPackagingOptions(), true, PathUtil.getParentPath(bc.getActualOutputFilePath()), errorConsumer);
                            break;
                        case iOSDevice:
                            checkPackagingOptions(module, bc.getSdk(), bc.getIosPackagingOptions(), false, PathUtil.getParentPath(bc.getActualOutputFilePath()), errorConsumer);
                            break;
                    }
                }
            }
        }
    }
    checkSimilarOutputFiles(modulesAndBCsToCompile, trinity -> problems.add(trinity));
    return problems;
}
Also used : Trinity(com.intellij.openapi.util.Trinity) HyperlinkEvent(javax.swing.event.HyperlinkEvent) VirtualFile(com.intellij.openapi.vfs.VirtualFile) THashSet(gnu.trove.THashSet) THashMap(gnu.trove.THashMap) TargetPlatform(com.intellij.flex.model.bc.TargetPlatform) ReadAction(com.intellij.openapi.application.ReadAction) FlexCommonUtils(com.intellij.flex.FlexCommonUtils) BCUtils(com.intellij.lang.javascript.flex.projectStructure.options.BCUtils) FlexmojosSdkType(com.intellij.lang.javascript.flex.sdk.FlexmojosSdkType) Map(java.util.Map) FileUtil(com.intellij.openapi.util.io.FileUtil) Module(com.intellij.openapi.module.Module) ProjectStructureProblemType(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemType) FlexBuildConfigurationsExtension(com.intellij.lang.javascript.flex.projectStructure.FlexBuildConfigurationsExtension) com.intellij.openapi.compiler(com.intellij.openapi.compiler) Collection(java.util.Collection) Set(java.util.Set) FlexBundle(com.intellij.lang.javascript.flex.FlexBundle) NotificationListener(com.intellij.notification.NotificationListener) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) NotificationType(com.intellij.notification.NotificationType) Notification(com.intellij.notification.Notification) Nullable(org.jetbrains.annotations.Nullable) ModuleRootManager(com.intellij.openapi.roots.ModuleRootManager) CompilerWorkspaceConfiguration(com.intellij.compiler.CompilerWorkspaceConfiguration) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) Consumer(com.intellij.util.Consumer) FlexUtils(com.intellij.lang.javascript.flex.FlexUtils) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) OutputType(com.intellij.flex.model.bc.OutputType) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) CompileStepBeforeRun(com.intellij.compiler.options.CompileStepBeforeRun) ArrayList(java.util.ArrayList) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) com.intellij.lang.javascript.flex.projectStructure.ui(com.intellij.lang.javascript.flex.projectStructure.ui) Project(com.intellij.openapi.project.Project) FlexSdkUtils(com.intellij.lang.javascript.flex.sdk.FlexSdkUtils) FlexCommonBundle(com.intellij.flex.FlexCommonBundle) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) StringUtil(com.intellij.openapi.util.text.StringUtil) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) com.intellij.lang.javascript.flex.projectStructure.model(com.intellij.lang.javascript.flex.projectStructure.model) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters) Sdk(com.intellij.openapi.projectRoots.Sdk) SystemInfo(com.intellij.openapi.util.SystemInfo) File(java.io.File) BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) Place(com.intellij.ui.navigation.Place) Pair(com.intellij.openapi.util.Pair) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable) Navigatable(com.intellij.pom.Navigatable) PathUtil(com.intellij.util.PathUtil) Trinity(com.intellij.openapi.util.Trinity) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) ArrayList(java.util.ArrayList) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Module(com.intellij.openapi.module.Module) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters)

Example 37 with RunConfiguration

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

the class FlexBuildTargetScopeProvider method getBuildTargetScopes.

@NotNull
public List<TargetTypeBuildScope> getBuildTargetScopes(@NotNull final CompileScope baseScope, @NotNull final CompilerFilter filter, @NotNull final Project project, boolean forceBuild) {
    final RunConfiguration runConfiguration = CompileStepBeforeRun.getRunConfiguration(baseScope);
    final Collection<Pair<Module, FlexBuildConfiguration>> bcsToCompileForPackaging = FlexResourceBuildTargetScopeProvider.getBCsToCompileForPackaging(baseScope);
    List<String> targetIds = new ArrayList<>();
    try {
        for (Pair<Module, FlexBuildConfiguration> moduleAndBC : getModulesAndBCsToCompile(baseScope)) {
            final Module module = moduleAndBC.first;
            final FlexBuildConfiguration bc = moduleAndBC.second;
            if (bcsToCompileForPackaging != null && contains(bcsToCompileForPackaging, module, bc)) {
                final boolean forcedDebugStatus = getForcedDebugStatus(project, bc);
                targetIds.add(FlexCommonUtils.getBuildTargetId(module.getName(), bc.getName(), forcedDebugStatus));
            } else if (bc.isTempBCForCompilation()) {
                LOG.assertTrue(runConfiguration instanceof FlashRunConfiguration || runConfiguration instanceof FlexUnitRunConfiguration, bc.getName());
                final BCBasedRunnerParameters params = runConfiguration instanceof FlashRunConfiguration ? ((FlashRunConfiguration) runConfiguration).getRunnerParameters() : ((FlexUnitRunConfiguration) runConfiguration).getRunnerParameters();
                LOG.assertTrue(params.getModuleName().equals(module.getName()), "Module name in run config: " + params.getModuleName() + ", expected: " + module.getName());
                LOG.assertTrue(params.getBCName().equals(bc.getName()), "BC name in run config: " + params.getBCName() + ", expected: " + bc.getName());
                targetIds.add(FlexCommonUtils.getBuildTargetIdForRunConfig(runConfiguration.getType().getId(), runConfiguration.getName()));
            } else {
                targetIds.add(FlexCommonUtils.getBuildTargetId(module.getName(), bc.getName(), null));
            }
        }
    } catch (ConfigurationException e) {
        // can't happen because checked in ValidateFlashConfigurationsPrecompileTask
        LOG.error(e);
    }
    if (targetIds.isEmpty()) {
        return Collections.emptyList();
    }
    return Collections.singletonList(CmdlineProtoUtil.createTargetsScope(FlexBuildTargetType.INSTANCE.getTypeId(), targetIds, forceBuild));
}
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) 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) Pair(com.intellij.openapi.util.Pair) NotNull(org.jetbrains.annotations.NotNull)

Example 38 with RunConfiguration

use of com.intellij.execution.configurations.RunConfiguration 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 39 with RunConfiguration

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

the class FlashRunConfigurationProducer method findSuitableRunConfig.

@Nullable
private static RunConfiguration findSuitableRunConfig(final Module module, final String fqn, final List<RunConfiguration> existing) {
    final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(module);
    RunConfiguration basedOnBC = null;
    RunConfiguration basedOnMainClass = null;
    RunConfiguration basedOnMainClassAndActiveBC = null;
    for (final RunConfiguration runConfig : existing) {
        final FlashRunnerParameters params = ((FlashRunConfiguration) runConfig).getRunnerParameters();
        if (module.getName().equals(params.getModuleName())) {
            final FlexBuildConfiguration bc = manager.findConfigurationByName(params.getBCName());
            if (bc == null)
                continue;
            if (params.isOverrideMainClass()) {
                if (fqn.equals(params.getOverriddenMainClass())) {
                    if (manager.getActiveConfiguration() == bc) {
                        basedOnMainClassAndActiveBC = runConfig;
                    }
                    basedOnMainClass = runConfig;
                }
            } else {
                if (bc.getOutputType() == OutputType.Application && fqn.equals(bc.getMainClass())) {
                    if (manager.getActiveConfiguration() == bc) {
                        // the best choice
                        return runConfig;
                    }
                    basedOnBC = runConfig;
                }
            }
        }
    }
    // forth - based on overridden main class and any bc
    return basedOnBC != null ? basedOnBC : basedOnMainClassAndActiveBC != null ? basedOnMainClassAndActiveBC : basedOnMainClass;
}
Also used : FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Nullable(org.jetbrains.annotations.Nullable)

Example 40 with RunConfiguration

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

the class FlashRunConfigurationProducer method isConfigurationFromContext.

public boolean isConfigurationFromContext(final FlashRunConfiguration configuration, final ConfigurationContext context) {
    final Module module = context.getModule();
    if (module == null || ModuleType.get(module) != FlexModuleType.getInstance())
        return false;
    if (!module.getName().equals(configuration.getRunnerParameters().getModuleName()))
        return false;
    final JSClass jsClass = getJSClass(context.getPsiLocation());
    if (jsClass == null || !isAcceptedMainClass(jsClass, module))
        return false;
    final List<RunConfiguration> existing = RunManager.getInstance(module.getProject()).getConfigurationsList(getConfigurationType());
    final RunConfiguration suitable = findSuitableRunConfig(module, jsClass.getQualifiedName(), existing);
    return suitable == configuration;
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) Module(com.intellij.openapi.module.Module) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass)

Aggregations

RunConfiguration (com.intellij.execution.configurations.RunConfiguration)59 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)16 Module (com.intellij.openapi.module.Module)13 Nullable (org.jetbrains.annotations.Nullable)12 Project (com.intellij.openapi.project.Project)10 PsiElement (com.intellij.psi.PsiElement)7 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)6 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)6 Pair (com.intellij.openapi.util.Pair)6 NotNull (org.jetbrains.annotations.NotNull)6 AndroidTestRunConfiguration (com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration)5 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)5 BeforeRunTask (com.intellij.execution.BeforeRunTask)4 FlashRunConfiguration (com.intellij.lang.javascript.flex.run.FlashRunConfiguration)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrayList (java.util.ArrayList)4 AndroidJUnitConfiguration (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration)3 BeforeRunTaskProvider (com.intellij.execution.BeforeRunTaskProvider)3 Location (com.intellij.execution.Location)3 RunManager (com.intellij.execution.RunManager)3