예제 #1
0
 /// <summary>
 /// Currently edited class. On set, synchronise CurrentClass.
 /// </summary>
 public FileModel SetCurrentFile(string fileName)
 {
     DebugConsole.Trace("Set '" + fileName + "'");
     // non-AS file
     if (fileName == null || fileName == "")
     {
         string nFile = MainForm.CurFile;
         if (doPathNormalization)
         {
             nFile = nFile.Replace(dirAltSeparator, dirSeparator);
         }
         cFile  = new FileModel(nFile);
         cClass = ClassModel.VoidClass;
     }
     // AS file
     else
     {
         string nFile = fileName;
         if (doPathNormalization)
         {
             nFile = nFile.Replace(dirAltSeparator, dirSeparator);
         }
         cFile  = PathModel.FindFile(nFile);
         cClass = cFile.GetPublicClass();
         DebugConsole.Trace("Parsed: " + cClass.ClassName);
         // update "this" and "super" special vars
         UpdateTopLevelElements();
     }
     if (Panel != null)
     {
         Panel.UpdateView(cFile);
     }
     return(cFile);
 }
예제 #2
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.Context.CurrentFile.FileName, 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)))
                    {
                        if (System.IO.File.Exists((string)classNode.Tag))
                        {
                            FileModel aFile = PathModel.FindFile((string)classNode.Tag);
                            ASContext.MainForm.OpenSelectedFile(aFile.FileName);
                        }
                    }
                    // 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);
            }
        }