Ejemplo n.º 1
0
        public bool insertFunction(TreeIndex index, String name)
        {
            if (name == "")
            {
                return(false);
            }
            if (index.type != IndexTypes.Page && index.type != IndexTypes.Folder)
            {
                String bpath;
                if (index.type == IndexTypes.Module)
                {
                    bpath = Path.GetDirectoryName(index.path);
                }
                else
                {
                    bpath = index.path;
                }
                FuncParser parser = new FuncParser(index.path);
                parser[name] = $@"
### Function **{name}**()

";
                parser.reSave();

                tree.addNode(index.tree_path, name, IndexTypes.Function, index.path);
                editor.openFile(index.path, name, IndexTypes.Function);
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 2
0
        private void loadFunctions(String place, String real_path)
        {
            FuncParser parser = new FuncParser(real_path);

            foreach (String name in parser.getFunctions().Keys)
            {
                log.info("Loading function at " + real_path);

                tree.addNode(place, name, IndexTypes.Function, real_path);
            }
        }
Ejemplo n.º 3
0
        public bool deleteNode(TreeIndex index, String name)
        {
            editor.closeFile();

            switch (index.type)
            {
            case IndexTypes.Class: {
                File.Delete(index.path);

                tree.removeNode(index);
                break;
            }

            case IndexTypes.Page: {
                File.Delete(index.path);
                tree.removeNode(index);
                break;
            }

            case IndexTypes.Module: {
                String bpath;
                if (index.type == IndexTypes.Module)
                {
                    bpath = Path.GetDirectoryName(index.path);
                }
                else
                {
                    bpath = index.path;
                }
                System.IO.DirectoryInfo di = new DirectoryInfo(bpath);

                foreach (FileInfo file in di.GetFiles())
                {
                    file.Delete();
                }
                foreach (DirectoryInfo dir in di.GetDirectories())
                {
                    dir.Delete(true);
                }
                di.Delete();
                tree.removeNode(index);

                break;
            }

            case IndexTypes.Folder: {
                System.IO.DirectoryInfo di = new DirectoryInfo(index.path);

                foreach (FileInfo file in di.GetFiles())
                {
                    file.Delete();
                }
                foreach (DirectoryInfo dir in di.GetDirectories())
                {
                    dir.Delete(true);
                }
                di.Delete();
                tree.removeNode(index);

                break;
            }

            case IndexTypes.Function: {
                FuncParser parser = new FuncParser(index.path);
                parser.functions.Remove(index.label);
                parser.reSave();
                tree.removeNode(index);
                break;
            }
            }
            return(false);
        }