Search in sources :

Example 26 with ModifiableFlexBuildConfiguration

use of com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration in project intellij-plugins by JetBrains.

the class FlexProjectConfigTest method testBcDependency.

public void testBcDependency() throws ConfigurationException {
    final Module module2 = createModule("module2");
    assertFalse(doesDepend(myModule, module2));
    assertFalse(doesDepend(module2, myModule));
    FlexTestUtils.modifyConfigs(myProject, editor -> {
        ModifiableFlexBuildConfiguration module1Config = editor.getConfigurations(myModule)[0];
        ModifiableFlexBuildConfiguration module2Config = editor.getConfigurations(module2)[0];
        ModifiableBuildConfigurationEntry entry = editor.createBcEntry(module1Config.getDependencies(), module2Config, null);
        editor.setEntries(module1Config.getDependencies(), Collections.singletonList(entry));
    });
    assertTrue(doesDepend(myModule, module2));
    assertFalse(doesDepend(module2, myModule));
    FlexTestUtils.modifyConfigs(myProject, editor -> {
        ModifiableFlexBuildConfiguration module1Config = editor.getConfigurations(myModule)[0];
        editor.setEntries(module1Config.getDependencies(), new ArrayList<>());
    });
    assertFalse(doesDepend(myModule, module2));
    assertFalse(doesDepend(module2, myModule));
    final Module module3 = createModule("module3");
    final Module module4 = createModule("module4");
    FlexTestUtils.modifyConfigs(myProject, editor -> {
        ModifiableFlexBuildConfiguration m1bc1 = editor.getConfigurations(myModule)[0];
        ModifiableFlexBuildConfiguration m1bc2 = createConfiguration(editor, myModule);
        ModifiableFlexBuildConfiguration m1bc3 = createConfiguration(editor, myModule);
        ModifiableFlexBuildConfiguration m1bc4 = createConfiguration(editor, myModule);
        ModifiableFlexBuildConfiguration m2bc1 = editor.getConfigurations(module2)[0];
        ModifiableFlexBuildConfiguration m3bc1 = editor.getConfigurations(module3)[0];
        ModifiableFlexBuildConfiguration m2bc2 = createConfiguration(editor, module2);
        ModifiableBuildConfigurationEntry e1 = editor.createBcEntry(m1bc1.getDependencies(), m2bc1, null);
        editor.setEntries(m1bc1.getDependencies(), Collections.singletonList(e1));
        ModifiableBuildConfigurationEntry e2 = editor.createBcEntry(m1bc2.getDependencies(), m2bc2, null);
        ModifiableBuildConfigurationEntry e3 = editor.createBcEntry(m1bc2.getDependencies(), m3bc1, null);
        editor.setEntries(m1bc1.getDependencies(), Arrays.asList(e2, e3));
    });
    assertTrue(doesDepend(myModule, module2));
    assertTrue(doesDepend(myModule, module3));
    assertFalse(doesDepend(myModule, module4));
}
Also used : ModifiableBuildConfigurationEntry(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableBuildConfigurationEntry) Module(com.intellij.openapi.module.Module) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)

Example 27 with ModifiableFlexBuildConfiguration

use of com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration in project intellij-plugins by JetBrains.

the class ActionScriptCompletionInTextFieldTest method doTestCustomScope.

private void doTestCustomScope(String activeBcName, String selectedBcName, int numberOfVariants) throws Exception {
    String filename = getTestName(false).replaceAll("\\d+", "");
    configureByFiles(null, BASE_PATH + filename + "_2.mxml", BASE_PATH + filename + "_3.mxml");
    final Sdk sdk = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.5"), null, true);
    FlexTestUtils.modifyConfigs(myProject, e -> {
        {
            final ModifiableFlexBuildConfiguration bc = e.getConfigurations(myModule)[0];
            bc.setName("Flex");
            bc.setNature(new BuildConfigurationNature(TargetPlatform.Web, false, OutputType.Application));
            FlexTestUtils.setSdk(bc, sdk);
        }
        {
            final ModifiableFlexBuildConfiguration bc = e.createConfiguration(myModule);
            bc.setName("AIR");
            bc.setNature(new BuildConfigurationNature(TargetPlatform.Desktop, false, OutputType.Application));
            FlexTestUtils.setSdk(bc, sdk);
        }
    });
    final FlexBuildConfigurationManager manager = FlexBuildConfigurationManager.getInstance(myModule);
    manager.setActiveBuildConfiguration(manager.findConfigurationByName(activeBcName));
    final ModuleWithDependenciesScope scope = FlexUtils.getModuleWithDependenciesAndLibrariesScope(myModule, manager.findConfigurationByName(selectedBcName), false);
    PublicInheritorFilter filter = new PublicInheritorFilter(myProject, FlashRunConfigurationForm.SPRITE_CLASS_NAME, scope, true);
    PsiFile fragment = JSReferenceEditor.forClassName("", myProject, null, GlobalSearchScope.moduleScope(myModule), null, filter, "").getPsiFile();
    doTestForEditorTextField((JSExpressionCodeFragment) fragment, "", "js2", BASE_PATH + filename + ".txt");
    if (numberOfVariants == 0) {
        assertNull(myItems);
    } else {
        assertEquals(numberOfVariants, myItems.length);
    }
}
Also used : BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) PublicInheritorFilter(com.intellij.lang.javascript.psi.impl.PublicInheritorFilter) FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) ModuleWithDependenciesScope(com.intellij.openapi.module.impl.scopes.ModuleWithDependenciesScope) PsiFile(com.intellij.psi.PsiFile) Sdk(com.intellij.openapi.projectRoots.Sdk) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)

Example 28 with ModifiableFlexBuildConfiguration

use of com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration in project intellij-plugins by JetBrains.

the class ActionScriptCompletionTest method testTwoSdks.

public void testTwoSdks() throws Exception {
    final Sdk sdk45 = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.5"), null, true);
    final Sdk sdk46 = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.6"), null, false);
    FlexTestUtils.modifyConfigs(myProject, new Consumer<FlexProjectConfigurationEditor>() {

        public void consume(final FlexProjectConfigurationEditor editor) {
            ModifiableFlexBuildConfiguration bc1 = editor.getConfigurations(myModule)[0];
            bc1.setName("1");
            FlexTestUtils.setSdk(bc1, sdk45);
            ModifiableFlexBuildConfiguration bc2 = editor.createConfiguration(myModule);
            bc2.setName("2");
            FlexTestUtils.setSdk(bc2, sdk46);
        }
    });
    final FlexBuildConfigurationManager m = FlexBuildConfigurationManager.getInstance(myModule);
    class TestZZ implements ThrowableRunnable<Exception> {

        private final String myBcName;

        private final String myExpectedTypeText;

        TestZZ(final String bcName, final String expectedTypeText) {
            myBcName = bcName;
            myExpectedTypeText = expectedTypeText;
        }

        @Override
        public void run() throws Exception {
            m.setActiveBuildConfiguration(m.findConfigurationByName(myBcName));
            defaultTest();
            for (LookupElement item : myItems) {
                final LookupElementPresentation p = new LookupElementPresentation();
                item.renderElement(p);
                assertEquals(myExpectedTypeText, p.getTypeText());
            }
        }
    }
    new TestZZ("1", sdk45.getName()).run();
    new TestZZ("2", sdk46.getName()).run();
    new TestZZ("1", sdk45.getName()).run();
}
Also used : FlexProjectConfigurationEditor(com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor) FlexBuildConfigurationManager(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager) ThrowableRunnable(com.intellij.util.ThrowableRunnable) LookupElementPresentation(com.intellij.codeInsight.lookup.LookupElementPresentation) Sdk(com.intellij.openapi.projectRoots.Sdk) LookupElement(com.intellij.codeInsight.lookup.LookupElement) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)

Example 29 with ModifiableFlexBuildConfiguration

use of com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration in project intellij-plugins by JetBrains.

the class FlexUnitRunnerParameters method checkAndGetModuleAndBC.

public Pair<Module, FlexBuildConfiguration> checkAndGetModuleAndBC(final Project project) throws RuntimeConfigurationError {
    final Pair<Module, FlexBuildConfiguration> moduleAndBC = super.checkAndGetModuleAndBC(project);
    doCheck(project, moduleAndBC);
    final ModifiableFlexBuildConfiguration overriddenBC = Factory.getTemporaryCopyForCompilation(moduleAndBC.second);
    overriddenBC.setOutputType(OutputType.Application);
    overriddenBC.setMainClass(FlexCommonUtils.FLEX_UNIT_LAUNCHER);
    overriddenBC.setOutputFileName("_flexunit.swf");
    overriddenBC.setOutputFolder(VfsUtilCore.urlToPath(CompilerModuleExtension.getInstance(moduleAndBC.first).getCompilerOutputUrlForTests()));
    overriddenBC.setUseHtmlWrapper(false);
    overriddenBC.setRLMs(Collections.emptyList());
    overriddenBC.setCssFilesToCompile(Collections.emptyList());
    overriddenBC.setSkipCompile(false);
    overriddenBC.getDependencies().setFrameworkLinkage(LinkageType.Merged);
    for (ModifiableDependencyEntry entry : overriddenBC.getDependencies().getModifiableEntries()) {
        if (entry.getDependencyType().getLinkageType() == LinkageType.External) {
            entry.getDependencyType().setLinkageType(LinkageType.Merged);
        }
    }
    return Pair.create(moduleAndBC.first, ((FlexBuildConfiguration) overriddenBC));
}
Also used : FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration) ModifiableDependencyEntry(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableDependencyEntry) Module(com.intellij.openapi.module.Module) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)

Example 30 with ModifiableFlexBuildConfiguration

use of com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration in project intellij-plugins by JetBrains.

the class FlexBCConfigurator method copy.

public void copy(final CompositeConfigurable configurable, final Runnable treeNodeNameUpdater) {
    try {
        configurable.apply();
    } catch (ConfigurationException ignored) {
    /**/
    }
    ModifiableFlexBuildConfiguration existingBC = myConfigurablesMap.getKeysByValue(configurable).get(0);
    FlexBCConfigurable unwrapped = FlexBCConfigurable.unwrap(configurable);
    final String title = FlexBundle.message("copy.build.configuration", existingBC.getName(), unwrapped.getModule().getName());
    Module module = unwrapped.getModule();
    AddBuildConfigurationDialog dialog = new AddBuildConfigurationDialog(module.getProject(), title, getUsedNames(module), existingBC.getNature(), true);
    dialog.reset("", existingBC.getAndroidPackagingOptions().isEnabled(), existingBC.getIosPackagingOptions().isEnabled());
    if (!dialog.showAndGet()) {
        return;
    }
    final String newBCName = dialog.getBCName();
    final String fileName = PathUtil.suggestFileName(newBCName);
    final BuildConfigurationNature newNature = dialog.getNature();
    ModifiableFlexBuildConfiguration newBC = myConfigEditor.copyConfiguration(existingBC, newNature);
    newBC.setName(newBCName);
    newBC.setOutputFileName(fileName + (newBC.getOutputType() == OutputType.Library ? ".swc" : ".swf"));
    updatePackageFileName(newBC, fileName);
    if (newNature.isApp() && newNature.isMobilePlatform()) {
        newBC.getAndroidPackagingOptions().setEnabled(dialog.isAndroidEnabled());
        newBC.getIosPackagingOptions().setEnabled(dialog.isIOSEnabled());
    }
    createConfigurableNode(newBC, unwrapped.getModule(), treeNodeNameUpdater);
}
Also used : BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) ConfigurationException(com.intellij.openapi.options.ConfigurationException) FlexBCConfigurable(com.intellij.lang.javascript.flex.projectStructure.ui.FlexBCConfigurable) Module(com.intellij.openapi.module.Module) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration) AddBuildConfigurationDialog(com.intellij.lang.javascript.flex.projectStructure.ui.AddBuildConfigurationDialog)

Aggregations

ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)31 Sdk (com.intellij.openapi.projectRoots.Sdk)16 Module (com.intellij.openapi.module.Module)8 FlexBuildConfigurationManager (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager)5 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)4 FlexProjectConfigurationEditor (com.intellij.lang.javascript.flex.projectStructure.model.impl.FlexProjectConfigurationEditor)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 LookupElement (com.intellij.codeInsight.lookup.LookupElement)3 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)3 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 IOException (java.io.IOException)3 FlexTestUtils (com.intellij.flex.util.FlexTestUtils)2 FlexStylesIndexableSetContributor (com.intellij.javascript.flex.css.FlexStylesIndexableSetContributor)2 FlexSchemaHandler (com.intellij.javascript.flex.mxml.schema.FlexSchemaHandler)2 FlexModuleType (com.intellij.lang.javascript.flex.FlexModuleType)2 SdkEntry (com.intellij.lang.javascript.flex.projectStructure.model.SdkEntry)2 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)2 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)2 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)2 ModuleType (com.intellij.openapi.module.ModuleType)2