Example #1
0
        public void WillPrintHelpTextForInvalidArgs_NoValueForOption()
        {
            var argsProcessor = new ArgumentsProcessor();

            argsProcessor.ProcessCommandLineArgs(new string[] { "asdf", "--reportDirectory", });

            var helpText = ConsoleWriter.ToString();

            Assert.IsTrue(helpText.Contains(@"ERROR(S):" + Environment.NewLine + "  Option 'reportDirectory' has no value."));
            Assert.IsTrue(Regex.Replace(helpText, @"\s+", "").Contains(UsageText), helpText);
        }
Example #2
0
        public void WillPrintHelpTextForNoArgs()
        {
            var argsProcessor = new ArgumentsProcessor();

            argsProcessor.ProcessCommandLineArgs(new string[] { });

            var helpText = ConsoleWriter.ToString();

            Assert.IsTrue(helpText.Contains("ERROR(S):" + Environment.NewLine + "  A required value not bound to option name is missing."));
            Assert.IsTrue(Regex.Replace(helpText, @"\s+", "").Contains(UsageText), helpText);
        }
Example #3
0
        public void WillPrintHelpTextForInvalidArgs()
        {
            var argsProcessor = new ArgumentsProcessor();

            argsProcessor.ProcessCommandLineArgs(new string[] { "asdf", "--abcd", "asdf" });

            var helpText = ConsoleWriter.ToString();

            Assert.IsTrue(helpText.Contains("ERROR(S):" + Environment.NewLine + "  Option 'abcd' is unknown."));
            Assert.IsTrue(Regex.Replace(helpText, @"\s+", "").Contains(UsageText), helpText);
        }
Example #4
0
        public void TestProcess()
        {
            IList <string>          parameters          = (IList <string>) this.Ctx.GetObject("Parameters");
            OptionsProcessor        optionsProcessor    = (OptionsProcessor)this.Ctx.GetObject("OptionsProcessor");
            ArgumentsProcessor      argumentsProcessor  = (ArgumentsProcessor)this.Ctx.GetObject("ArgumentsProcessor");
            ParametersProcessorImpl parametersProcessor = new ParametersProcessorImpl();

            parametersProcessor.Parameters         = parameters;
            parametersProcessor.OptionsProcessor   = optionsProcessor;
            parametersProcessor.ArgumentsProcessor = argumentsProcessor;

            parametersProcessor.Process();
        }
        public ParametersProcessor NewParametersProcessor(
            IList <string> parameters,
            OptionsProcessor optionsProcessor,
            ArgumentsProcessor argumentsProcessor
            )
        {
            ParametersProcessorImpl processor = new ParametersProcessorImpl();

            processor.Parameters         = parameters;
            processor.OptionsProcessor   = optionsProcessor;
            processor.ArgumentsProcessor = argumentsProcessor;
            return(processor);
        }
Example #6
0
        public void WillParseMultipleArguments(string [] files, string reportDirectory)
        {
            string[] args = files;
            if (!string.IsNullOrEmpty(reportDirectory))
            {
                args = files.Union(new string[] { "--reportDirectory", reportDirectory }).ToArray();
            }

            var argsProcessor = new ArgumentsProcessor();

            var cliArgs = argsProcessor.ProcessCommandLineArgs(args);

            Assert.AreEqual(cliArgs.ReportDirectory, reportDirectory);

            foreach (var file in files)
            {
                Assert.IsTrue(cliArgs.CoverageFiles.Contains(file));
            }
        }
    public static void DotNetTest(
        this ICakeContext context,
        FilePath project,
        DotNetTestSettings settings,
        CoverletSettings coverletSettings)
    {
        if (context == null)
        {
            throw new ArgumentNullException(nameof(context));
        }
        var currentCustomization = settings.ArgumentCustomization;

        settings.ArgumentCustomization = (args) => ArgumentsProcessor.ProcessMSBuildArguments(
            coverletSettings,
            context.Environment,
            currentCustomization?.Invoke(args) ?? args,
            project);

        context.DotNetTest(project.FullPath, settings);
    }
Example #8
0
        [Test] public void TestNewParametersProcessor()
        {
            IList <string>     parameters         = (IList <string>) this.Ctx.GetObject("Parameters");
            OptionsProcessor   optionsProcessor   = (OptionsProcessor)this.Ctx.GetObject("OptionsProcessor");
            ArgumentsProcessor argumentsProcessor = (ArgumentsProcessor)this.Ctx.GetObject("ArgumentsProcessor");

            ParametersProcessor parametersProcessor = this.ConfigurationFactory.NewParametersProcessor(
                parameters,
                optionsProcessor,
                argumentsProcessor
                );

            Assert.That(parametersProcessor, Is.Not.Null);
            Assert.That(parametersProcessor, Is.InstanceOf(typeof(ParametersProcessorImpl)));
            ParametersProcessorImpl parametersProcessorImpl = (ParametersProcessorImpl)parametersProcessor;

            Assert.That(parametersProcessorImpl.Parameters, Is.EqualTo(parameters));
            Assert.That(parametersProcessorImpl.OptionsProcessor, Is.EqualTo(optionsProcessor));
            Assert.That(parametersProcessorImpl.ArgumentsProcessor, Is.EqualTo(argumentsProcessor));
        }
Example #9
0
        public static void Main(string[] args)
        {
            Logger.Init();

            ArgumentsProcessor.ParseArguments(args);

            //Ascii art of Pootis-Bot because why not ¯\_(ツ)_/¯
            Console.WriteLine(@"__________              __  .__                 __________        __   ");
            Console.WriteLine(@"\______   \____   _____/  |_|__| ______         \______   \ _____/  |_ ");
            Console.WriteLine(@" |     ___/  _ \ /  _ \   __\  |/  ___/  ______  |    |  _//  _ \   __\");
            Console.WriteLine(@" |    |  (  <_> |  <_> )  | |  |\___ \  /_____/  |    |   (  <_> )  |  ");
            Console.WriteLine(@" |____|   \____/ \____/|__| |__/____  >          |______  /\____/|__|  ");
            Console.WriteLine(@"                                    \/                  \/             ");
            Console.WriteLine($"			Version: {VersionUtils.GetAppVersion()}");
            Console.WriteLine();

            Logger.Info("Pootis-Bot starting...");

            Logger.Debug("Creating the HttpClient object...");
            Global.HttpClient = new HttpClient();

            Logger.Debug("Setting up global variables...");
            Global.BotName   = Config.bot.BotName;
            Global.BotPrefix = Config.bot.BotPrefix;
            Global.BotToken  = Config.bot.BotToken;

            //Check the audio services, if they are enabled
            MusicLibsChecker.CheckMusicService();

            Console.Title = $"{Global.BotName} Console";

            //Setup the bot, put in the name, prefix and token
            Logger.Debug("Creating the bot instance...");
            Bot bot = new Bot();

            Logger.Debug("Starting the bot...");

            //Start her up!
            bot.StartBot().GetAwaiter().GetResult();
        }
Example #10
0
        /**
         * Handles the incoming events
         */
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            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;
                }
                ScintillaNet.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().EndsWith(".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.StartsWith("ASCompletion."))
                    {
                        string cmdData = (de.Data is string) ? (string)de.Data : null;

                        // 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 = Commands.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 = Commands.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.Context.UserRefreshRequest();
                    }
                    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:
                        string command = (e as DataEvent).Action ?? "";
                        if (command.StartsWith("ASCompletion."))
                        {
                            string cmdData = (e as DataEvent).Data as string;
                            // run MTASC
                            if (command == "ASCompletion.CustomBuild")
                            {
                                if (cmdData != null)
                                {
                                    ASContext.Context.RunCMD(cmdData);
                                }
                                else
                                {
                                    ASContext.Context.RunCMD("");
                                }
                                e.Handled = true;
                            }

                            // build the SWF using MTASC
                            else if (command == "ASCompletion.QuickBuild")
                            {
                                ASContext.Context.BuildCMD(false);
                                e.Handled = true;
                            }

                            // resolve element under cusor and open declaration
                            else if (command == "ASCompletion.GotoDeclaration")
                            {
                                ASComplete.DeclarationLookup(sci);
                                e.Handled = true;
                            }

                            // resolve element under cursor and send a CustomData event
                            else if (command == "ASCompletion.ResolveElement")
                            {
                                ASComplete.ResolveElement(sci, cmdData);
                                e.Handled = true;
                            }
                            else if (command == "ASCompletion.MakeIntrinsic")
                            {
                                ASContext.Context.MakeIntrinsic(cmdData);
                                e.Handled = true;
                            }

                            // alternative to default shortcuts
                            else if (command == "ASCompletion.CtrlSpace")
                            {
                                ASComplete.OnShortcut(Keys.Control | Keys.Space, ASContext.CurSciControl);
                                e.Handled = true;
                            }
                            else if (command == "ASCompletion.CtrlShiftSpace")
                            {
                                ASComplete.OnShortcut(Keys.Control | Keys.Shift | Keys.Space, ASContext.CurSciControl);
                                e.Handled = true;
                            }
                            else if (command == "ASCompletion.CtrlAltSpace")
                            {
                                ASComplete.OnShortcut(Keys.Control | Keys.Alt | Keys.Space, ASContext.CurSciControl);
                                e.Handled = true;
                            }
                            else if (command == "ASCompletion.ContextualGenerator")
                            {
                                if (ASContext.HasContext && ASContext.Context.IsFileValid)
                                {
                                    ASGenerator.ContextualGenerator(ASContext.CurSciControl);
                                }
                            }
                        }
                        return;

                    case EventType.ProcessEnd:
                        string procResult = (e as TextEvent).Value;
                        ASContext.Context.OnProcessEnd(procResult);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorManager.ShowError(ex);
            }
        }
 public void SetUp()
 {
     processor = new ArgumentsProcessor();
 }
Example #12
0
        /**
         * Handles the incoming events
         */
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            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;
                    // associate context to initial document
                    e = new NotifyEvent(EventType.SyntaxChange);
                }

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

                //
                //  Events always handled
                //
                bool isValid;
                switch (e.Type)
                {
                // caret position in editor
                case EventType.UIRefresh:
                    if (!doc.IsEditable)
                    {
                        return;
                    }
                    try
                    {
                        int position = sci.CurrentPos;
                        if (position != currentPos)
                        {
                            currentPos = position;
                            if (currentDoc == doc.FileName)
                            {
                                int line = sci.LineFromPosition(currentPos);
                                ASContext.SetCurrentLine(line);
                                // UI
                                SetItemsEnabled(ASContext.Context.IsFileValid);
                            }
                        }
                    }
                    catch {}     // drag & drop sci Perform crash
                    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;

                //
                // 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().EndsWith(".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)
                    {
                        currentDoc = "";
                        SetItemsEnabled(false);
                        ASContext.SetCurrentFile(null, true);
                        return;
                    }
                    currentDoc = doc.FileName;
                    currentPos = sci.CurrentPos;
                    // check file
                    bool ignoreFile = !doc.IsEditable;
                    ASContext.SetCurrentFile(doc, ignoreFile);
                    // UI
                    bool enableItems = ASContext.Context.IsFileValid && !doc.IsUntitled;
                    SetItemsEnabled(enableItems);
                    pluginUI.OutlineTree.Enabled = ASContext.Context.CurrentModel != null;
                    return;

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

                    if (command.StartsWith("ASCompletion."))
                    {
                        string cmdData = (e as DataEvent).Data as string;

                        // add a custom classpath
                        if (command == "ASCompletion.ClassPath")
                        {
                            //TraceManager.Add("CP = " + cmdData);
                            if (cmdData != null)
                            {
                                int    p    = cmdData.IndexOf(';');
                                string lang = cmdData.Substring(0, p);
                                ASContext.SetLanguageClassPath(lang, cmdData.Substring(p + 1));
                            }
                            e.Handled = true;
                        }

                        // send a UserClasspath
                        else if (command == "ASCompletion.GetUserClasspath")
                        {
                            Hashtable info = (e as DataEvent).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 = (e as DataEvent).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 compiler path
                        else if (command == "ASCompletion.GetCompilerPath")
                        {
                            Hashtable info = (e as DataEvent).Data as Hashtable;
                            if (info != null && info.ContainsKey("language"))
                            {
                                IASContext context = ASContext.GetLanguageContext(info["language"] as string);
                                info["compiler"] = context != null?context.GetCompilerPath() : null;
                            }
                            e.Handled = true;
                        }

                        // show a language's settings
                        else if (command == "ASCompletion.ShowSettings")
                        {
                            e.Handled = true;
                            IASContext context = ASContext.GetLanguageContext(cmdData);
                            if (context == null)
                            {
                                return;
                            }
                            string filter = "";
                            string name   = "";
                            switch (cmdData.ToUpper())
                            {
                            case "AS2": name = "AS2Context"; filter = "MTASC"; break;

                            case "AS3": name = "AS3Context"; filter = "SDK"; break;

                            case "HAXE": name = "HaXeContext"; filter = "HaXe"; break;

                            default: name = cmdData.ToUpper() + "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")
                        {
                            e.Handled = Commands.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 = Commands.CreateTrustFile.Run(args[0], args[1]);
                                }
                            }
                        }
                        else if (command == "ASCompletion.GetClassPath")
                        {
                            if (cmdData != null)
                            {
                                string[] args = cmdData.Split(';');
                                if (args.Length == 1)
                                {
                                    FileModel fm = ASFileParser.ParseFile(args[0], ASContext.Context);
                                    if (fm != null)
                                    {
                                        if (fm.Classes != null && fm.Classes.Count > 0)
                                        {
                                            string classpath = fm.Classes[0].QualifiedName;
                                            if (classpath != null)
                                            {
                                                Clipboard.SetText(classpath);
                                                e.Handled = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else if (command == "ProjectManager.OpenVirtualFile")
                    {
                        string cmdData = (e as DataEvent).Data as string;
                        if (Regex.IsMatch(cmdData, "\\.(swf|swc)::"))
                        {
                            string[] path     = Regex.Split(cmdData, "::");
                            string   fileName = path[0] + Path.DirectorySeparatorChar
                                                + path[1].Replace('.', Path.DirectorySeparatorChar).Replace("::", Path.DirectorySeparatorChar.ToString())
                                                + "$.as";
                            FileModel found = ModelsExplorer.Instance.OpenFile(fileName);
                            if (found != null)
                            {
                                e.Handled = true;
                            }
                        }
                    }
                    break;
                }

                //
                // Actionscript context specific
                //
                if (ASContext.Context.IsFileValid)
                {
                    switch (e.Type)
                    {
                    case EventType.ProcessArgs:
                        TextEvent te  = (TextEvent)e;
                        string    cmd = te.Value;
                        if (Regex.IsMatch(cmd, "\\$\\((Typ|Mbr|Itm)"))
                        {
                            // resolve current element
                            Hashtable details = ASComplete.ResolveElement(sci, null);
                            te.Value = ArgumentsProcessor.Process(cmd, details);
                        }
                        break;

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

                            // build the SWF using MTASC
                            else if (command == "ASCompletion.QuickBuild")
                            {
                                ASContext.Context.BuildCMD(false);
                                e.Handled = true;
                            }

                            // resolve element under cusor and open declaration
                            else if (command == "ASCompletion.GotoDeclaration")
                            {
                                ASComplete.DeclarationLookup(sci);
                                e.Handled = true;
                            }

                            // resolve element under cursor and send a CustomData event
                            else if (command == "ASCompletion.ResolveElement")
                            {
                                ASComplete.ResolveElement(sci, cmdData);
                                e.Handled = true;
                            }
                            else if (command == "ASCompletion.MakeIntrinsic")
                            {
                                ASContext.Context.MakeIntrinsic(cmdData);
                                e.Handled = true;
                            }

                            // alternative to default shortcuts
                            else if (command == "ASCompletion.CtrlSpace")
                            {
                                ASComplete.OnShortcut(Keys.Control | Keys.Space, ASContext.CurSciControl);
                                e.Handled = true;
                            }
                            else if (command == "ASCompletion.CtrlShiftSpace")
                            {
                                ASComplete.OnShortcut(Keys.Control | Keys.Shift | Keys.Space, ASContext.CurSciControl);
                                e.Handled = true;
                            }
                            else if (command == "ASCompletion.CtrlAltSpace")
                            {
                                ASComplete.OnShortcut(Keys.Control | Keys.Alt | Keys.Space, ASContext.CurSciControl);
                                e.Handled = true;
                            }
                        }
                        return;

                    case EventType.ProcessEnd:
                        string result = (e as TextEvent).Value;
                        ASContext.Context.OnProcessEnd(result);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorManager.ShowError(ex);
            }
        }