Search in sources :

Example 41 with FlexBuildConfiguration

use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration 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;
}
Also used : Trinity(com.intellij.openapi.util.Trinity) HyperlinkEvent(javax.swing.event.HyperlinkEvent) VirtualFile(com.intellij.openapi.vfs.VirtualFile) THashSet(gnu.trove.THashSet) THashMap(gnu.trove.THashMap) TargetPlatform(com.intellij.flex.model.bc.TargetPlatform) ReadAction(com.intellij.openapi.application.ReadAction) FlexCommonUtils(com.intellij.flex.FlexCommonUtils) BCUtils(com.intellij.lang.javascript.flex.projectStructure.options.BCUtils) FlexmojosSdkType(com.intellij.lang.javascript.flex.sdk.FlexmojosSdkType) Map(java.util.Map) FileUtil(com.intellij.openapi.util.io.FileUtil) Module(com.intellij.openapi.module.Module) ProjectStructureProblemType(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureProblemType) FlexBuildConfigurationsExtension(com.intellij.lang.javascript.flex.projectStructure.FlexBuildConfigurationsExtension) com.intellij.openapi.compiler(com.intellij.openapi.compiler) Collection(java.util.Collection) Set(java.util.Set) FlexBundle(com.intellij.lang.javascript.flex.FlexBundle) NotificationListener(com.intellij.notification.NotificationListener) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) NotificationType(com.intellij.notification.NotificationType) Notification(com.intellij.notification.Notification) Nullable(org.jetbrains.annotations.Nullable) ModuleRootManager(com.intellij.openapi.roots.ModuleRootManager) CompilerWorkspaceConfiguration(com.intellij.compiler.CompilerWorkspaceConfiguration) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) Consumer(com.intellij.util.Consumer) FlexUtils(com.intellij.lang.javascript.flex.FlexUtils) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) OutputType(com.intellij.flex.model.bc.OutputType) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) CompileStepBeforeRun(com.intellij.compiler.options.CompileStepBeforeRun) ArrayList(java.util.ArrayList) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) com.intellij.lang.javascript.flex.projectStructure.ui(com.intellij.lang.javascript.flex.projectStructure.ui) Project(com.intellij.openapi.project.Project) FlexSdkUtils(com.intellij.lang.javascript.flex.sdk.FlexSdkUtils) FlexCommonBundle(com.intellij.flex.FlexCommonBundle) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) StringUtil(com.intellij.openapi.util.text.StringUtil) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) com.intellij.lang.javascript.flex.projectStructure.model(com.intellij.lang.javascript.flex.projectStructure.model) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters) Sdk(com.intellij.openapi.projectRoots.Sdk) SystemInfo(com.intellij.openapi.util.SystemInfo) File(java.io.File) BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) Place(com.intellij.ui.navigation.Place) Pair(com.intellij.openapi.util.Pair) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable) Navigatable(com.intellij.pom.Navigatable) PathUtil(com.intellij.util.PathUtil) Trinity(com.intellij.openapi.util.Trinity) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) ArrayList(java.util.ArrayList) FlashRunConfiguration(com.intellij.lang.javascript.flex.run.FlashRunConfiguration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Module(com.intellij.openapi.module.Module) FlashRunnerParameters(com.intellij.lang.javascript.flex.run.FlashRunnerParameters)

Example 42 with FlexBuildConfiguration

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

the class ValidateFlashConfigurationsPrecompileTask method checkConfiguration.

public static void checkConfiguration(final Module module, final FlexBuildConfiguration bc, final boolean checkPackaging, final Consumer<FlashProjectStructureProblem> errorConsumer) {
    final Sdk sdk = bc.getSdk();
    if (sdk == null) {
        errorConsumer.consume(FlashProjectStructureProblem.createDependenciesProblem(ProjectStructureProblemType.Severity.ERROR, FlexBundle.message("sdk.not.set"), DependenciesConfigurable.Location.SDK));
    }
    if (sdk != null) {
        String version = sdk.getVersionString();
        if (FlexSdkUtils.isAirSdkWithoutFlex(sdk)) {
            version = version.substring(FlexCommonUtils.AIR_SDK_VERSION_PREFIX.length());
        }
        if (StringUtil.compareVersionNumbers(version, "0") < 0 || StringUtil.compareVersionNumbers(version, "100") > 0) {
            errorConsumer.consume(FlashProjectStructureProblem.createDependenciesProblem(ProjectStructureProblemType.Severity.ERROR, FlexBundle.message("sdk.version.unknown", sdk.getName()), DependenciesConfigurable.Location.SDK));
        }
        if (FlexSdkUtils.isAirSdkWithoutFlex(sdk) && !bc.isPureAs()) {
            errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("air.sdk.requires.pure.as", sdk.getName()), FlexBCConfigurable.Location.Nature));
        }
    }
    InfoFromConfigFile info = InfoFromConfigFile.DEFAULT;
    final String additionalConfigFilePath = bc.getCompilerOptions().getAdditionalConfigFilePath();
    if (!additionalConfigFilePath.isEmpty()) {
        final VirtualFile additionalConfigFile = LocalFileSystem.getInstance().findFileByPath(additionalConfigFilePath);
        if (additionalConfigFile == null || additionalConfigFile.isDirectory()) {
            errorConsumer.consume(FlashProjectStructureProblem.createCompilerOptionsProblem(ProjectStructureProblemType.Severity.ERROR, FlexBundle.message("additional.config.file.not.found", FileUtil.toSystemDependentName(additionalConfigFilePath)), CompilerOptionsConfigurable.Location.AdditionalConfigFile));
        }
        if (!bc.isTempBCForCompilation()) {
            info = FlexCompilerConfigFileUtil.getInfoFromConfigFile(additionalConfigFilePath);
        }
    }
    final BuildConfigurationNature nature = bc.getNature();
    if (!nature.isLib() && info.getMainClass(module) == null && !bc.isTempBCForCompilation()) {
        if (bc.getMainClass().isEmpty()) {
            errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("main.class.not.set"), FlexBCConfigurable.Location.MainClass));
        } else {
            if (FlexUtils.getPathToMainClassFile(bc.getMainClass(), module).isEmpty()) {
                errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("main.class.not.found", bc.getMainClass()), FlexBCConfigurable.Location.MainClass));
            }
        }
    }
    if (info.getOutputFileName() == null && info.getOutputFolderPath() == null) {
        if (FileUtil.getNameWithoutExtension(bc.getOutputFileName()).isEmpty()) {
            errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("output.file.name.not.set"), FlexBCConfigurable.Location.OutputFileName));
        } else {
            if (!nature.isLib() && !bc.getOutputFileName().toLowerCase().endsWith(".swf")) {
                errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("output.file.wrong.extension", "swf"), FlexBCConfigurable.Location.OutputFileName));
            }
            if (nature.isLib() && !bc.getOutputFileName().toLowerCase().endsWith(".swc")) {
                errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("output.file.wrong.extension", "swc"), FlexBCConfigurable.Location.OutputFileName));
            }
        }
        if (bc.getOutputFolder().isEmpty()) {
            if (BCUtils.isFlexUnitBC(bc)) {
                errorConsumer.consume(FlashProjectStructureProblem.FlexUnitOutputFolderProblem.INSTANCE);
            } else {
                errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("output.folder.not.set"), FlexBCConfigurable.Location.OutputFolder));
            }
        } else if (!FileUtil.isAbsolute(bc.getOutputFolder())) {
            if (BCUtils.isFlexUnitBC(bc)) {
                errorConsumer.consume(FlashProjectStructureProblem.FlexUnitOutputFolderProblem.INSTANCE);
            } else {
                errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("output.folder.not.absolute", FileUtil.toSystemDependentName(bc.getOutputFolder())), FlexBCConfigurable.Location.OutputFolder));
            }
        }
    }
    if (nature.isWebPlatform() && nature.isApp() && bc.isUseHtmlWrapper()) {
        if (bc.getWrapperTemplatePath().isEmpty()) {
            errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("html.template.folder.not.set"), FlexBCConfigurable.Location.HtmlTemplatePath));
        } else {
            final VirtualFile templateDir = LocalFileSystem.getInstance().findFileByPath(bc.getWrapperTemplatePath());
            if (templateDir == null || !templateDir.isDirectory()) {
                errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("html.template.folder.not.found", FileUtil.toSystemDependentName(bc.getWrapperTemplatePath())), FlexBCConfigurable.Location.HtmlTemplatePath));
            } else {
                final VirtualFile templateFile = templateDir.findChild(FlexCommonUtils.HTML_WRAPPER_TEMPLATE_FILE_NAME);
                if (templateFile == null) {
                    errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexCommonBundle.message("no.index.template.html.file", templateDir.getPresentableUrl()), FlexBCConfigurable.Location.HtmlTemplatePath));
                } else {
                    // Probably heavy calculation. Will be checked only when real html template handling is performed
                    /*
            try {
              if (!VfsUtilCore.loadText(templateFile).contains(FlexCompilationUtils.SWF_MACRO)) {
                errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(
                  FlexBundle.message("no.swf.macro.in.template", FileUtil.toSystemDependentName(templateFile.getPath())), "html.template"));
              }
            }
            catch (IOException e) {
              errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(
                FlexBundle.message("failed.to.load.template.file", FileUtil.toSystemDependentName(templateFile.getPath()), e.getMessage()),
                "html.template"));
            }
            */
                    final String templateFolderPath = templateDir.getPath();
                    boolean ok = true;
                    for (String url : ModuleRootManager.getInstance(module).getContentRootUrls()) {
                        if (ok) {
                            ok = checkWrapperFolderClash(bc, templateFolderPath, VfsUtilCore.urlToPath(url), "module content root", errorConsumer);
                        }
                    }
                    for (String url : ModuleRootManager.getInstance(module).getSourceRootUrls()) {
                        if (ok) {
                            ok = checkWrapperFolderClash(bc, templateFolderPath, VfsUtilCore.urlToPath(url), "source folder", errorConsumer);
                        }
                    }
                    final String outputFolderPath = StringUtil.notNullize(info.getOutputFolderPath(), bc.getOutputFolder());
                    if (ok && !outputFolderPath.isEmpty()) {
                        ok = checkWrapperFolderClash(bc, templateFolderPath, outputFolderPath, "output folder", errorConsumer);
                    }
                }
            }
        }
    }
    if (BCUtils.canHaveRLMsAndRuntimeStylesheets(bc)) {
        for (FlexBuildConfiguration.RLMInfo rlm : bc.getRLMs()) {
            if (rlm.MAIN_CLASS.isEmpty()) {
                errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("rlm.main.class.not.set"), FlexBCConfigurable.Location.RLMs));
            } else {
                if (FlexUtils.getPathToMainClassFile(rlm.MAIN_CLASS, module).isEmpty()) {
                    errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("rlm.main.class.not.found", rlm.MAIN_CLASS), FlexBCConfigurable.Location.RLMs));
                }
            }
            if (bc.getMainClass().equals(rlm.MAIN_CLASS)) {
                errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("rlm.main.class.equal.to.bc.main.class", rlm.MAIN_CLASS), FlexBCConfigurable.Location.RLMs));
            }
            if (bc.getOutputFileName().equals(rlm.OUTPUT_FILE)) {
                errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("rlm.output.equal.to.bc.output", rlm.OUTPUT_FILE), FlexBCConfigurable.Location.RLMs));
            }
            if (rlm.OUTPUT_FILE.isEmpty()) {
                errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("rlm.output.file.name.not.specified"), FlexBCConfigurable.Location.RLMs));
            } else {
                if (!rlm.OUTPUT_FILE.toLowerCase().endsWith(".swf")) {
                    errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("rlm.output.file.must.have.swf.extension"), FlexBCConfigurable.Location.RLMs));
                }
            }
        }
        for (String cssPath : bc.getCssFilesToCompile()) {
            if (!cssPath.toLowerCase().endsWith(".css")) {
                errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("not.a.css.runtime.stylesheet", FileUtil.toSystemDependentName(cssPath)), FlexBCConfigurable.Location.RuntimeStyleSheets));
            } else if (LocalFileSystem.getInstance().findFileByPath(cssPath) == null) {
                errorConsumer.consume(FlashProjectStructureProblem.createGeneralOptionProblem(ProjectStructureProblemType.Severity.ERROR, bc.getName(), FlexBundle.message("css.not.found", FileUtil.toSystemDependentName(cssPath)), FlexBCConfigurable.Location.RuntimeStyleSheets));
            }
        }
    }
    if (nature.isLib()) {
        for (String path : bc.getCompilerOptions().getFilesToIncludeInSWC()) {
            if (LocalFileSystem.getInstance().findFileByPath(path) == null) {
                errorConsumer.consume(FlashProjectStructureProblem.createCompilerOptionsProblem(ProjectStructureProblemType.Severity.ERROR, FlexBundle.message("file.to.include.in.swc.not.found", FileUtil.toSystemDependentName(path)), CompilerOptionsConfigurable.Location.FilesToIncludeInSwc));
            }
        }
    }
    if (checkPackaging) {
        checkPackagingOptions(module, bc, errorConsumer);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) BuildConfigurationNature(com.intellij.flex.model.bc.BuildConfigurationNature) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Sdk(com.intellij.openapi.projectRoots.Sdk)

Example 43 with FlexBuildConfiguration

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

the class ValidateFlashConfigurationsPrecompileTask method reportProblems.

private static void reportProblems(final CompileContext context, final Collection<Trinity<Module, FlexBuildConfiguration, FlashProjectStructureProblem>> problems) {
    for (Trinity<Module, FlexBuildConfiguration, FlashProjectStructureProblem> trinity : problems) {
        final Module module = trinity.getFirst();
        final FlexBuildConfiguration bc = trinity.getSecond();
        final FlashProjectStructureProblem problem = trinity.getThird();
        final String message = problem instanceof FlashProjectStructureProblem.FlexUnitOutputFolderProblem ? problem.errorMessage : FlexBundle.message("bc.0.module.1.problem.2", bc.getName(), module.getName(), problem.errorMessage);
        final CompilerMessageCategory severity = problem.severity == ProjectStructureProblemType.Severity.ERROR ? CompilerMessageCategory.ERROR : CompilerMessageCategory.WARNING;
        context.addMessage(severity, message, null, -1, -1, new BCProblemNavigatable(module, bc.getName(), problem));
    }
}
Also used : FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Module(com.intellij.openapi.module.Module)

Example 44 with FlexBuildConfiguration

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

the class FlashProjectStructureErrorsDialog method openProjectStructure.

private void openProjectStructure() {
    final TreePath selectionPath = myTree.getSelectionPath();
    DefaultMutableTreeNode node = selectionPath == null ? null : (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
    Object userObject = node == null ? null : node.getUserObject();
    if (userObject == null)
        return;
    final Ref<Module> moduleRef = new Ref<>();
    final Ref<FlexBuildConfiguration> bcRef = new Ref<>();
    final Ref<FlashProjectStructureProblem> problemRef = new Ref<>();
    if (userObject instanceof FlashProjectStructureProblem) {
        problemRef.set((FlashProjectStructureProblem) userObject);
        node = (DefaultMutableTreeNode) node.getParent();
        userObject = node.getUserObject();
    }
    if (userObject instanceof FlexBuildConfiguration) {
        bcRef.set((FlexBuildConfiguration) userObject);
        node = (DefaultMutableTreeNode) node.getParent();
        userObject = node.getUserObject();
    }
    if (userObject instanceof Module) {
        moduleRef.set((Module) userObject);
    }
    close(CANCEL_EXIT_CODE);
    final ProjectStructureConfigurable configurable = ProjectStructureConfigurable.getInstance(myProject);
    ShowSettingsUtil.getInstance().editConfigurable(myProject, configurable, () -> {
        final Place place;
        if (problemRef.get() instanceof FlashProjectStructureProblem.FlexUnitOutputFolderProblem) {
            place = new Place().putPath(ProjectStructureConfigurable.CATEGORY, configurable.getProjectConfig());
        } else if (moduleRef.isNull()) {
            place = new Place().putPath(ProjectStructureConfigurable.CATEGORY, configurable.getModulesConfig());
        } else if (bcRef.isNull()) {
            place = new Place().putPath(ProjectStructureConfigurable.CATEGORY, configurable.getModulesConfig()).putPath(MasterDetailsComponent.TREE_OBJECT, moduleRef.get());
        } else {
            place = FlexBuildConfigurationsExtension.getInstance().getConfigurator().getPlaceFor(moduleRef.get(), bcRef.get().getName());
            if (!problemRef.isNull()) {
                place.putPath(CompositeConfigurable.TAB_NAME, problemRef.get().tabName);
                place.putPath(FlexBCConfigurable.LOCATION_ON_TAB, problemRef.get().locationOnTab);
            }
        }
        configurable.navigateTo(place, true);
    });
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) ProjectStructureConfigurable(com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable) Ref(com.intellij.openapi.util.Ref) TreePath(javax.swing.tree.TreePath) Module(com.intellij.openapi.module.Module) Place(com.intellij.ui.navigation.Place)

Example 45 with FlexBuildConfiguration

use of com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration 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)

Aggregations

FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)52 Module (com.intellij.openapi.module.Module)30 Sdk (com.intellij.openapi.projectRoots.Sdk)9 Pair (com.intellij.openapi.util.Pair)7 ArrayList (java.util.ArrayList)7 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)6 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)5 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)5 FlexBuildConfigurationManager (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfigurationManager)5 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)4 Project (com.intellij.openapi.project.Project)4 FlexModuleType (com.intellij.lang.javascript.flex.FlexModuleType)3 FlexUnitRunConfiguration (com.intellij.lang.javascript.flex.flexunit.FlexUnitRunConfiguration)3 ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)3 FlashRunConfiguration (com.intellij.lang.javascript.flex.run.FlashRunConfiguration)3 FlashRunnerParameters (com.intellij.lang.javascript.flex.run.FlashRunnerParameters)3 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 ProjectStructureConfigurable (com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable)3 CheckedTreeNode (com.intellij.ui.CheckedTreeNode)3 Place (com.intellij.ui.navigation.Place)3