Search in sources :

Example 1 with FlexBuildConfigurationManager

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());
}
Also used : FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) LookupElement(com.intellij.codeInsight.lookup.LookupElement) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration) JSTestOptions(com.intellij.lang.javascript.JSTestOptions)

Example 2 with FlexBuildConfigurationManager

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;
    }
}
Also used : ModuleOrProjectCompilerOptions(com.intellij.lang.javascript.flex.projectStructure.model.ModuleOrProjectCompilerOptions) FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)

Example 3 with FlexBuildConfigurationManager

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;
}
Also used : FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) JSFunction(com.intellij.lang.javascript.psi.JSFunction) PsiDirectory(com.intellij.psi.PsiDirectory) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) PsiDirectoryContainer(com.intellij.psi.PsiDirectoryContainer) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass)

Example 4 with FlexBuildConfigurationManager

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;
}
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 5 with FlexBuildConfigurationManager

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();
}
Also used : FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)

Aggregations

FlexBuildConfigurationManager (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager)9 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)5 ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)4 Sdk (com.intellij.openapi.projectRoots.Sdk)3 LookupElement (com.intellij.codeInsight.lookup.LookupElement)2 LookupElementPresentation (com.intellij.codeInsight.lookup.LookupElementPresentation)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)1 JSTestOptions (com.intellij.lang.javascript.JSTestOptions)1 ModuleOrProjectCompilerOptions (com.intellij.lang.javascript.flex.projectStructure.model.ModuleOrProjectCompilerOptions)1 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)1 JSFunction (com.intellij.lang.javascript.psi.JSFunction)1 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)1 PublicInheritorFilter (com.intellij.lang.javascript.psi.impl.PublicInheritorFilter)1 SimpleDataContext (com.intellij.openapi.actionSystem.impl.SimpleDataContext)1 ModuleWithDependenciesScope (com.intellij.openapi.module.impl.scopes.ModuleWithDependenciesScope)1 PsiDirectory (com.intellij.psi.PsiDirectory)1 PsiDirectoryContainer (com.intellij.psi.PsiDirectoryContainer)1 PsiFile (com.intellij.psi.PsiFile)1 RowIcon (com.intellij.ui.RowIcon)1