compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNode.java [194:358]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        workspace = new Workspace();
        workspace.setASDocDelegate(new RoyaleASDocDelegate());
        project = new RoyaleJSProject(workspace, backend);
        problems = new ProblemQuery(); // this gets replaced in configure().  Do we need it here?
        asFileHandler = backend.getSourceFileHandlerInstance();
    }

    @Override
    public int mainNoExit(final String[] args, List<ICompilerProblem> problems,
            Boolean printProblems)
    {
        int exitCode = -1;
        try
        {
            exitCode = _mainNoExit(ArgumentUtil.fixArgs(args), problems);
        }
        catch (Exception e)
        {
            System.err.println(e.toString());
        }
        finally
        {
            if (problems != null && !problems.isEmpty())
            {
                if (printProblems)
                {
                    final WorkspaceProblemFormatter formatter = new WorkspaceProblemFormatter(
                            workspace);
                    final ProblemPrinter printer = new ProblemPrinter(formatter);
                    printer.printProblems(problems);
                }
            }
        }
        return exitCode;
    }

    /**
     * Entry point that doesn't call <code>System.exit()</code>. This is for
     * unit testing.
     * 
     * @param args command line arguments
     * @return exit code
     */
    private int _mainNoExit(final String[] args,
            List<ICompilerProblem> outProblems)
    {
        ExitCode exitCode = ExitCode.SUCCESS;
        try
        {
            final boolean continueCompilation = configure(args);

/*            if (outProblems != null && !config.isVerbose())
                JSSharedData.STDOUT = JSSharedData.STDERR = null;*/

            if (continueCompilation)
            {
                project.setProblems(problems.getProblems());
               	compile();
                if (problems.hasFilteredProblems())
                {
                    if (problems.hasErrors())
                        exitCode = ExitCode.FAILED_WITH_ERRORS;
                    // no exit code for warnings because anything except 0 is
                    // detected as a failure by various build tools
                }
            }
            else if (problems.hasFilteredProblems())
            {
                exitCode = ExitCode.FAILED_WITH_CONFIG_PROBLEMS;
            }
            else
            {
                exitCode = ExitCode.PRINT_HELP;
            }
        }
        catch (Exception e)
        {
            if (outProblems == null) {
                System.err.println(e.getMessage());
            } else
            {
                final ICompilerProblem unexpectedExceptionProblem = new UnexpectedExceptionProblem(
                        e);
                problems.add(unexpectedExceptionProblem);
            }
            exitCode = ExitCode.FAILED_WITH_EXCEPTIONS;
        }
        finally
        {
            if (!config.getWatch() || !ExitCode.SUCCESS.equals(exitCode))
            {
                waitAndClose();
            }

            if (outProblems != null && problems.hasFilteredProblems())
            {
                for (ICompilerProblem problem : problems.getFilteredProblems())
                {
                    outProblems.add(problem);
                }
            }
        }
        if (config.getWatch() && ExitCode.SUCCESS.equals(exitCode))
        {
            setupWatcher();
            exitCode = ExitCode.WATCHING;
        }
        return exitCode.getCode();
    }

    protected void setupWatcher()
    {
        if (!config.getWatch())
        {
            return;
        }
        IWatchWriter writer = new IWatchWriter()
        {
            private long startTime;

            public void rebuild(Collection<ICompilationUnit> units, Collection<ICompilerProblem> problems) throws InterruptedException, IOException
            {
                startTime = System.nanoTime();
                workspace.startBuilding();
                try
                {
                    target = project.getBackend().createTarget(project,
                            getTargetSettings(), null);
                    ((JSTarget) target).build(mainCU, problems);
                    for (ICompilationUnit unit : units)
                    {
                        // call waitForBuildFinish() to ensure that binding data
                        // doesn't get lost when a new definition is created
                        unit.waitForBuildFinish(problems, null);
                    }
                }
                finally
                {
                    workspace.doneBuilding();
                }
            }
    
            public void write(Collection<ICompilationUnit> units) throws InterruptedException, IOException
            {
                workspace.startBuilding();
                try
                {
                    File outputFolder = jsPublisher.getOutputFolder();
                    for (ICompilationUnit unit : units)
                    {
                        writeCompilationUnit(unit, outputFolder);
                    }

                    // ensures that the goog.addDependency() calls are updated
                    jsPublisher.publish(problems);

                    long endTime = System.nanoTime();
                    System.out.println((endTime - startTime) / 1e9 + " seconds");
                }
                finally
                {
                    workspace.doneBuilding();
                }
            }
        };
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyaleCordova.java [196:360]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        workspace = new Workspace();
        workspace.setASDocDelegate(new RoyaleASDocDelegate());
        project = new RoyaleJSProject(workspace, backend);
        problems = new ProblemQuery(); // this gets replaced in configure().  Do we need it here?
        asFileHandler = backend.getSourceFileHandlerInstance();
    }

    @Override
    public int mainNoExit(final String[] args, List<ICompilerProblem> problems,
            Boolean printProblems)
    {
        int exitCode = -1;
        try
        {
            exitCode = _mainNoExit(ArgumentUtil.fixArgs(args), problems);
        }
        catch (Exception e)
        {
            System.err.println(e.toString());
        }
        finally
        {
            if (problems != null && !problems.isEmpty())
            {
                if (printProblems)
                {
                    final WorkspaceProblemFormatter formatter = new WorkspaceProblemFormatter(
                            workspace);
                    final ProblemPrinter printer = new ProblemPrinter(formatter);
                    printer.printProblems(problems);
                }
            }
        }
        return exitCode;
    }

    /**
     * Entry point that doesn't call <code>System.exit()</code>. This is for
     * unit testing.
     * 
     * @param args command line arguments
     * @return exit code
     */
    private int _mainNoExit(final String[] args,
            List<ICompilerProblem> outProblems)
    {
        ExitCode exitCode = ExitCode.SUCCESS;
        try
        {
            final boolean continueCompilation = configure(args);

/*            if (outProblems != null && !config.isVerbose())
                JSSharedData.STDOUT = JSSharedData.STDERR = null;*/

            if (continueCompilation)
            {
                project.setProblems(problems.getProblems());
               	compile();
                if (problems.hasFilteredProblems())
                {
                    if (problems.hasErrors())
                        exitCode = ExitCode.FAILED_WITH_ERRORS;
                    // no exit code for warnings because anything except 0 is
                    // detected as a failure by various build tools
                }
            }
            else if (problems.hasFilteredProblems())
            {
                exitCode = ExitCode.FAILED_WITH_CONFIG_PROBLEMS;
            }
            else
            {
                exitCode = ExitCode.PRINT_HELP;
            }
        }
        catch (Exception e)
        {
            if (outProblems == null) {
                System.err.println(e.getMessage());
            } else
            {
                final ICompilerProblem unexpectedExceptionProblem = new UnexpectedExceptionProblem(
                        e);
                problems.add(unexpectedExceptionProblem);
            }
            exitCode = ExitCode.FAILED_WITH_EXCEPTIONS;
        }
        finally
        {
            if (!config.getWatch() || !ExitCode.SUCCESS.equals(exitCode))
            {
                waitAndClose();
            }

            if (outProblems != null && problems.hasFilteredProblems())
            {
                for (ICompilerProblem problem : problems.getFilteredProblems())
                {
                    outProblems.add(problem);
                }
            }
        }
        if (config.getWatch() && ExitCode.SUCCESS.equals(exitCode))
        {
            setupWatcher();
            exitCode = ExitCode.WATCHING;
        }
        return exitCode.getCode();
    }

    protected void setupWatcher()
    {
        if (!config.getWatch())
        {
            return;
        }
        IWatchWriter writer = new IWatchWriter()
        {
            private long startTime;

            public void rebuild(Collection<ICompilationUnit> units, Collection<ICompilerProblem> problems) throws InterruptedException, IOException
            {
                startTime = System.nanoTime();
                workspace.startBuilding();
                try
                {
                    target = project.getBackend().createTarget(project,
                            getTargetSettings(), null);
                    ((JSTarget) target).build(mainCU, problems);
                    for (ICompilationUnit unit : units)
                    {
                        // call waitForBuildFinish() to ensure that binding data
                        // doesn't get lost when a new definition is created
                        unit.waitForBuildFinish(problems, null);
                    }
                }
                finally
                {
                    workspace.doneBuilding();
                }
            }
    
            public void write(Collection<ICompilationUnit> units) throws InterruptedException, IOException
            {
                workspace.startBuilding();
                try
                {
                    File outputFolder = jsPublisher.getOutputFolder();
                    for (ICompilationUnit unit : units)
                    {
                        writeCompilationUnit(unit, outputFolder);
                    }

                    // ensures that the goog.addDependency() calls are updated
                    jsPublisher.publish(problems);

                    long endTime = System.nanoTime();
                    System.out.println((endTime - startTime) / 1e9 + " seconds");
                }
                finally
                {
                    workspace.doneBuilding();
                }
            }
        };
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



