use of com.intellij.execution.configurations.RunConfiguration in project intellij-plugins by JetBrains.
the class FlexUnitConfigurationTest method doTest.
private void doTest(String filename) throws Exception {
configureByFile(BASE_PATH + filename);
final Map<Integer, String> markers = JSTestUtils.extractPositionMarkers(getProject(), getEditor().getDocument());
assertFalse("No caret markers found", markers.isEmpty());
assertFalse("No 'expected' value", markers.containsValue(null));
final DataContext dataContext = DataManager.getInstance().getDataContext(getEditor().getComponent());
int i = 1;
for (Map.Entry<Integer, String> marker : markers.entrySet()) {
String place = filename + ": marker " + i++ + ": ";
getEditor().getCaretModel().moveToOffset(marker.getKey());
final ConfigurationFromContext configurationFromContext = new FlexUnitRuntimeConfigurationProducer().createConfigurationFromContext(ConfigurationContext.getFromContext(dataContext));
final RunConfiguration configuration = configurationFromContext == null ? null : configurationFromContext.getConfiguration();
if ("null".equals(marker.getValue())) {
assertNull(place + "Null configuration expected", configuration);
} else {
assertNotNull(place + "Not null configuration expected", configuration);
assertTrue(place + "Invalid configuration", configuration instanceof FlexUnitRunConfiguration);
final String[] expected;
if ("null".equals(marker.getValue())) {
expected = null;
} else {
expected = marker.getValue().split(" ");
assertEquals(place + "Expected should be in the form: \"Class com.test.Foo\" or \"Method com.test.Foo.testBar()\" or \"Package com.test\"", 2, expected.length);
}
final FlexUnitRunnerParameters params = ((FlexUnitRunConfiguration) configuration).getRunnerParameters();
assertEquals(place + "Invalid scope", expected[0], params.getScope().name());
final String definition;
switch(params.getScope()) {
case Class:
definition = params.getClassName();
break;
case Method:
definition = params.getClassName() + "." + params.getMethodName() + "()";
break;
case Package:
definition = params.getPackageName();
break;
default:
fail(place + "Unknown scope: " + params.getScope());
definition = null;
}
assertEquals(place + "Invalid definition", expected[1], definition);
}
}
}
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;
}
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));
}
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;
}
Aggregations