Ejemplo n.º 1
0
        private void ContextChanged()
        {
            ITabbedDocument doc     = PluginBase.MainForm.CurrentDocument;
            bool            isValid = false;

            if (doc.IsEditable)
            {
                ScintillaControl sci = ASContext.CurSciControl;
                if (currentDoc == doc.FileName && sci != null)
                {
                    int line = sci.LineFromPosition(currentPos);
                    ASContext.SetCurrentLine(line);
                }
                else
                {
                    ASComplete.CurrentResolvedContext = null;  // force update
                }
                isValid = ASContext.Context.IsFileValid;
                if (isValid)
                {
                    ASComplete.ResolveContext(sci);
                }
            }
            else
            {
                ASComplete.ResolveContext(null);
            }

            bool enableItems = isValid && !doc.IsUntitled;

            pluginUI.OutlineTree.Enabled = ASContext.Context.CurrentModel != null;
            SetItemsEnabled(enableItems, ASContext.Context.CanBuild);
        }
Ejemplo n.º 2
0
        public void FixtureSetUp()
        {
#pragma warning disable CS0436 // Type conflicts with imported type
            mainForm = new MainForm();
#pragma warning restore CS0436 // Type conflicts with imported type
            settings                 = Substitute.For <ISettings>();
            settings.UseTabs         = true;
            settings.IndentSize      = 4;
            settings.SmartIndentType = SmartIndent.CPP;
            settings.TabIndents      = true;
            settings.TabWidth        = 4;
            doc = Substitute.For <ITabbedDocument>();
            mainForm.Settings        = settings;
            mainForm.CurrentDocument = doc;
            mainForm.Documents       = new[] { doc };
            mainForm.StandaloneMode  = true;
            PluginBase.Initialize(mainForm);
            FlashDevelop.Managers.ScintillaManager.LoadConfiguration();

            var pluginMain   = Substitute.For <PluginMain>();
            var pluginUiMock = new PluginUIMock(pluginMain);
            pluginMain.MenuItems.Returns(new List <System.Windows.Forms.ToolStripItem>());
            pluginMain.Settings.Returns(new GeneralSettings());
            pluginMain.Panel.Returns(pluginUiMock);
            ASContext.GlobalInit(pluginMain);
            ASContext.Context = Substitute.For <IASContext>();

            sci = GetBaseScintillaControl();
            doc.SciControl.Returns(sci);
        }
Ejemplo n.º 3
0
 private void DetectContext()
 {
     current = ASContext.Context;
     if (PluginBase.CurrentProject != null)
     {
         current = ASContext.GetLanguageContext(PluginBase.CurrentProject.Language);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Menu item command: Quick MTASC Build
 /// </summary>
 public void QuickMTASCBuild(object sender, System.EventArgs e)
 {
     if (ASContext.CurrentClass.IsAS3 || System.IO.Path.GetExtension(mainForm.CurFile) == ".mxml")
     {
         AS3.Flex2Shell.Instance.QuickBuild(mainForm.CurFile);
     }
     else
     {
         ASContext.BuildMTASC(false);
     }
 }
Ejemplo n.º 5
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);
         }
     }
 }
Ejemplo n.º 6
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);
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * Initializes the plugin
  */
 public void Initialize()
 {
     try
     {
         InitSettings();
         CreatePanel();
         CreateMenuItems();
         AddEventHandlers();
         ASContext.GlobalInit(this);
         ModelsExplorer.CreatePanel();
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(/*"Failed to initialize the completion engine.\n"+ex.Message,*/ ex);
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Init completion engine context
        /// </summary>
        /// <param name="mainForm">Reference to MainForm</param>
        static public void Init(PluginMain pluginMain)
        {
            dirSeparatorChar    = System.IO.Path.DirectorySeparatorChar;
            dirSeparator        = dirSeparatorChar.ToString();
            dirAltSeparatorChar = System.IO.Path.AltDirectorySeparatorChar;
            dirAltSeparator     = dirAltSeparatorChar.ToString();
            doPathNormalization = dirSeparator != dirAltSeparator;
            //
            ASContext.plugin = pluginMain;
            try
            {
                context = new Contexts.Actionscript2();
                ASFileParser.Context = context;
                context.Init();
            }
            catch (Exception ex)
            {
                ErrorHandler.ShowError("Failed to initialize context.\n" + ex.Message, ex);
            }

            // documentation
            if (!MainForm.MainSettings.HasKey(SETTING_DOCUMENTATION_COMPLETION))
            {
                MainForm.MainSettings.AddValue(SETTING_DOCUMENTATION_COMPLETION, "true");
            }
            if (!MainForm.MainSettings.HasKey(SETTING_DOCUMENTATION_TAGS))
            {
                MainForm.MainSettings.AddValue(SETTING_DOCUMENTATION_TAGS, ASDocumentation.DEFAULT_DOC_TAGS);
            }
            if (!MainForm.MainSettings.HasKey(SETTING_DOCUMENTATION_TIPS))
            {
                MainForm.MainSettings.AddValue(SETTING_DOCUMENTATION_TIPS, "true");
            }
            if (!MainForm.MainSettings.HasKey(SETTING_DOCUMENTATION_DESCRIPTION))
            {
                MainForm.MainSettings.AddValue(SETTING_DOCUMENTATION_DESCRIPTION, "true");
            }

            // debugging enabled?
            DebugConsole.CheckSettings();

            // status
            UnLock();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Some .AS file has changed
        /// </summary>
        public void OnFileChanged(object sender, System.IO.FileSystemEventArgs e)
        {
            // this event comes in on a separate thread
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new System.IO.FileSystemEventHandler(this.OnFileChanged), new object[] { sender, e });
            }
            else
            {
                // repeated event fix
                long   ts   = System.DateTime.Now.Ticks;
                string file = e.FullPath;
                if ((ts - lastChangeTimeStamp < 100) && (file == lastChangeFile))
                {
                    return;
                }
                lastChangeFile      = file;
                lastChangeTimeStamp = ts;

                // check AS class
                ASContext.TrackFileChanged(file);
            }
        }
Ejemplo n.º 10
0
 private void OnTextChanged(ScintillaNet.ScintillaControl sender, int position, int length, int linesAdded)
 {
     ASComplete.OnTextChanged(sender, position, length, linesAdded);
     ASContext.OnTextChanged(sender, position, length, linesAdded);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Clear and rebuild classpath models cache
 /// </summary>
 private void RebuildClasspath(object sender, System.EventArgs e)
 {
     ASContext.RebuildClasspath();
 }
Ejemplo n.º 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;
                    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);
            }
        }
Ejemplo n.º 13
0
		/// <summary>
		/// Init completion engine context
		/// </summary>
		/// <param name="mainForm">Reference to MainForm</param>
		static public void Init(PluginMain pluginMain)
		{
			dirSeparatorChar = System.IO.Path.DirectorySeparatorChar;
			dirSeparator = dirSeparatorChar.ToString();
			dirAltSeparatorChar = System.IO.Path.AltDirectorySeparatorChar;
			dirAltSeparator = dirAltSeparatorChar.ToString();
			doPathNormalization = dirSeparator != dirAltSeparator;
			//
			ASContext.plugin = pluginMain;
			try
			{
				context = new Contexts.Actionscript2();
				ASFileParser.Context = context;
				context.Init();
			}
			catch(Exception ex)
			{
				ErrorHandler.ShowError("Failed to initialize context.\n"+ex.Message, ex);
			}
			
			// documentation
			if (!MainForm.MainSettings.HasKey(SETTING_DOCUMENTATION_COMPLETION))
				MainForm.MainSettings.AddValue(SETTING_DOCUMENTATION_COMPLETION, "true");
			if (!MainForm.MainSettings.HasKey(SETTING_DOCUMENTATION_TAGS))
				MainForm.MainSettings.AddValue(SETTING_DOCUMENTATION_TAGS, ASDocumentation.DEFAULT_DOC_TAGS);
			if (!MainForm.MainSettings.HasKey(SETTING_DOCUMENTATION_TIPS))
				MainForm.MainSettings.AddValue(SETTING_DOCUMENTATION_TIPS, "true");
			if (!MainForm.MainSettings.HasKey(SETTING_DOCUMENTATION_DESCRIPTION))
				MainForm.MainSettings.AddValue(SETTING_DOCUMENTATION_DESCRIPTION, "true");
			
			// debugging enabled?
			DebugConsole.CheckSettings();
			
			// status
			UnLock();
		}
Ejemplo n.º 14
0
 private void RebuildButton_Click(object sender, EventArgs e)
 {
     outlineTreeView.Nodes.Clear();
     ASContext.RebuildClasspath();
 }
Ejemplo n.º 15
0
        private void delayedClassTreeSelect(Object sender, System.Timers.ElapsedEventArgs e)
        {
            TreeNode node = classTree.SelectedNode;

            if (node == null)
            {
                return;
            }
            try
            {
                // class node
                if (node.Parent == null)
                {
                    if (node.Tag != null)
                    {
                        ASContext.MainForm.OpenSelectedFile((string)node.Tag);
                    }
                }

                // group node
                else if (node.Nodes.Count > 0)
                {
                    node.Toggle();
                }

                // leaf node
                else if ((node.Parent != null) && (node.Parent.Tag == null))
                {
                    TreeNode classNode = node.Parent.Parent;
                    ScintillaNet.ScintillaControl sci = ASContext.MainForm.CurSciControl;
                    // for Back command:
                    if (sci != null)
                    {
                        SetLastLookupPosition(ASContext.CurrentFile, sci.CurrentPos);
                    }
                    //
                    int index = node.Parent.Index;
                    // extends
                    if (showExtend && index == 0)
                    {
                        if (node.Tag != null)
                        {
                            ASContext.MainForm.OpenSelectedFile((string)node.Tag);
                        }
                    }
                    // import
                    else if (showImports && ((showExtend && index == 1) || (!showExtend && index == 0)))
                    {
                        ASClass aClass = ASContext.FindClassFromFile((string)classNode.Tag);
                        if (aClass.IsVoid())
                        {
                            return;
                        }
                        ASContext.OpenFileFromClass(node.Text, aClass);
                    }
                    // members
                    else if (node.Tag != null)
                    {
                        ASContext.MainForm.OpenSelectedFile((string)classNode.Tag);
                        sci = ASContext.MainForm.CurSciControl;
                        if (sci == null)
                        {
                            return;
                        }
                        // look for declaration
                        string pname = Regex.Escape((string)node.Tag);
                        Match  m     = null;
                        switch (node.ImageIndex)
                        {
                        case 12:                                 // method
                        case 3:
                            m = Regex.Match(sci.Text, "function[\\s]+(?<pname>" + pname + ")[\\s]*\\(");
                            break;

                        case 13:                                 // property
                        case 4:
                            m = Regex.Match(sci.Text, "function[\\s]+(?<pname>(g|s)et[\\s]+" + pname + ")[\\s]*\\(");
                            break;

                        case 14:                                 // variables
                        case 5:
                            m = Regex.Match(sci.Text, "var[\\s]+(?<pname>" + pname + ")[^\\w]");
                            break;
                        }
                        // show
                        if (m != null && m.Success)
                        {
                            GotoPosAndFocus(sci, m.Groups["pname"].Index);
                            sci.SetSel(sci.CurrentPos, sci.CurrentPos + m.Groups["pname"].Length);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.ShowError(ex.Message, ex);
            }
        }
Ejemplo n.º 16
0
        /**
         * Handles the incoming events
         */
        public void HandleEvent(object sender, NotifyEvent e)
        {
            try
            {
                if (e.Type != EventType.UIRefresh)
                {
                    DebugConsole.Trace("*** " + e.Type.ToString());
                }

                // context busy?
                if (ASContext.Locked)
                {
                    DebugConsole.Trace("ASContext is busy");

                    if (e.Type == EventType.Command)
                    {
                        string command = ((TextEvent)e).Text;

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

                // editor ready?
                ScintillaNet.ScintillaControl sci = ASContext.MainForm.CurSciControl;
                if (sci == null)
                {
                    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.Context.CurrentClass.IsVoid();
                    // toolbar
                    isValid = ASContext.Context.IsFileValid();
                    this.SetItemsEnabled(isValid);
                    if (isValid)
                    {
                        if (ASContext.Context.CheckOnSave)
                        {
                            AutoCheckActionScript();
                        }
                        ASContext.Context.RemoveClassCompilerCache();
                    }
                    return;

                case EventType.LanguageChange:
                case EventType.FileSwitch:
                    DebugConsole.Trace("Switch to " + ASContext.MainForm.CurFile);

                    // check file
                    if (sci.ConfigurationLanguage == "as2" && !ASContext.MainForm.CurDocIsUntitled())
                    {
                        ASContext.Context.SetCurrentFile(ASContext.MainForm.CurFile);
                    }
                    else
                    {
                        ASContext.Context.SetCurrentFile("");
                    }

                    // toolbar
                    isValid = ASContext.Context.IsFileValid();
                    DebugConsole.Trace("Valid? " + isValid);
                    return;

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

                case EventType.SettingUpdate:
                    ASContext.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.SetExternalClassPath(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.StartsWith("ASCompletion;SendContext"))
                    {
                        int    p      = command.IndexOf(';', 15);
                        string wanted = command.Substring(p + 1);
                        if (wanted == "as2")
                        {
                            DataEvent de = new DataEvent(EventType.CustomData, "ASCompletion.Context", ASContext.Context);
                            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;
                    }
                    break;
                }

                /**
                 * Actionscript context specific
                 */
                if ((sci.Lexer == 3) && ASContext.Context.IsFileValid())
                {
                    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)
                            {
                                ClassModel oClass = ASContext.Context.CurrentClass;
                                details = new Hashtable();
                                details.Add("@CLASSDECL", ClassModel.MemberDeclaration(oClass.ToMemberModel()));
                                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.Context.RunCMD(command.Substring(p + 1));
                                }
                                else
                                {
                                    ASContext.Context.RunCMD("");
                                }
                                e.Handled = true;
                            }

                            // build the SWF using MTASC
                            else if (command.StartsWith("ASCompletion;MtascBuild"))
                            {
                                ASContext.Context.BuildCMD(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.Context.MakeIntrinsic(command.Substring(p + 1));
                                }
                                else
                                {
                                    ASContext.Context.MakeIntrinsic(null);
                                }
                                e.Handled = true;
                            }
                        }
                        return;

                    case EventType.ProcessEnd:
                        string result = ((TextEvent)e).Text;
                        ASContext.Context.OnProcessEnd(result);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.ShowError(ex.Message, ex);
            }
        }
Ejemplo n.º 17
0
        private void SafeInit()
        {
            this.mainForm = this.pluginHost.MainForm;
            this.pluginUI = new PluginUI();
            System.Drawing.Image image = this.mainForm.GetSystemImage(46);

            /**
             *  Create panel
             */
            this.pluginUI.Tag  = "ActionScript";
            this.pluginUI.Text = "ActionScript";
            this.pluginPanel   = mainForm.CreateDockingPanel(this.pluginUI, this.pluginGuid, image, DockState.DockRight);

            /**
             * Default shortcuts
             */
            if (!MainForm.MainSettings.HasKey(SETTING_SHORTCUT_CHECK))
            {
                MainForm.MainSettings.AddValue(SETTING_SHORTCUT_CHECK, "F7");
            }
            if (!MainForm.MainSettings.HasKey(SETTING_SHORTCUT_BUILD))
            {
                MainForm.MainSettings.AddValue(SETTING_SHORTCUT_BUILD, "CtrlF8");
            }
            if (!MainForm.MainSettings.HasKey(SETTING_SHORTCUT_GOTO))
            {
                MainForm.MainSettings.AddValue(SETTING_SHORTCUT_GOTO, "F4");
            }
            if (!MainForm.MainSettings.HasKey(SETTING_SHORTCUT_BACK))
            {
                MainForm.MainSettings.AddValue(SETTING_SHORTCUT_BACK, "ShiftF4");
            }
            if (!MainForm.MainSettings.HasKey(SETTING_SHORTCUT_CLEARCACHE))
            {
                MainForm.MainSettings.AddValue(SETTING_SHORTCUT_CLEARCACHE, "CtrlF7");
            }

            /**
             *  Create menu items
             */
            menuItems = new ArrayList();
            CommandBarItem item;
            CommandBarMenu menu = mainForm.GetCBMenu("ViewMenu");

            menu.Items.AddButton(image, "&ActionScript Panel", new EventHandler(this.OpenPanel));
            Keys k;

            // tools items
            menu = this.mainForm.GetCBMenu("FlashToolsMenu");
            if (menu != null)
            {
                menu.Items.AddSeparator();

                // clear class cache
                k = MainForm.MainSettings.GetShortcut(SETTING_SHORTCUT_CLEARCACHE);
                if (k != Keys.None)
                {
                    this.mainForm.IgnoredKeys.Add(k);
                }
                else
                {
                    ErrorHandler.ShowInfo("Settings Error: Invalid Shortcut (" + MainForm.MainSettings.GetValue(SETTING_SHORTCUT_CLEARCACHE) + ")");
                }
                menu.Items.AddButton("&Clear Class Cache", new EventHandler(this.ClearClassCache), k);

                // convert to intrinsic
                item = menu.Items.AddButton("Convert To &Intrinsic", new EventHandler(this.MakeIntrinsic));
                menuItems.Add(item);

                // check actionscript
                image = this.pluginUI.treeIcons.Images[11];
                k     = MainForm.MainSettings.GetShortcut(SETTING_SHORTCUT_CHECK);
                if (k != Keys.None)
                {
                    this.mainForm.IgnoredKeys.Add(k);
                }
                else
                {
                    ErrorHandler.ShowInfo("Settings Error: Invalid Shortcut (" + MainForm.MainSettings.GetValue(SETTING_SHORTCUT_CHECK) + ")");
                }
                item = menu.Items.AddButton(image, "Check &ActionScript", new EventHandler(this.CheckActionScript), k);
                menuItems.Add(item);

                // quick MTASC build
                image = this.pluginUI.treeIcons.Images[10];
                k     = MainForm.MainSettings.GetShortcut(SETTING_SHORTCUT_BUILD);
                if (k != Keys.None)
                {
                    this.mainForm.IgnoredKeys.Add(k);
                }
                else
                {
                    ErrorHandler.ShowInfo("Settings Error: Invalid Shortcut (" + MainForm.MainSettings.GetValue(SETTING_SHORTCUT_BUILD) + ")");
                }
                item = menu.Items.AddButton(image, "&Quick Build", new EventHandler(this.QuickBuild), k);
                menuItems.Add(item);
            }
            else
            {
                ErrorHandler.ShowInfo("MainMenu Error: no 'FlashToolsMenu' group found");
            }

            // toolbar items
            CommandBar toolbar = MainForm.GetCBToolbar();

            if (toolbar != null)
            {
                toolbar.Items.AddSeparator();
                // check
                image = this.pluginUI.treeIcons.Images[11];
                item  = toolbar.Items.AddButton(image, "Check ActionScript", new EventHandler(this.CheckActionScript));
                menuItems.Add(item);

                // build
                image = this.pluginUI.treeIcons.Images[10];
                item  = toolbar.Items.AddButton(image, "Quick Build", new EventHandler(this.QuickBuild));
                menuItems.Add(item);
            }

            // search items
            menu = this.mainForm.GetCBMenu("SearchMenu");
            if (menu != null)
            {
                menu.Items.AddSeparator();

                // goto back from declaration
                image = this.mainForm.GetSystemImage(18);
                k     = MainForm.MainSettings.GetShortcut(SETTING_SHORTCUT_BACK);
                if (k != Keys.None)
                {
                    this.mainForm.IgnoredKeys.Add(k);
                }
                else
                {
                    ErrorHandler.ShowInfo("Settings Error: Invalid Shortcut (" + MainForm.MainSettings.GetValue(SETTING_SHORTCUT_BACK) + ")");
                }
                item = menu.Items.AddButton(image, "&Back From Declaration", new EventHandler(this.BackDeclaration), k);
                menuItems.Add(item);

                // goto declaration
                image = this.mainForm.GetSystemImage(17);
                k     = MainForm.MainSettings.GetShortcut(SETTING_SHORTCUT_GOTO);
                if (k != Keys.None)
                {
                    this.mainForm.IgnoredKeys.Add(k);
                }
                else
                {
                    ErrorHandler.ShowInfo("Settings Error: Invalid Shortcut (" + MainForm.MainSettings.GetValue(SETTING_SHORTCUT_GOTO) + ")");
                }
                item = menu.Items.AddButton(image, "Goto &Declaration", new EventHandler(this.GotoDeclaration), k);
                menuItems.Add(item);
            }
            else
            {
                ErrorHandler.ShowInfo("MainMenu Error: no 'SearchMenu' group found");
            }

            /**
             *  Initialize completion context
             */
            sciReferences = new ArrayList();
            ASContext.Init(this);
            UITools.OnCharAdded     += new UITools.CharAddedHandler(OnChar);
            InfoTip.OnMouseHover    += new InfoTip.MouseHoverHandler(OnMouseHover);
            UITools.OnTextChanged   += new UITools.TextChangedHandler(ASContext.OnTextChanged);
            InfoTip.OnUpdateCallTip += new InfoTip.UpdateCallTipHandler(OnUpdateCallTip);
            this.mainForm.IgnoredKeys.Add(Keys.Control | Keys.Enter);
            this.mainForm.IgnoredKeys.Add(Keys.F1);

            /**
             *  Path to the Flash IDE
             */
            if (!MainForm.MainSettings.HasKey(SETTING_MACROMEDIA_FLASHIDE))
            {
                string found = "";
                foreach (string flashexe in MACROMEDIA_FLASHIDE_PATH)
                {
                    if (System.IO.File.Exists(flashexe))
                    {
                        found = flashexe;
                        break;
                    }
                }
                MainForm.MainSettings.AddValue(SETTING_MACROMEDIA_FLASHIDE, found);
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Menu item command: Clear the class cache
 /// </summary>
 public void ClearClassCache(object sender, System.EventArgs e)
 {
     ASContext.BuildClassPath();
 }
Ejemplo n.º 19
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);
            }
        }