Esempio n. 1
0
		static public int ParseCacheFile(PathModel inPath, string file)
		{
			parentPath = inPath;
			ParseFile(file);
			parentPath = null;
			return 0;
		}
Esempio n. 2
0
		/// <summary>
		/// Retrieve a PathModel from the cache or create a new one
		/// </summary>
		/// <param name="path"></param>
		/// <returns></returns>
		static public PathModel GetModel(string path)
		{
			PathModel aPath = pathes[path.ToUpper()] as PathModel;
			if (aPath == null)
			{
				pathes[path.ToUpper()] = aPath = new PathModel(path);
			}
			aPath.Touch();
			return aPath;
		}
Esempio n. 3
0
        private void ConvertToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = outlineTreeView.SelectedNode;

            if (node == null || current == null || current.Classpath == null)
            {
                return;
            }

            ResolvedPath resolved = ResolvePath(node);
            string       package  = resolved.package;
            PathModel    thePath  = resolved.model;

            if (thePath == null)
            {
                return;
            }

            if (node is TypeTreeNode)
            {
                string    filename = (node.Tag as string).Split('@')[0];
                FileModel theModel = thePath.GetFile(filename);
                if (theModel == null)
                {
                    return;
                }

                saveFileDialog.Title      = TextHelper.GetString("Title.SaveIntrinsicAs");
                saveFileDialog.FileName   = Path.GetFileName(filename);
                saveFileDialog.DefaultExt = Path.GetExtension(filename);
                if (PluginBase.CurrentProject != null)
                {
                    saveFileDialog.InitialDirectory = Path.GetDirectoryName(PluginBase.CurrentProject.ProjectPath);
                }
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        WriteIntrinsic(theModel, saveFileDialog.FileName);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                    }
                }
            }
            else
            {
                folderBrowserDialog.ShowNewFolderButton    = true;
                folderBrowserDialog.UseDescriptionForTitle = true;
                folderBrowserDialog.Description            = TextHelper.GetString("Title.SelectIntrinsicTargetFolder");
                if (PluginBase.CurrentProject != null)
                {
                    folderBrowserDialog.SelectedPath = Path.GetDirectoryName(PluginBase.CurrentProject.ProjectPath);
                }
                if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        string sourcePath = Path.Combine(thePath.Path, package.Replace('.', Path.DirectorySeparatorChar));
                        string targetPath = folderBrowserDialog.SelectedPath + Path.DirectorySeparatorChar;
                        string packagep   = (package.Length > 0) ? package + "." : "";

                        thePath.ForeachFile((aModel) =>
                        {
                            if (aModel.Package == package || aModel.Package.StartsWithOrdinal(packagep))
                            {
                                if (aModel.FileName.StartsWithOrdinal(sourcePath))
                                {
                                    WriteIntrinsic(aModel, aModel.FileName.Replace(sourcePath, targetPath));
                                }
                            }
                            return(true);
                        });
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                    }
                }
            }
        }
Esempio n. 4
0
		static public string BuildLogFileName(PathModel aPath)
		{
			string clean = System.Text.RegularExpressions.Regex.Replace(aPath.Path, "[\\:]+", "")+".as";
			return ASContext.MainForm.LocalDataPath+clean;
		}
Esempio n. 5
0
        static public string BuildLogFileName(PathModel aPath)
        {
            string clean = System.Text.RegularExpressions.Regex.Replace(aPath.Path, "[\\:]+", "") + ".as";

            return(ASContext.MainForm.LocalDataPath + clean);
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
0
		public PathModel AddPath(PathModel path)
		{
			// avoid duplicated pathes
			string upath = path.Path.ToUpper();
			foreach(PathModel apath in classPath)
			{
				if (apath.Path.ToUpper() == upath)
						return apath;
			}
			// add new path
			classPath.Add(path);
			return path;
		}