Exemplo n.º 1
0
        public SyntaxTree BuildProject(Project project, bool prod = false)
        {
            Console.Out.WriteLine("Analyzing source code");
            ProjectAnalyzer analyzer = new ProjectAnalyzer(project);

            analyzer.analyze();

            SyntaxTree result = null;

            if (analyzer.MainTree != null)
            {
                Console.Out.WriteLine("Renaming main program class");
                SyntaxTree renamedTree = this.renameProgramClass(analyzer.MainTree);
                if (renamedTree != null)
                {
                    result = renamedTree;
                    if (analyzer.Dependencies != null && analyzer.Dependencies.Count() > 0)
                    {
                        Console.Out.WriteLine("Merging dependencies");
                        SyntaxTree lib = this.mergeClasses(analyzer.Dependencies);
                        if (lib != null)
                        {
                            Console.Out.WriteLine("Injecting dependencies");
                            result = this.injectClasses(result, lib);
                        }
                    }
                }
            }

            if (result != null)
            {
                if (prod)
                {
                    result = this.getProductionCode(result);
                }
                else
                {
                    result = this.getDebugCode(result);
                }
            }

            return(result);
        }