Search in sources :

Example 1 with BCBasedRunnerParameters

use of com.intellij.lang.javascript.flex.run.BCBasedRunnerParameters in project intellij-plugins by JetBrains.

the class FlexRunner method doExecute.

@Override
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
    final BCBasedRunnerParameters parameters = ((RemoteFlashRunConfiguration) env.getRunProfile()).getRunnerParameters();
    RunContentDescriptor runContentDescriptor = XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {

        @Override
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
            try {
                return DebugPathManager.IS_DEV ? new MyFlexDebugProcessAbleToResolveFileDebugId(callback, session, buildConfiguration, parameters) : new MyFlexDebugProcess(callback, session, buildConfiguration, parameters);
            } catch (IOException e) {
                throw new ExecutionException(e.getMessage(), e);
            } finally {
                buildConfiguration = null;
            }
        }
    }).getRunContentDescriptor();
    ProcessHandler processHandler = runContentDescriptor.getProcessHandler();
    assert processHandler != null;
    //noinspection deprecation
    processHandler.putUserData(ProcessHandler.SILENTLY_DESTROY_ON_CLOSE, true);
    return runContentDescriptor;
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) BCBasedRunnerParameters(com.intellij.lang.javascript.flex.run.BCBasedRunnerParameters) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) RemoteFlashRunConfiguration(com.intellij.lang.javascript.flex.run.RemoteFlashRunConfiguration) ProcessHandler(com.intellij.execution.process.ProcessHandler) IOException(java.io.IOException) ExecutionException(com.intellij.execution.ExecutionException) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with BCBasedRunnerParameters

use of com.intellij.lang.javascript.flex.run.BCBasedRunnerParameters 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 3 with BCBasedRunnerParameters

use of com.intellij.lang.javascript.flex.run.BCBasedRunnerParameters 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)

Aggregations

BCBasedRunnerParameters (com.intellij.lang.javascript.flex.run.BCBasedRunnerParameters)3 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)2 FlexUnitRunConfiguration (com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration)2 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)2 FlashRunConfiguration (com.intellij.lang.javascript.flex.run.FlashRunConfiguration)2 Module (com.intellij.openapi.module.Module)2 ConfigurationException (com.intellij.openapi.options.ConfigurationException)2 Pair (com.intellij.openapi.util.Pair)2 NotNull (org.jetbrains.annotations.NotNull)2 ExecutionException (com.intellij.execution.ExecutionException)1 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)1 RemoteFlashRunConfiguration (com.intellij.lang.javascript.flex.run.RemoteFlashRunConfiguration)1 Ref (com.intellij.openapi.util.Ref)1 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)1 XDebugSession (com.intellij.xdebugger.XDebugSession)1 IOException (java.io.IOException)1