コード例 #1
0
        private void OnMouseHover(ScintillaNet.ScintillaControl sci, int position)
        {
            if (!ASContext.IsClassValid())
            {
                return;
            }

            // get word at mouse position
            int style = sci.BaseStyleAt(position);

            DebugConsole.Trace("Style=" + style);
            if (!ASComplete.IsTextStyle(style))
            {
                return;
            }
            position = sci.WordEndPosition(position, true);
            ASResult result = ASComplete.GetExpressionType(sci, position);

            // set tooltip
            if (!result.IsNull())
            {
                string text = ASComplete.GetToolTipText(result);
                DebugConsole.Trace("SHOW " + text);
                if (text == null)
                {
                    return;
                }
                // show tooltip
                InfoTip.ShowAtMouseLocation(text);
            }
        }
コード例 #2
0
 /// <summary>
 /// Menu item command: Check ActionScript
 /// </summary>
 public void CheckActionScript(object sender, System.EventArgs e)
 {
     if (ASContext.IsClassValid())
     {
         if (ASContext.CurrentClass.IsAS3)
         {
             AS3.Flex2Shell.Instance.CheckAS3(mainForm.CurFile);
         }
         else
         {
             ASContext.RunMTASC(null, null);
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// Menu item command: Convert To Intrinsic
 /// </summary>
 public void MakeIntrinsic(object sender, System.EventArgs e)
 {
     if (ASContext.IsClassValid())
     {
         if (ASContext.CurrentClass.IsAS3)
         {
             ErrorHandler.ShowInfo("AS3 classes are not supported.");
         }
         else if (this.mainForm.CurSciControl != null)
         {
             ASContext.MakeIntrinsic(null);
         }
     }
 }
コード例 #4
0
        /**
         * Handles the incoming events
         */
        public void HandleEvent(object sender, NotifyEvent e)
        {
            if (e.Type != EventType.UIRefresh)
            {
                DebugConsole.Trace("*** " + e.Type.ToString());
            }

            // editor context
            ScintillaNet.ScintillaControl sci = ASContext.MainForm.CurSciControl;
            if (sci == null)
            {
                DebugConsole.Trace("null SCI");
                return;
            }

            /**
             *  Other events always handled
             */
            bool isValid;

            switch (e.Type)
            {
            // key combinations
            case EventType.Shortcut:
                DebugConsole.Trace("Key " + ((KeyEvent)e).Value);
                e.Handled = ASComplete.OnShortcut(((KeyEvent)e).Value, sci);
                return;

            //
            // File management
            //
            case EventType.FileSave:
                // update view if needed
                ASContext.CurrentClass.IsVoid();
                // toolbar
                isValid = ASContext.IsClassValid();
                this.SetItemsEnabled(isValid);
                if (isValid)
                {
                    if (ASContext.CheckOnSave)
                    {
                        AutoCheckActionScript();
                    }
                    ASContext.RemoveClassASO();
                }
                return;

            case EventType.LanguageChange:
            case EventType.FileSwitch:
                DebugConsole.Trace("Switch to " + ASContext.MainForm.CurFile);
                if (e.Type == EventType.LanguageChange)
                {
                    // remove file from the treeview (it will be re-checked and re-added later)
                    ASContext.Panel.RemoveFromView(ASContext.MainForm.CurFile);
                }

                // check class
                if ((sci.ConfigurationLanguage == "as2" || sci.ConfigurationLanguage == "as3") &&
                    !ASContext.MainForm.CurDocIsUntitled())
                {
                    ASContext.CurrentFile = ASContext.MainForm.CurFile;
                }
                else
                {
                    ASContext.CurrentFile = "";
                }

                // toolbar
                isValid = ASContext.IsClassValid();
                this.SetItemsEnabled(isValid);

                // check on open

                /*if (justOpenFile)
                 * {
                 *      justOpenFile = true;
                 *      if (isValid && ASContext.CheckOnSave)
                 *              AutoCheckActionScript();
                 * }*/
                return;

            /*case EventType.FileOpen:
             *      justOpenFile = true;
             *      return;*/

            case EventType.FileClose:
                DebugConsole.Trace("Close " + ASContext.MainForm.CurFile);
                this.pluginUI.RemoveFromView(ASContext.MainForm.CurFile);
                return;

            case EventType.SettingUpdate:
                ASContext.UpdateSettings();
                AS3.Flex2Shell.UpdateSettings();
                break;

            // some commands work all the time
            case EventType.Command:
                string command = ((TextEvent)e).Text;

                // add a custom classpath
                if (command.StartsWith("ASCompletion;ClassPath;"))
                {
                    int p = command.IndexOf(';', 15);
                    ASContext.ExternalClassPath = command.Substring(p + 1);
                    e.Handled = true;
                }

                // clear the classes cache
                else if (command.StartsWith("ASCompletion;ClearClassCache"))
                {
                    ClearClassCache(null, null);
                    e.Handled = true;
                }

                else if (command == "ASCompletion.SendContext")
                {
                    DataEvent de = new DataEvent(EventType.CustomData, "ASCompletion.Context", new ASContext());
                    MainForm.DispatchEvent(de);
                    e.Handled = true;
                }

                // call the Flash IDE
                else if (command.StartsWith("CallFlashIDE"))
                {
                    string flashexe = MainForm.MainSettings.GetValue(SETTING_MACROMEDIA_FLASHIDE);
                    if ((flashexe.Length == 0) || !System.IO.File.Exists(flashexe))
                    {
                        ErrorHandler.ShowInfo("The path to Flash.exe is not configured properly.");
                    }
                    // save modified files
                    this.mainForm.CallCommand("SaveAllModified", null);
                    // run the Flash IDE
                    if (command.IndexOf(';') > 0)
                    {
                        string args = MainForm.ProcessArgString(command.Substring(command.IndexOf(';') + 1));
                        if (args.IndexOf('"') < 0)
                        {
                            args = '"' + args + '"';
                        }
                        System.Diagnostics.Process.Start(flashexe, args);
                    }
                    else
                    {
                        System.Diagnostics.Process.Start(flashexe);
                    }
                    e.Handled = true;
                }

                // run the Flex 2 compilet
                else if (command.StartsWith("RunMxmlc;"))
                {
                    AS3.Flex2Shell.Instance.RunMxmlc(command.Substring(9));
                }
                break;
            }

            /**
             * Actionscript context specific
             */
            if ((sci.Lexer == 3) && ASContext.IsClassValid())
            {
                switch (e.Type)
                {
                case EventType.ProcessArgs:
                    TextEvent te  = (TextEvent)e;
                    string    cmd = te.Text;
                    if (cmd.IndexOf("@") > 0)
                    {
                        // resolve current element
                        Hashtable details = ASComplete.ResolveElement(sci, null);
                        // resolve current class details
                        if (details == null)
                        {
                            ASClass oClass = ASContext.CurrentClass;
                            details = new Hashtable();
                            details.Add("@CLASSDECL", ASClass.MemberDeclaration(oClass.ToASMember()));
                            int p = oClass.ClassName.LastIndexOf('.');
                            if (p > 0)
                            {
                                details.Add("@CLASSPACKAGE", oClass.ClassName.Substring(0, p));
                                details.Add("@CLASSNAME", oClass.ClassName.Substring(p + 1));
                            }
                            else
                            {
                                details.Add("@CLASSPACKAGE", "");
                                details.Add("@CLASSNAME", oClass.ClassName);
                            }
                            details.Add("@CLASSFULLNAME", oClass.ClassName);
                            details.Add("@MEMBERKIND", "");
                            details.Add("@MEMBERNAME", "");
                            details.Add("@MEMBERDECL", "");
                            details.Add("@MEMBERCLASSPACKAGE", "");
                            details.Add("@MEMBERCLASSNAME", "");
                            details.Add("@MEMBERCLASSFILE", "");
                            details.Add("@MEMBERCLASSDECL", "");
                        }
                        // complete command
                        foreach (string key in details.Keys)
                        {
                            cmd = cmd.Replace(key, (string)details[key]);
                        }
                        te.Text = cmd;
                    }
                    break;

                // menu commands
                case EventType.Command:
                    string command = ((TextEvent)e).Text;
                    DebugConsole.Trace(command);
                    if (command.StartsWith("ASCompletion;"))
                    {
                        // run MTASC
                        if (command.StartsWith("ASCompletion;MtascRun"))
                        {
                            int p = command.IndexOf(';', 15);
                            if (p > 15)
                            {
                                ASContext.RunMTASC(command.Substring(p + 1));
                            }
                            else
                            {
                                ASContext.RunMTASC("");
                            }
                            e.Handled = true;
                        }

                        // build the SWF using MTASC
                        else if (command.StartsWith("ASCompletion;MtascBuild"))
                        {
                            ASContext.BuildMTASC(false);
                            e.Handled = true;
                        }

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

                        // resolve element under cursor and send a CustomData event
                        else if (command.StartsWith("ASCompletion;ResolveElement;"))
                        {
                            int p = command.IndexOf(';', 15);
                            ASComplete.ResolveElement(sci, command.Substring(p + 1));
                            e.Handled = true;
                        }
                        else if (command.StartsWith("ASCompletion;MakeIntrinsic"))
                        {
                            int p = command.IndexOf(';', 15);
                            if (p > 15)
                            {
                                ASContext.MakeIntrinsic(command.Substring(p + 1));
                            }
                            else
                            {
                                ASContext.MakeIntrinsic(null);
                            }
                            e.Handled = true;
                        }
                    }
                    return;

                case EventType.ProcessEnd:
                    string result = ((TextEvent)e).Text;
                    ASContext.OnProcessEnd(result);
                    break;
                }
            }
        }