Search in sources :

Example 26 with FlexBuildConfiguration

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

the class BCBasedRunnerParameters method checkAndGetModuleAndBC.

public Pair<Module, FlexBuildConfiguration> checkAndGetModuleAndBC(final Project project) throws RuntimeConfigurationError {
    if (myModuleName.isEmpty() || myBCName.isEmpty()) {
        throw new RuntimeConfigurationError(FlexBundle.message("bc.not.specified"));
    }
    final Module module = ModuleManager.getInstance(project).findModuleByName(myModuleName);
    if (module == null || !(ModuleType.get(module) instanceof FlexModuleType)) {
        throw new RuntimeConfigurationError(FlexBundle.message("bc.not.specified"));
    }
    final FlexBuildConfiguration bc = FlexBuildConfigurationManager.getInstance(module).findConfigurationByName(myBCName);
    if (bc == null) {
        throw new RuntimeConfigurationError(FlexBundle.message("module.does.not.contain.bc", myModuleName, myBCName));
    }
    final Sdk sdk = bc.getSdk();
    if (sdk == null) {
        throw new RuntimeConfigurationError(FlexCommonBundle.message("sdk.not.set.for.bc.0.of.module.1", bc.getName(), module.getName()));
    }
    return Pair.create(module, bc);
}
Also used : FlexModuleType(com.intellij.lang.javascript.flex.FlexModuleType) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Example 27 with FlexBuildConfiguration

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

the class AdlUtil method runDebugger.

// http://kb2.adobe.com/cps/407/kb407625.html
public static void runDebugger(final Module module, final Runnable postTask) throws ExecutionException {
    final Project project = module.getProject();
    final RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createConfiguration("FlashUIDesigner", RemoteFlashRunConfigurationType.getFactory());
    final RemoteFlashRunConfiguration configuration = (RemoteFlashRunConfiguration) settings.getConfiguration();
    RunManagerEx.disableTasks(project, settings.getConfiguration(), CompileStepBeforeRun.ID, CompileStepBeforeRunNoErrorCheck.ID);
    final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
    ProgramRunner.Callback callback = new ProgramRunner.Callback() {

        @Override
        public void processStarted(final RunContentDescriptor descriptor) {
            final ProcessHandler processHandler = descriptor.getProcessHandler();
            assert processHandler != null;
            DesignerApplication application = DesignerApplicationManager.getApplication();
            if (application != null) {
                Disposer.register(application, new Disposable() {

                    @Override
                    public void dispose() {
                        if (!project.isDisposed()) {
                            ApplicationManager.getApplication().invokeLater(() -> ExecutionManager.getInstance(project).getContentManager().removeRunContent(executor, descriptor));
                        }
                        processHandler.destroyProcess();
                    }
                });
                postTask.run();
            }
        }
    };
    FlexBuildConfiguration buildConfiguration = FlexBuildConfigurationManager.getInstance(module).getActiveConfiguration();
    configuration.getRunnerParameters().setModuleName(module.getName());
    configuration.getRunnerParameters().setBCName(buildConfiguration.getName());
    final FlexRunner runner = new FlexRunner(callback, buildConfiguration);
    runner.execute(new ExecutionEnvironment(executor, runner, settings, project));
}
Also used : Disposable(com.intellij.openapi.Disposable) FlexRunner(com.intellij.flex.uiDesigner.debug.FlexRunner) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Project(com.intellij.openapi.project.Project) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) RemoteFlashRunConfiguration(com.intellij.lang.javascript.flex.run.RemoteFlashRunConfiguration) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) ProgramRunner(com.intellij.execution.runners.ProgramRunner)

Example 28 with FlexBuildConfiguration

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

the class FlexUnitRunnerParameters method doCheck.

private void doCheck(final Project project, final Pair<Module, FlexBuildConfiguration> moduleAndBC) throws RuntimeConfigurationError {
    if (DumbService.getInstance(project).isDumb())
        return;
    final FlexBuildConfiguration bc = moduleAndBC.second;
    final Sdk sdk = bc.getSdk();
    if (sdk == null) {
        throw new RuntimeConfigurationError(FlexCommonBundle.message("sdk.not.set.for.bc.0.of.module.1", bc.getName(), moduleAndBC.first.getName()));
    }
    switch(bc.getTargetPlatform()) {
        case Web:
            break;
        case Desktop:
            FlashRunnerParameters.checkAdlAndAirRuntime(sdk);
            if (bc.getOutputType() == OutputType.Application) {
                FlashRunnerParameters.checkCustomDescriptor(bc.getAirDesktopPackagingOptions(), getBCName(), getModuleName());
            }
            break;
        case Mobile:
            FlashRunnerParameters.checkAdlAndAirRuntime(sdk);
            switch(myAppDescriptorForEmulator) {
                case Android:
                    if (bc.getOutputType() == OutputType.Application) {
                        FlashRunnerParameters.checkCustomDescriptor(bc.getAndroidPackagingOptions(), getBCName(), getModuleName());
                    }
                    break;
                case IOS:
                    if (bc.getOutputType() == OutputType.Application) {
                        FlashRunnerParameters.checkCustomDescriptor(bc.getIosPackagingOptions(), getBCName(), getModuleName());
                    }
                    break;
            }
            break;
    }
    final FlexUnitSupport support = FlexUnitSupport.getSupport(bc, moduleAndBC.first);
    if (support == null) {
        throw new RuntimeConfigurationError(FlexBundle.message("flexunit.not.found.for.bc", bc.getName()));
    }
    if (!support.flexUnit4Present && bc.isPureAs()) {
        throw new RuntimeConfigurationError(FlexBundle.message("cant.execute.flexunit1.for.pure.as.bc"));
    }
    final GlobalSearchScope searchScope = FlexUtils.getModuleWithDependenciesAndLibrariesScope(moduleAndBC.first, bc, true);
    switch(getScope()) {
        case Class:
            getClassToTest(getClassName(), searchScope, support, true);
            break;
        case Method:
            final JSClass classToTest = getClassToTest(getClassName(), searchScope, support, false);
            if (StringUtil.isEmpty(getMethodName())) {
                throw new RuntimeConfigurationError(FlexBundle.message("no.test.method.specified"));
            }
            final JSFunction methodToTest = classToTest.findFunctionByNameAndKind(getMethodName(), JSFunction.FunctionKind.SIMPLE);
            if (methodToTest == null || !support.isTestMethod(methodToTest)) {
                throw new RuntimeConfigurationError(FlexBundle.message("method.not.valid", getMethodName()));
            }
            break;
        case Package:
            if (!JSUtils.packageExists(getPackageName(), searchScope)) {
                throw new RuntimeConfigurationError(FlexBundle.message("package.not.valid", getPackageName()));
            }
            break;
        default:
            assert false : "Unknown scope: " + getScope();
    }
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) JSFunction(com.intellij.lang.javascript.psi.JSFunction) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) ModifiableFlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration) Sdk(com.intellij.openapi.projectRoots.Sdk) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass)

Example 29 with FlexBuildConfiguration

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

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

the class FlexUnitRunConfigurationForm method createUIComponents.

private void createUIComponents() {
    myBCCombo = new BCCombo(myProject);
    myWhatToTestForm = new WhatToTestForm(myProject, () -> {
        final Module module = myBCCombo.getModule();
        if (module != null)
            return module;
        throw new RuntimeConfigurationError(FlexBundle.message("bc.not.specified"));
    }, () -> {
        final FlexBuildConfiguration bc = myBCCombo.getBC();
        if (bc == null)
            throw new RuntimeConfigurationError(FlexBundle.message("bc.not.specified"));
        final FlexUnitSupport support = FlexUnitSupport.getSupport(bc, myBCCombo.getModule());
        if (support != null)
            return support;
        throw new RuntimeConfigurationError(FlexBundle.message("flexunit.not.found.for.bc", bc.getName()));
    });
}
Also used : FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) Module(com.intellij.openapi.module.Module) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

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