Пример #1
0
        private void AddLib(ContextSetupInfos contextSetup, string loomlib)
        {
            AddPath(loomlib);

            // TODO: it would be nice if Reference node could work with virtual models
            //if (contextSetup.AdditionalPaths == null) contextSetup.AdditionalPaths = new List<string>();
            //contextSetup.AdditionalPaths.Add(loomlib); // References
        }
Пример #2
0
        /**
        * Handles the incoming events
        */
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            try
            {
                // ignore all events when leaving
                if (PluginBase.MainForm.ClosingEntirely) return;
                // current active document
                ITabbedDocument doc = PluginBase.MainForm.CurrentDocument;

                // application start
                if (!started && e.Type == EventType.UIStarted)
                {
                    started = true;
                    PathExplorer.OnUIStarted();
                    // associate context to initial document
                    e = new NotifyEvent(EventType.SyntaxChange);
                    this.pluginUI.UpdateAfterTheme();
                }

                // editor ready?
                if (doc == null) return;
                ScintillaControl sci = doc.IsEditable ? doc.SciControl : null;

                //
                //  Events always handled
                //
                bool isValid;
                DataEvent de;
                switch (e.Type)
                {
                    // caret position in editor
                    case EventType.UIRefresh:
                        if (!doc.IsEditable) return;
                        timerPosition.Enabled = false;
                        timerPosition.Enabled = true;
                        return;

                    // key combinations
                    case EventType.Keys:
                        Keys key = (e as KeyEvent).Value;
                        if (ModelsExplorer.HasFocus)
                        {
                            e.Handled = ModelsExplorer.Instance.OnShortcut(key);
                            return;
                        }
                        if (!doc.IsEditable) return;
                        e.Handled = ASComplete.OnShortcut(key, sci);
                        return;

                    // user-customized shortcuts
                    case EventType.Shortcut:
                        de = e as DataEvent;
                        if (de.Action == "Completion.ShowHelp")
                        {
                            ASComplete.HelpKeys = (Keys)de.Data;
                            de.Handled = true;
                        }
                        return;

                    //
                    // File management
                    //
                    case EventType.FileSave:
                        if (!doc.IsEditable) return;
                        ASContext.Context.CheckModel(false);
                        // toolbar
                        isValid = ASContext.Context.IsFileValid;
                        if (isValid && !PluginBase.MainForm.SavingMultiple)
                        {
                            if (ASContext.Context.Settings.CheckSyntaxOnSave) CheckSyntax(null, null);
                            ASContext.Context.RemoveClassCompilerCache();
                        }
                        return;

                    case EventType.SyntaxDetect:
                        // detect Actionscript language version
                        if (!doc.IsEditable) return;
                        if (doc.FileName.ToLower().EndsWithOrdinal(".as"))
                        {
                            settingObject.LastASVersion = DetectActionscriptVersion(doc);
                            (e as TextEvent).Value = settingObject.LastASVersion;
                            e.Handled = true;
                        }
                        break;

                    case EventType.ApplySettings:
                    case EventType.SyntaxChange:
                    case EventType.FileSwitch:
                        if (!doc.IsEditable)
                        {
                            ASContext.SetCurrentFile(null, true);
                            ContextChanged();
                            return;
                        }
                        currentDoc = doc.FileName;
                        currentPos = sci.CurrentPos;
                        // check file
                        bool ignoreFile = !doc.IsEditable;
                        ASContext.SetCurrentFile(doc, ignoreFile);
                        // UI
                        ContextChanged();
                        return;

                    case EventType.Completion:
                        if (ASContext.Context.IsFileValid) e.Handled = true;
                        return;

                    // some commands work all the time
                    case EventType.Command:
                        de = e as DataEvent;
                        string command = de.Action ?? "";

                        if (command.StartsWithOrdinal("ASCompletion."))
                        {
                            string cmdData = de.Data as string;

                            // add a custom classpath
                            if (command == "ASCompletion.ClassPath")
                            {
                                Hashtable info = de.Data as Hashtable;
                                if (info != null)
                                {
                                    ContextSetupInfos setup = new ContextSetupInfos();
                                    setup.Platform = (string)info["platform"];
                                    setup.Lang = (string)info["lang"];
                                    setup.Version = (string)info["version"];
                                    setup.TargetBuild = (string)info["targetBuild"];
                                    setup.Classpath = (string[])info["classpath"];
                                    setup.HiddenPaths = (string[])info["hidden"];
                                    ASContext.SetLanguageClassPath(setup);
                                    if (setup.AdditionalPaths != null) // report custom classpath
                                        info["additional"] = setup.AdditionalPaths.ToArray();
                                }
                                e.Handled = true;
                            }

                            // send a UserClasspath
                            else if (command == "ASCompletion.GetUserClasspath")
                            {
                                Hashtable info = de.Data as Hashtable;
                                if (info != null && info.ContainsKey("language"))
                                {
                                    IASContext context = ASContext.GetLanguageContext(info["language"] as string);
                                    if (context != null && context.Settings != null 
                                        && context.Settings.UserClasspath != null)
                                        info["cp"] = new List<string>(context.Settings.UserClasspath);
                                }
                                e.Handled = true;
                            }
                            // update a UserClasspath
                            else if (command == "ASCompletion.SetUserClasspath")
                            {
                                Hashtable info = de.Data as Hashtable;
                                if (info != null && info.ContainsKey("language") && info.ContainsKey("cp"))
                                {
                                    IASContext context = ASContext.GetLanguageContext(info["language"] as string);
                                    List<string> cp = info["cp"] as List<string>;
                                    if (cp != null && context != null && context.Settings != null)
                                    {
                                        string[] pathes = new string[cp.Count];
                                        cp.CopyTo(pathes);
                                        context.Settings.UserClasspath = pathes;
                                    }
                                }
                                e.Handled = true;
                            }
                            // send the language's default compiler path
                            else if (command == "ASCompletion.GetCompilerPath")
                            {
                                Hashtable info = de.Data as Hashtable;
                                if (info != null && info.ContainsKey("language"))
                                {
                                    IASContext context = ASContext.GetLanguageContext(info["language"] as string);
                                    if (context != null)
                                        info["compiler"] = context.GetCompilerPath();
                                }
                                e.Handled = true;
                            }

                            // show a language's compiler settings
                            else if (command == "ASCompletion.ShowSettings")
                            {
                                e.Handled = true;
                                IASContext context = ASContext.GetLanguageContext(cmdData);
                                if (context == null) return;
                                string filter = "SDK";
                                string name = "";
                                switch (cmdData.ToUpper())
                                {
                                    case "AS2": name = "AS2Context"; break;
                                    case "AS3": name = "AS3Context"; break;
                                    default: 
                                        name = cmdData.Substring(0, 1).ToUpper() + cmdData.Substring(1) + "Context";
                                        break;
                                }
                                PluginBase.MainForm.ShowSettingsDialog(name, filter);
                            }

                            // Open types explorer dialog
                            else if (command == "ASCompletion.TypesExplorer")
                            {
                                TypesExplorer(null, null);
                            }

                            // call the Flash IDE
                            else if (command == "ASCompletion.CallFlashIDE")
                            {
                                if (flashErrorsWatcher == null) flashErrorsWatcher = new FlashErrorsWatcher();
                                e.Handled = CallFlashIDE.Run(settingObject.PathToFlashIDE, cmdData);
                            }

                            // create Flash 8+ trust file
                            else if (command == "ASCompletion.CreateTrustFile")
                            {
                                if (cmdData != null)
                                {
                                    string[] args = cmdData.Split(';');
                                    if (args.Length == 2)
                                        e.Handled = CreateTrustFile.Run(args[0], args[1]);
                                }
                            }
                            else if (command == "ASCompletion.GetClassPath")
                            {
                                if (cmdData != null)
                                {
                                    string[] args = cmdData.Split(';');
                                    if (args.Length == 1)
                                    {
                                        FileModel model = ASContext.Context.GetFileModel(args[0]);
                                        ClassModel aClass = model.GetPublicClass();
                                        if (!aClass.IsVoid())
                                        {
                                            Clipboard.SetText(aClass.QualifiedName);
                                            e.Handled = true;
                                        }
                                    }
                                }
                            }
                            else if (command == "ProjectManager.FileActions.DisableWatchers")
                            {
                                foreach (PathModel cp in ASContext.Context.Classpath)
                                    cp.DisableWatcher();
                            }
                            else if (command == "ProjectManager.FileActions.EnableWatchers")
                            {
                                // classpaths could be invalid now - remove those, BuildClassPath() is too expensive
                                ASContext.Context.Classpath.RemoveAll(cp => !Directory.Exists(cp.Path));

                                foreach (PathModel cp in ASContext.Context.Classpath)
                                    cp.EnableWatcher();
                            }

                            // Return requested language SDK list
                            else if (command == "ASCompletion.InstalledSDKs")
                            {
                                Hashtable info = de.Data as Hashtable;
                                if (info != null && info.ContainsKey("language"))
                                {
                                    IASContext context = ASContext.GetLanguageContext(info["language"] as string);
                                    if (context != null)
                                        info["sdks"] = context.Settings.InstalledSDKs;
                                }
                                e.Handled = true;
                            }
                        }

                        // Create a fake document from a FileModel
                        else if (command == "ProjectManager.OpenVirtualFile")
                        {
                            string cmdData = de.Data as string;
                            if (reVirtualFile.IsMatch(cmdData))
                            {
                                string[] path = Regex.Split(cmdData, "::");
                                string fileName = path[0] + Path.DirectorySeparatorChar
                                    + path[1].Replace('.', Path.DirectorySeparatorChar).Replace("::", Path.DirectorySeparatorChar.ToString());
                                FileModel found = ModelsExplorer.Instance.OpenFile(fileName);
                                if (found != null) e.Handled = true;
                            }
                        }
                        else if (command == "ProjectManager.UserRefreshTree")
                        {
                            ASContext.UserRefreshRequestAll();
                        }
                        break;
                }

                //
                // Actionscript context specific
                //
                if (ASContext.Context.IsFileValid)
                {
                    switch (e.Type)
                    {
                        case EventType.ProcessArgs:
                            TextEvent te = (TextEvent) e;
                            if (reArgs.IsMatch(te.Value))
                            {
                                // resolve current element
                                Hashtable details = ASComplete.ResolveElement(sci, null);
                                te.Value = ArgumentsProcessor.Process(te.Value, details);

                                if (te.Value.IndexOf('$') >= 0 && reCostlyArgs.IsMatch(te.Value))
                                {
                                    ASResult result = ASComplete.CurrentResolvedContext.Result ?? new ASResult();
                                    details = new Hashtable();
                                    // Get closest list (Array or Vector)
                                    string closestListName = "", closestListItemType = "";
                                    ASComplete.FindClosestList(ASContext.Context, result.Context, sci.CurrentLine, ref closestListName, ref closestListItemType);
                                    details.Add("TypClosestListName", closestListName);
                                    details.Add("TypClosestListItemType", closestListItemType);
                                    // get free iterator index
                                    string iterator = ASComplete.FindFreeIterator(ASContext.Context, ASContext.Context.CurrentClass, result.Context);
                                    details.Add("ItmUniqueVar", iterator);
                                    te.Value = ArgumentsProcessor.Process(te.Value, details);
                                }
                            }
                            break;

                        // menu commands
                        case EventType.Command:
                            de = e as DataEvent;
                            string command = de.Action ?? "";
                            if (command.StartsWith("ASCompletion.", StringComparison.Ordinal))
                            {
                                string cmdData = de.Data as string;
                                switch (command)
                                {
                                    // run MTASC
                                    case "ASCompletion.CustomBuild":
                                        if (cmdData != null) ASContext.Context.RunCMD(cmdData);
                                        else ASContext.Context.RunCMD("");
                                        e.Handled = true;
                                        break;

                                    // build the SWF using MTASC
                                    case "ASCompletion.QuickBuild":
                                        ASContext.Context.BuildCMD(false);
                                        e.Handled = true;
                                        break;

                                    // resolve element under cursor and open declaration
                                    case "ASCompletion.GotoDeclaration":
                                        ASComplete.DeclarationLookup(sci);
                                        e.Handled = true;
                                        break;

                                    // resolve element under cursor and send a CustomData event
                                    case "ASCompletion.ResolveElement":
                                        ASComplete.ResolveElement(sci, cmdData);
                                        e.Handled = true;
                                        break;

                                    case "ASCompletion.MakeIntrinsic":
                                        ASContext.Context.MakeIntrinsic(cmdData);
                                        e.Handled = true;
                                        break;

                                    // alternative to default shortcuts
                                    case "ASCompletion.CtrlSpace":
                                        ASComplete.OnShortcut(Keys.Control | Keys.Space, ASContext.CurSciControl);
                                        e.Handled = true;
                                        break;

                                    case "ASCompletion.CtrlShiftSpace":
                                        ASComplete.OnShortcut(Keys.Control | Keys.Shift | Keys.Space, ASContext.CurSciControl);
                                        e.Handled = true;
                                        break;

                                    case "ASCompletion.CtrlAltSpace":
                                        ASComplete.OnShortcut(Keys.Control | Keys.Alt | Keys.Space, ASContext.CurSciControl);
                                        e.Handled = true;
                                        break;

                                    case "ASCompletion.ContextualGenerator":
                                        if (ASContext.HasContext && ASContext.Context.IsFileValid)
                                        {
                                            var options = new List<ICompletionListItem>();
                                            ASGenerator.ContextualGenerator(ASContext.CurSciControl, options);
                                            EventManager.DispatchEvent(this, new DataEvent(EventType.Command, "ASCompletion.ContextualGenerator.AddOptions", options));
                                            if (options.Count == 0)
                                            {
                                                PluginBase.MainForm.StatusLabel.Text = TextHelper.GetString("Info.NoContextGeneratorCode");
                                            }
                                            CompletionList.Show(options, false);
                                        }
                                        break;
                                }
                            }
                            return;

                        case EventType.ProcessEnd:
                            string procResult = (e as TextEvent).Value;
                            ASContext.Context.OnProcessEnd(procResult);
                            break;
                    }
                }
            }
            catch(Exception ex)
            {
                ErrorManager.ShowError(ex);
            }
        }
Пример #3
0
        /// <summary>
        /// Classpathes & classes cache initialisation
        /// </summary>
        public override void BuildClassPath()
        {
            ReleaseClasspath();
            started = true;
            if (loomSettings == null) throw new Exception("BuildClassPath() must be overridden");
            if (contextSetup == null)
            {
                contextSetup = new ContextSetupInfos();
                contextSetup.Lang = settings.LanguageId;
                contextSetup.Platform = "loom";
                contextSetup.Version = "1.0";
            }

            // external version definition
            platform = contextSetup.Platform;
            majorVersion = 1;
            minorVersion = 0;
            ParseVersion(contextSetup.Version, ref majorVersion, ref minorVersion);

            //
            // Class pathes
            //
            classPath = new List<PathModel>();

            // SDK
            string compiler = PluginBase.CurrentProject != null && PluginBase.CurrentProject.CurrentSDK != null
                ? PluginBase.CurrentProject.CurrentSDK
                : loomSettings.GetDefaultSDK().Path;

            char S = Path.DirectorySeparatorChar;
            string sdkLibs = compiler + S + "libs";

            if (!String.IsNullOrEmpty(sdkLibs) && Directory.Exists(sdkLibs))
            {
                foreach (string loomlib in Directory.GetFiles(sdkLibs, "*.loomlib"))
                {
                    AddLib(contextSetup, loomlib);
                }
            }

            // add external pathes
            List<PathModel> initCP = classPath;
            classPath = new List<PathModel>();
            if (contextSetup.Classpath != null)
            {
                foreach (string cpath in contextSetup.Classpath)
                    AddPath(cpath.Trim());
            }

            // add library
            AddPath(PathHelper.LibraryDir + S + "LOOM" + S + "classes");
            // 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();
        }
Пример #4
0
 /// <summary>
 /// Add additional classpathes
 /// </summary>
 public virtual void Setup(ContextSetupInfos setup)
 {
     contextSetup = setup;
     BuildClassPath();
 }
Пример #5
0
        /// <summary>
        /// Classpathes & classes cache initialisation
        /// </summary>
        public override void BuildClassPath()
        {
            ReleaseClasspath();
            started = true;
            if (as2settings == null) throw new Exception("BuildClassPath() must be overridden");
            if (contextSetup == null)
            {
                contextSetup = new ContextSetupInfos();
                contextSetup.Lang = settings.LanguageId;
                contextSetup.Platform = "Flash Player";
                contextSetup.Version = as2settings.DefaultFlashVersion + ".0";
            }

            // external version definition
            platform = contextSetup.Platform;
            majorVersion = as2settings.DefaultFlashVersion;
            minorVersion = 0;
            ParseVersion(contextSetup.Version, ref majorVersion, ref minorVersion);

            //
            // Class pathes
            //
            classPath = new List<PathModel>();

            // MTASC
            string mtascPath = PluginBase.CurrentProject != null
                    ? PluginBase.CurrentProject.CurrentSDK
                    : PathHelper.ResolvePath(as2settings.GetDefaultSDK().Path);
            if (Path.GetExtension(mtascPath) != "") mtascPath = Path.GetDirectoryName(mtascPath);

            string path;
            if ((as2settings.UseMtascIntrinsic || String.IsNullOrEmpty(as2settings.MMClassPath))
                && !String.IsNullOrEmpty(mtascPath) && System.IO.Directory.Exists(mtascPath))
            {
                try
                {
                    if (majorVersion == 9)
                    {
                        path = Path.Combine(mtascPath, "std9");
                        if (System.IO.Directory.Exists(path)) AddPath(path);
                        else majorVersion = 8;
                    }
                    if (majorVersion == 8)
                    {
                        path = Path.Combine(mtascPath, "std8");
                        if (System.IO.Directory.Exists(path)) AddPath(path);
                    }
                    path = Path.Combine(mtascPath, "std");
                    if (System.IO.Directory.Exists(path)) AddPath(path);
                }
                catch {}
            }
            // Macromedia/Adobe
            if (!String.IsNullOrEmpty(as2settings.MMClassPath) && System.IO.Directory.Exists(as2settings.MMClassPath))
            {
                if (classPath.Count == 0)
                {
                    // Flash CS3: the FP9 classpath overrides some classes of FP8
                    int tempVersion = majorVersion;
                    if (tempVersion > 8)
                    {
                        path = Path.Combine(as2settings.MMClassPath, "FP" + tempVersion);
                        if (System.IO.Directory.Exists(path))
                            AddPath(path);
                        // now add FP8
                        tempVersion = 8;
                    }
                    path = Path.Combine(as2settings.MMClassPath, "FP" + Math.Max(7, tempVersion));
                    if (System.IO.Directory.Exists(path))
                    {
                        PathModel aPath = new PathModel(path, this);
                        ManualExploration(aPath, new string[] { "aso", "FP7", "FP8", "FP9" });
                        AddPath(aPath);
                    }
                }
            }

            // add external pathes
            List<PathModel> initCP = classPath;
            classPath = new List<PathModel>();
            if (contextSetup.Classpath != null)
            {
                foreach (string cpath in contextSetup.Classpath)
                    AddPath(cpath.Trim());
            }

            // add library
            AddPath(Path.Combine(PathHelper.LibraryDir, "AS2/classes"));
            // 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();
        }
Пример #6
0
        /// <summary>
        /// Classpathes & classes cache initialisation
        /// </summary>
        public override void BuildClassPath()
        {
            ReleaseClasspath();
            started = true;
            if (hxsettings == null) throw new Exception("BuildClassPath() must be overridden");
            if (contextSetup == null)
            {
                contextSetup = new ContextSetupInfos();
                contextSetup.Classpath = new string[] { Environment.CurrentDirectory };
                contextSetup.Lang = settings.LanguageId;
                contextSetup.Platform = "Flash Player";
                contextSetup.Version = "10.0";
            }

            // external version definition
            platform = contextSetup.Platform;
            majorVersion = hxsettings.DefaultFlashVersion;
            minorVersion = 0;
            ParseVersion(contextSetup.Version, ref majorVersion, ref minorVersion);

            // NOTE: version > 10 for non-Flash platforms
            string lang = GetHaxeTarget(platform);
            hasAIRSupport = hasMobileSupport = false;
            features.Directives = new List<string>();

            if (lang == null)
            {
                if (contextSetup.Platform == "hxml")
                {
                    lang = contextSetup.TargetBuild ?? "";
                }
                else // assume game-related toolchain
                {
                    lang = "cpp";
                    if (contextSetup.TargetBuild == null || contextSetup.TargetBuild.StartsWithOrdinal("flash"))
                        lang = "";
                    else if (contextSetup.TargetBuild.StartsWithOrdinal("html5"))
                        lang = "js";
                    else if (contextSetup.TargetBuild.IndexOfOrdinal("neko") >= 0)
                        lang = "neko";
                }
            }
            else if (lang == "swf")
            {
                lang = "flash";
                hasAIRSupport = platform.StartsWithOrdinal("AIR");
                hasMobileSupport = platform == "AIR Mobile";
            }
            features.Directives.Add(lang);
            HaxeTarget = lang;

            //
            // Class pathes
            //
            classPath = new List<PathModel>();
            // haXe std
            string hxPath = PluginBase.CurrentProject is HaxeProject
                    ? PluginBase.CurrentProject.CurrentSDK
                    : PathHelper.ResolvePath(hxsettings.GetDefaultSDK().Path);
            if (hxPath != null)
            {
                if (currentSDK != hxPath)
                {
                    currentSDK = hxPath;
                    haxelibsCache = new Dictionary<string, List<string>>();
                    OnCompletionModeChange();
                }

                string haxeCP = Path.Combine(hxPath, "std");
                if (Directory.Exists(haxeCP))
                {
                    if (Directory.Exists(Path.Combine(haxeCP, "flash9")))
                    {
                        FLASH_NEW = "flash9";
                        FLASH_OLD = "flash";
                    }
                    else
                    {
                        FLASH_NEW = "flash";
                        FLASH_OLD = "flash8";
                    }
                    if (HaxeTarget == "flash")
                        lang = (majorVersion >= 6 && majorVersion < 9) ? FLASH_OLD : FLASH_NEW;

                    PathModel std = PathModel.GetModel(haxeCP, this);
                    if (!std.WasExplored && !Settings.LazyClasspathExploration)
                    {
                        string[] keep = new string[] { "sys", "haxe", "libs" };
                        List<String> hide = new List<string>();
                        foreach (string dir in Directory.GetDirectories(haxeCP))
                            if (Array.IndexOf<string>(keep, Path.GetFileName(dir)) < 0)
                                hide.Add(Path.GetFileName(dir));
                        ManualExploration(std, hide);
                    }
                    AddPath(std);

                    if (!string.IsNullOrEmpty(lang))
                    {
                        PathModel specific = PathModel.GetModel(Path.Combine(haxeCP, lang), this);
                        if (!specific.WasExplored && !Settings.LazyClasspathExploration)
                        {
                            ManualExploration(specific, null);
                        }
                        AddPath(specific);
                    }
                }

                // Haxe3/extralibs is a user global source location
                string extraCP = Path.Combine(hxPath, "extralibs");
                if (Directory.Exists(extraCP)) AddPath(extraCP);
            }
            HaxeProject proj = PluginBase.CurrentProject as HaxeProject;

            // swf-libs
            if (HaxeTarget == "flash" && majorVersion >= 9 && proj != null)
            {
                foreach(LibraryAsset asset in proj.LibraryAssets)
                    if (asset.IsSwc)
                    {
                        string path = proj.GetAbsolutePath(asset.Path);
                        if (File.Exists(path)) AddPath(path);
                    }
                foreach(string p in proj.CompilerOptions.Additional)
                    if (p.IndexOfOrdinal("-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 (!string.IsNullOrEmpty(param) && param.IndexOfOrdinal("-lib ") == 0)
                    {
                        List<string> libPaths = LookupLibrary(param.Substring(5));
                        if (libPaths != null)
                        {
                            foreach (string path in libPaths)
                            {
                                PathModel libPath = AddPath(path);
                                if (libPath != null) AppendPath(contextSetup, libPath.Path);
                            }
                        }
                    }
            }

            // add external pathes
            List<PathModel> initCP = classPath;
            classPath = new List<PathModel>();
            if (contextSetup.Classpath != null)
            {
                foreach (string cpath in contextSetup.Classpath)
                    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();

            resolvingDot = false;
            resolvingFunction = false;
            if (completionModeHandler == null)
                OnCompletionModeChange();
        }
Пример #7
0
 /// <summary>
 /// Allows the Project Manager to define the languages projects' classpath
 /// </summary>
 /// <param name="lang">Language id (ie. Scintilla.ConfigurationLanguage)</param>
 /// <param name="classpath">Additional classpath</param>
 static public void SetLanguageClassPath(ContextSetupInfos setup)
 {
     foreach (RegisteredContext reg in allContexts)
     {
         if (reg.Language == setup.Lang) reg.Context.Setup(setup);
     }
 }
Пример #8
0
 private void AppendPath(ContextSetupInfos contextSetup, string path)
 {
     foreach(string cp in contextSetup.Classpath)
         if (path.Equals(cp, StringComparison.OrdinalIgnoreCase))
             return;
     if (contextSetup.AdditionalPaths == null) contextSetup.AdditionalPaths = new List<string>();
     foreach (string cp in contextSetup.AdditionalPaths)
         if (path.Equals(cp, StringComparison.OrdinalIgnoreCase))
             return;
     contextSetup.AdditionalPaths.Add(path);
 }
Пример #9
0
        /// <summary>
        /// Classpathes & classes cache initialisation
        /// </summary>
        public override void BuildClassPath()
        {
            ReleaseClasspath();
            started = true;
            if (langSettings == null) throw new Exception("BuildClassPath() must be overridden");
            if (contextSetup == null)
            {
                contextSetup = new ContextSetupInfos();
                contextSetup.Lang = settings.LanguageId;
                contextSetup.Platform = "PHP";
                contextSetup.Version = "5.0";
            }

            //
            // Class pathes
            //
            classPath = new List<PathModel>();
            // intrinsic language definitions
            if (langSettings.LanguageDefinitions != null)
            {
                string langPath = PathHelper.ResolvePath(langSettings.LanguageDefinitions);
                if (Directory.Exists(langPath)) AddPath(langPath);
            }

            // add external pathes
            List<PathModel> initCP = classPath;
            classPath = new List<PathModel>();
            if (contextSetup.Classpath != null)
            {
                foreach (string cpath in contextSetup.Classpath)
                    AddPath(cpath.Trim());
            }

            // add library
            AddPath(Path.Combine(PathHelper.LibraryDir, settings.LanguageId + "/classes"));
            // 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();
        }
Пример #10
0
        /// <summary>
        /// Classpathes & classes cache initialisation
        /// </summary>
        public override void BuildClassPath()
        {
            ReleaseClasspath();
            started = true;
            if (as3settings == null) throw new Exception("BuildClassPath() must be overridden");
            if (contextSetup == null)
            {
                contextSetup = new ContextSetupInfos();
                contextSetup.Lang = settings.LanguageId;
                contextSetup.Platform = "Flash Player";
                contextSetup.Version = as3settings.DefaultFlashVersion;
            }

            // external version definition
            platform = contextSetup.Platform;
            majorVersion = 10;
            minorVersion = 0;
            ParseVersion(contextSetup.Version, ref majorVersion, ref minorVersion);
            hasAIRSupport = platform == "AIR" || platform == "AIR Mobile";
            hasMobileSupport = platform == "AIR Mobile";

            string cpCheck = contextSetup.Classpath != null ?
                String.Join(";", contextSetup.Classpath).Replace('\\', '/') : "";

            // check if CP contains a custom playerglobal.swc
            bool hasCustomAPI = re_customAPI.IsMatch(cpCheck);

            //
            // Class pathes
            //
            classPath = new List<PathModel>();
            MxmlFilter.ClearCatalogs();
            MxmlFilter.AddProjectManifests();

            // SDK
            string compiler = PluginBase.CurrentProject != null
                ? PluginBase.CurrentProject.CurrentSDK
                : as3settings.GetDefaultSDK().Path;

            char S = Path.DirectorySeparatorChar;
            if (compiler == null)
                compiler = Path.Combine(PathHelper.ToolDir, "flexlibs");
            string frameworks = compiler + S + "frameworks";
            string sdkLibs = frameworks + S + "libs";
            string sdkLocales = frameworks + S + "locale" + S + PluginBase.MainForm.Settings.LocaleVersion;
            string fallbackLibs = PathHelper.ResolvePath(PathHelper.ToolDir + S + "flexlibs" + S + "frameworks" + S + "libs");
            string fallbackLocale = PathHelper.ResolvePath(PathHelper.ToolDir + S + "flexlibs" + S + "frameworks" + S + "locale" + S + "en_US");
            List<string> addLibs = new List<string>();
            List<string> addLocales = new List<string>();

            if (!Directory.Exists(sdkLibs) && !sdkLibs.StartsWith("$")) // fallback
            {
                sdkLibs = PathHelper.ResolvePath(PathHelper.ToolDir + S + "flexlibs" + S + "frameworks" + S + "libs" + S + "player");
            }

            if (majorVersion > 0 && !String.IsNullOrEmpty(sdkLibs) && Directory.Exists(sdkLibs))
            {
                // core API SWC
                if (!hasCustomAPI)
                    if (hasAIRSupport)
                    {
                        addLibs.Add("air" + S + "airglobal.swc");
                        addLibs.Add("air" + S + "aircore.swc");
                        addLibs.Add("air" + S + "applicationupdater.swc");
                    }
                    else
                    {
                        bool swcPresent = false;
                        string playerglobal = MatchPlayerGlobalExact(majorVersion, minorVersion, sdkLibs);
                        if (playerglobal != null) swcPresent = true;
                        else playerglobal = MatchPlayerGlobalExact(majorVersion, minorVersion, fallbackLibs);
                        if (playerglobal == null) playerglobal = MatchPlayerGlobalAny(ref majorVersion, ref minorVersion, fallbackLibs);
                        if (playerglobal == null) playerglobal = MatchPlayerGlobalAny(ref majorVersion, ref minorVersion, sdkLibs);
                        if (playerglobal != null)
                        {
                            // add missing SWC in new SDKs
                            if (!swcPresent && sdkLibs.IndexOf(S + "flexlibs") < 0 && Directory.Exists(compiler))
                            {
                                string swcDir = sdkLibs + S + "player" + S;
                                if (!Directory.Exists(swcDir + "9") && !Directory.Exists(swcDir + "10"))
                                    swcDir += majorVersion + "." + minorVersion;
                                else
                                    swcDir += majorVersion;
                                try
                                {
                                    if (!File.Exists(swcDir + S + "playerglobal.swc"))
                                    {
                                        Directory.CreateDirectory(swcDir);
                                        File.Copy(playerglobal, swcDir + S + "playerglobal.swc");
                                        File.WriteAllText(swcDir + S + "FlashDevelopNotice.txt",
                                            "This 'playerglobal.swc' was copied here automatically by FlashDevelop from:\r\n" + playerglobal);
                                    }
                                    playerglobal = swcDir + S + "playerglobal.swc";
                                }
                                catch { }
                            }
                            addLibs.Add(playerglobal);
                        }
                    }
                addLocales.Add("playerglobal_rb.swc");

                // framework SWCs
                string as3Fmk = PathHelper.ResolvePath("Library" + S + "AS3" + S + "frameworks");

                // Flex core - ie. (Bitmap|Font|ByteArray|...)Asset / Flex(Sprite|MobieClip|Loader...)
                addLibs.Add("flex.swc");
                addLibs.Add("core.swc");

                // Flex framework
                if (cpCheck.IndexOf("Library/AS3/frameworks/Flex", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    addLibs.Add("framework.swc");
                    addLibs.Add("mx/mx.swc");
                    addLibs.Add("rpc.swc");
                    addLibs.Add("datavisualization.swc");
                    addLibs.Add("flash-integration.swc");
                    addLocales.Add("framework_rb.swc");
                    addLocales.Add("mx_rb.swc");
                    addLocales.Add("rpc_rb.swc");
                    addLocales.Add("datavisualization_rb.swc");
                    addLocales.Add("flash-integration_rb.swc");

                    if (hasAIRSupport)
                    {
                        addLibs.Add("air" + S + "airframework.swc");
                        addLocales.Add("airframework_rb.swc");
                    }

                    if (cpCheck.IndexOf("Library/AS3/frameworks/Flex4", StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        addLibs.Add("spark.swc");
                        addLibs.Add("spark_dmv.swc");
                        addLibs.Add("sparkskins.swc");
                        //addLibs.Add("textLayout.swc");
                        addLibs.Add("osmf.swc");
                        addLocales.Add("spark_rb.swc");
                        //addLocales.Add("textLayout_rb.swc");
                        addLocales.Add("osmf_rb.swc");

                        if (hasAIRSupport)
                        {
                            addLibs.Add("air" + S + "airspark.swc");
                            addLocales.Add("airspark_rb.swc");

                            if (hasMobileSupport)
                            {
                                addLibs.Add("mobile" + S + "mobilecomponents.swc");
                                addLocales.Add("mobilecomponents_rb.swc");
                            }
                        }

                        MxmlFilter.AddManifest("http://ns.adobe.com/mxml/2009", as3Fmk + S + "Flex4" + S + "manifest.xml");
                    }
                    else
                    {
                        MxmlFilter.AddManifest(MxmlFilter.OLD_MX, as3Fmk + S + "Flex3" + S + "manifest.xml");
                    }
                }
            }

            foreach (string file in addLocales)
            {
                string swcItem = sdkLocales + S + file;
                if (!File.Exists(swcItem)) swcItem = fallbackLocale + S + file;
                AddPath(swcItem);
            }
            foreach (string file in addLibs)
            {
                if (File.Exists(file)) AddPath(file);
                else AddPath(sdkLibs + S + file);
            }

            // intrinsics (deprecated, excepted for FP10 Vector.<T>)
            string fp9cp = as3settings.AS3ClassPath + S + "FP9";
            AddPath(PathHelper.ResolvePath(fp9cp));
            if (majorVersion > 9)
            {
                string fp10cp = as3settings.AS3ClassPath + S + "FP" + majorVersion;
                AddPath(PathHelper.ResolvePath(fp10cp));
                string fp101cp = as3settings.AS3ClassPath + S + "FP" + majorVersion + "." + minorVersion;
                AddPath(PathHelper.ResolvePath(fp101cp));
            }

            // add external pathes
            List<PathModel> initCP = classPath;
            classPath = new List<PathModel>();
            if (contextSetup.Classpath != null)
            {
                foreach (string cpath in contextSetup.Classpath)
                    AddPath(cpath.Trim());
            }

            // add library
            AddPath(PathHelper.LibraryDir + S + "AS3" + S + "classes");
            // 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();
        }
Пример #11
0
        /// <summary>
        /// Classpathes & classes cache initialisation
        /// </summary>
        public override void BuildClassPath()
        {
            ReleaseClasspath();
            started = true;
            if (unitysettings == null) throw new Exception("BuildClassPath() must be overridden");
            if (contextSetup == null)
            {
                contextSetup = new ContextSetupInfos();
                contextSetup.Lang = settings.LanguageId;
                contextSetup.Platform = "Unity3D";
                contextSetup.Version = unitysettings.DefaultVersion;
            }

            // external version definition
            platform = contextSetup.Platform;
            majorVersion = 0;
            minorVersion = 0;
            ParseVersion(contextSetup.Version, ref majorVersion, ref minorVersion);

            //
            // Class pathes
            //
            classPath = new List<PathModel>();

            // SDK
            string sdkPath = PluginBase.CurrentProject != null
                    ? PluginBase.CurrentProject.CurrentSDK
                    : PathHelper.ResolvePath(unitysettings.GetDefaultSDK().Path);
            //TODO?

            // add external pathes
            List<PathModel> initCP = classPath;
            classPath = new List<PathModel>();
            if (contextSetup.Classpath != null)
            {
                foreach (string cpath in contextSetup.Classpath)
                    AddPath(cpath.Trim());
            }

            // add library
            AddPath(Path.Combine(PathHelper.LibraryDir, "UNITYSCRIPT/Classes"));

            // 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();
        }
Пример #12
0
 /// <summary>
 /// Allows the Project Manager to define the languages projects' classpath
 /// </summary>
 /// <param name="lang">Language id (ie. Scintilla.ConfigurationLanguage)</param>
 /// <param name="classpath">Additional classpath</param>
 public static void SetLanguageClassPath(ContextSetupInfos setup)
 {
     string lang = setup.Lang.ToLower();
     foreach (RegisteredContext reg in allContexts)
     {
         if (reg.Language == setup.Lang) reg.Context.Setup(setup);
     }
 }