コード例 #1
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            switch (e.Type)
            {
            case EventType.Command:
                DataEvent de = e as DataEvent;
                if (de == null)
                {
                    return;
                }
                if (de.Action == "ProjectManager.RunCustomCommand")
                {
                    if (ExternalToolchain.HandleProject(PluginBase.CurrentProject))
                    {
                        e.Handled = ExternalToolchain.Run(de.Data as string);
                    }
                }
                else if (de.Action == "ProjectManager.BuildingProject" || de.Action == "ProjectManager.TestingProject")
                {
                    var completionHandler = contextInstance.completionModeHandler as CompletionServerCompletionHandler;
                    if (completionHandler != null && !completionHandler.IsRunning())
                    {
                        completionHandler.StartServer();
                    }
                }
                else if (de.Action == "ProjectManager.CleanProject")
                {
                    var project = de.Data as IProject;
                    if (ExternalToolchain.HandleProject(project))
                    {
                        e.Handled = ExternalToolchain.Clean(project);
                    }
                }
                else if (de.Action == "ProjectManager.Project")
                {
                    var project = de.Data as IProject;
                    ExternalToolchain.Monitor(project);
                }
                else if (de.Action == "Context.SetHaxeEnvironment")
                {
                    contextInstance.SetHaxeEnvironment(de.Data as string);
                }
                break;

            case EventType.UIStarted:
                ValidateSettings();
                contextInstance = new Context(settingObject);
                // Associate this context with haxe language
                ASCompletion.Context.ASContext.RegisterLanguage(contextInstance, "haxe");
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
            case EventType.Command:
                DataEvent de = e as DataEvent;
                if (de == null)
                {
                    return;
                }
                var action = de.Action;
                if (action == "ProjectManager.RunCustomCommand")
                {
                    if (ExternalToolchain.HandleProject(PluginBase.CurrentProject))
                    {
                        e.Handled = ExternalToolchain.Run(de.Data as string);
                    }
                }
                else if (action == "ProjectManager.BuildingProject" || action == "ProjectManager.TestingProject")
                {
                    var completionHandler = contextInstance.completionModeHandler as CompletionServerCompletionHandler;
                    if (completionHandler != null && !completionHandler.IsRunning())
                    {
                        completionHandler.StartServer();
                    }
                }
                else if (action == "ProjectManager.CleanProject")
                {
                    var project = de.Data as IProject;
                    if (ExternalToolchain.HandleProject(project))
                    {
                        e.Handled = ExternalToolchain.Clean(project);
                    }
                }
                else if (action == "ProjectManager.Project")
                {
                    var project = de.Data as IProject;
                    ExternalToolchain.Monitor(project);
                }
                else if (action == "Context.SetHaxeEnvironment")
                {
                    contextInstance.SetHaxeEnvironment(de.Data as string);
                }
                else if (action == "ProjectManager.OpenVirtualFile")
                {
                    e.Handled = OpenVirtualFileModel((string)de.Data);
                }
                else if (action == "ResultsPanel.ClearResults")
                {
                    logCount = 0;
                }
                break;

            case EventType.UIStarted:
                ValidateSettings();
                contextInstance = new Context(settingObject);
                // Associate this context with haxe language
                ASCompletion.Context.ASContext.RegisterLanguage(contextInstance, "haxe");
                CommandFactoryProvider.Register("haxe", new HaxeCommandFactory());
                break;

            case EventType.Trace:
                if (settingObject.DisableLibInstallation)
                {
                    return;
                }
                var patterns = new[]
                {
                    "Library \\s*(?<name>[^ ]+)\\s*?(\\s*version (?<version>[^ ]+))?",
                    "Could not find haxelib\\s*(?<name>\"[^ ]+\")?(\\s*version \"(?<version>[^ ]+)\")?"    //openfl project
                };
                var nameToVersion = new Dictionary <string, string>();
                for (var i = logCount; i < TraceManager.TraceLog.Count; i++)
                {
                    var message = TraceManager.TraceLog[i].Message?.Trim();
                    if (string.IsNullOrEmpty(message))
                    {
                        continue;
                    }
                    foreach (var pattern in patterns)
                    {
                        var m = Regex.Match(message, pattern);
                        if (m.Success)
                        {
                            nameToVersion[m.Groups["name"].Value] = m.Groups["version"].Value;
                        }
                    }
                }
                logCount = TraceManager.TraceLog.Count;
                if (nameToVersion.Count == 0)
                {
                    return;
                }
                var text   = TextHelper.GetString("Info.MissingLib");
                var result = MessageBox.Show(PluginBase.MainForm, text, string.Empty, MessageBoxButtons.OKCancel);
                if (result == DialogResult.OK)
                {
                    contextInstance.InstallHaxelib(nameToVersion);
                }
                break;
            }
        }