Exemplo n.º 1
0
 private static void ExploreNext()
 {
     if (index >= config.Classpath.Length)
     {
         ForceMXNamespace();
         AddBuiltInTags();
         ExpandInheritance();
         BuildGroups();
         //AddBuiltInEvents(); // FD intrinsics now contain required information
         GenerateDeclarations();
         output.Close();
         log.Close();
         Console.WriteLine("Finished. Press Enter to continue.");
     }
     else
     {
         string path = config.Classpath[index++];
         Log("> " + path);
         pathModel = new PathModel(path, context);
         explorer  = new PathExplorer(context, pathModel);
         explorer.Run();
         explorer.OnExplorationDone += new PathExplorer.ExplorationDoneHandler(explorer_OnExplorationDone);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Classpathes & classes cache initialisation
        /// </summary>
        public override void BuildClassPath()
        {
            ReleaseClasspath();
            started = true;
            if (hxsettings == null)
            {
                throw new Exception("BuildClassPath() must be overridden");
            }

            // external version definition
            // expected from project manager: "9;path;path..."
            flashVersion = hxsettings.DefaultFlashVersion;
            string exPath = externalClassPath ?? "";

            if (exPath.Length > 0)
            {
                try
                {
                    int p = exPath.IndexOf(';');
                    flashVersion = Convert.ToInt16(exPath.Substring(0, p));
                    exPath       = exPath.Substring(p + 1).Trim();
                }
                catch { }
            }

            // NOTE: version > 10 for non-Flash platforms
            string lang = null;

            features.Directives = new List <string>();
            if (IsJavaScriptTarget)
            {
                lang = "js";
                features.Directives.Add(lang);
            }
            else if (IsNekoTarget)
            {
                lang = "neko";
                features.Directives.Add(lang);
            }
            else if (IsPhpTarget)
            {
                lang = "php";
                features.Directives.Add(lang);
            }
            else if (IsCppTarget)
            {
                lang = "cpp";
                features.Directives.Add(lang);
            }
            else
            {
                features.Directives.Add("flash");
                features.Directives.Add("flash" + flashVersion);
                lang = (flashVersion >= 9) ? "flash9" : "flash";
            }
            features.Directives.Add("true");

            //
            // Class pathes
            //
            classPath = new List <PathModel>();
            // haXe std
            if (hxsettings.HaXePath != null)
            {
                string haxeCP = Path.Combine(hxsettings.HaXePath, "std");
                if (Directory.Exists(haxeCP))
                {
                    PathModel std = PathModel.GetModel(haxeCP, this);
                    if (!std.WasExplored && !Settings.LazyClasspathExploration)
                    {
                        PathExplorer stdExplorer = new PathExplorer(this, std);
                        stdExplorer.HideDirectories(new string[] { "flash", "flash9", "js", "neko", "php", "cpp" });
                        stdExplorer.OnExplorationDone += new PathExplorer.ExplorationDoneHandler(RefreshContextCache);
                        stdExplorer.Run();
                    }
                    AddPath(std);

                    PathModel specific = PathModel.GetModel(Path.Combine(haxeCP, lang), this);
                    if (!specific.WasExplored && !Settings.LazyClasspathExploration)
                    {
                        PathExplorer speExplorer = new PathExplorer(this, specific);
                        speExplorer.OnExplorationDone += new PathExplorer.ExplorationDoneHandler(RefreshContextCache);
                        speExplorer.Run();
                    }
                    AddPath(specific);
                }
            }
            HaxeProject proj = PluginBase.CurrentProject as HaxeProject;

            // swf-libs
            if (IsFlashTarget && flashVersion >= 9 && proj != null)
            {
                foreach (LibraryAsset asset in proj.LibraryAssets)
                {
                    if (asset.IsSwf)
                    {
                        string path = proj.GetAbsolutePath(asset.Path);
                        if (File.Exists(path))
                        {
                            AddPath(path);
                        }
                    }
                }
                foreach (string p in proj.CompilerOptions.Additional)
                {
                    if (p.IndexOf("-swf-lib ") == 0)
                    {
                        string path = proj.GetAbsolutePath(p.Substring(9));
                        if (File.Exists(path))
                        {
                            AddPath(path);
                        }
                    }
                }
            }

            // add haxe libraries
            if (proj != null)
            {
                foreach (string param in proj.BuildHXML(new string[0], "", false))
                {
                    if (param.IndexOf("-lib ") == 0)
                    {
                        AddPath(LookupLibrary(param.Substring(5)));
                    }
                }
            }


            // add external pathes
            List <PathModel> initCP = classPath;

            classPath = new List <PathModel>();
            string[] cpathes;
            if (exPath.Length > 0)
            {
                cpathes = exPath.Split(';');
                foreach (string cpath in cpathes)
                {
                    AddPath(cpath.Trim());
                }
            }
            // add user pathes from settings
            if (settings.UserClasspath != null && settings.UserClasspath.Length > 0)
            {
                foreach (string cpath in settings.UserClasspath)
                {
                    AddPath(cpath.Trim());
                }
            }
            // add initial pathes
            foreach (PathModel mpath in initCP)
            {
                AddPath(mpath);
            }

            // parse top-level elements
            InitTopLevelElements();
            if (cFile != null)
            {
                UpdateTopLevelElements();
            }

            // add current temporaty path
            if (temporaryPath != null)
            {
                string tempPath = temporaryPath;
                temporaryPath = null;
                SetTemporaryPath(tempPath);
            }
            FinalizeClasspath();
        }