use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager in project intellij-plugins by JetBrains.
the class FlexCompletionTest method testNonApplicableInheritors.
@JSTestOptions({ JSTestOption.WithGumboSdk, JSTestOption.WithFlexLib, JSTestOption.WithSmartCompletion })
public void testNonApplicableInheritors() throws Exception {
FlexTestUtils.modifyConfigs(myProject, editor -> {
final ModifiableFlexBuildConfiguration bc1 = editor.getConfigurations(myModule)[0];
final ModifiableFlexBuildConfiguration bc2 = editor.copyConfiguration(bc1, BuildConfigurationNature.DEFAULT);
bc2.setName("bc 2");
bc2.getDependencies().getModifiableEntries().clear();
});
LookupElement[] elements = doTest("", "as");
assertEquals(3, elements.length);
assertEquals("Image", elements[0].getLookupString());
assertEquals("Base64Image", elements[1].getLookupString());
assertEquals("ImageMap", elements[2].getLookupString());
final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(myModule);
manager.setActiveBuildConfiguration(manager.findConfigurationByName("bc 2"));
elements = doTest("", "as");
assertEquals(1, elements.length);
assertEquals("Image", elements[0].getLookupString());
}
use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager in project intellij-plugins by JetBrains.
the class JSConditionalCompilationDefinitionsProviderImpl method processConditionalCompilationDefinitions.
private void processConditionalCompilationDefinitions(final Module module, final Processor<Pair<String, String>> processor) {
final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(module);
final FlexBuildConfiguration bc = manager.getActiveConfiguration();
final ModuleOrProjectCompilerOptions moduleLevelOptions = manager.getModuleLevelCompilerOptions();
final ModuleOrProjectCompilerOptions projectLevelOptions = FlexProjectLevelCompilerOptionsHolder.getInstance(module.getProject()).getProjectLevelCompilerOptions();
if (!FlexUtils.processCompilerOption(module, bc, "compiler.define", processor))
return;
if (!processDefinitionsFromCompilerOptions(projectLevelOptions.getAdditionalOptions(), processor))
return;
if (!processDefinitionsFromCompilerOptions(moduleLevelOptions.getAdditionalOptions(), processor))
return;
if (!processDefinitionsFromCompilerOptions(bc.getCompilerOptions().getAdditionalOptions(), processor))
return;
for (Pair<String, String> nameAndValue : getDefinitionsFromConfigFile(bc.getCompilerOptions().getAdditionalConfigFilePath())) {
if (!processor.process(nameAndValue))
return;
}
}
use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager in project intellij-plugins by JetBrains.
the class FlexUnitRuntimeConfigurationProducer method configureRunnerParameters.
private static boolean configureRunnerParameters(final FlexUnitRunnerParameters params, final Module module, final PsiElement element) {
final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(module);
FlexUnitSupport support = null;
FlexBuildConfiguration bc = null;
if (module.getName().equals(params.getModuleName()) && !params.getBCName().isEmpty()) {
bc = manager.findConfigurationByName(params.getBCName());
if (bc != null) {
support = FlexUnitSupport.getSupport(bc, module);
}
}
if (support == null) {
bc = manager.getActiveConfiguration();
support = FlexUnitSupport.getSupport(bc, module);
}
if (support == null) {
for (FlexBuildConfiguration anyBC : manager.getBuildConfigurations()) {
bc = anyBC;
support = FlexUnitSupport.getSupport(bc, module);
if (support != null) {
break;
}
}
}
if (support == null) {
return false;
}
params.setModuleName(module.getName());
params.setBCName(bc.getName());
if (bc.getTargetPlatform() == TargetPlatform.Mobile) {
if (bc.getAndroidPackagingOptions().isEnabled()) {
params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.Android);
} else if (bc.getIosPackagingOptions().isEnabled()) {
params.setAppDescriptorForEmulator(FlashRunnerParameters.AppDescriptorForEmulator.IOS);
}
}
if (element instanceof JSClass) {
final JSClass clazz = (JSClass) element;
if (!support.isTestClass(clazz, true))
return false;
forClass(clazz, params);
} else if (element instanceof JSFunction) {
final JSFunction method = (JSFunction) element;
final String methodName = method.getName();
final JSClass clazz = (JSClass) element.getParent();
if (!support.isTestClass(clazz, true))
return false;
if (methodName == null || !support.isTestMethod(method)) {
forClass(clazz, params);
} else {
params.setClassName(clazz.getQualifiedName());
params.setMethodName(methodName);
params.setScope(FlexUnitRunnerParameters.Scope.Method);
}
} else if (element instanceof PsiDirectory) {
if (!forDirectory((PsiDirectory) element, module, params))
return false;
} else if (element instanceof PsiDirectoryContainer) {
if (!forPackage((PsiDirectoryContainer) element, module, params))
return false;
} else {
return false;
}
return true;
}
use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager 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;
}
use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager in project intellij-plugins by JetBrains.
the class FlashRunConfigurationProducer method getBCToBaseOn.
private static FlexBuildConfiguration getBCToBaseOn(final Module module, final String fqn) {
final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(module);
FlexBuildConfiguration appWithSuitableMainClass = null;
for (FlexBuildConfiguration bc : manager.getBuildConfigurations()) {
if (bc.getOutputType() == OutputType.Application && fqn.equals(bc.getMainClass())) {
if (manager.getActiveConfiguration() == bc) {
// the best choice
return bc;
}
appWithSuitableMainClass = bc;
}
}
// if no apps with matching main class - take active bc and override main class
return appWithSuitableMainClass != null ? appWithSuitableMainClass : manager.getActiveConfiguration();
}
Aggregations