예제 #1
0
        public void AddSource(Stream stm)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(stm);
            XmlNodeList    xnl = doc.GetElementsByTagName("symbols");
            XmlNode        n   = xnl[0];
            CompletionNode cn  = new CompletionNode();

            ParseNode(cn, n);
            if (cn.children != null)
            {
                foreach (CompletionNode x in cn.children)
                {
                    string name = x.display;
                    int    j    = 0;
                    foreach (CompletionNode cur in nodes)
                    {
                        if (cur.display == name)
                        {
                            nodes[j] = x;
                            continue;
                        }
                        j++;
                    }
                    nodes.Add(x);
                }
            }
            nodes.Sort(delegate(CompletionNode a, CompletionNode b)
            {
                return(a.display.CompareTo(b.display));
            });
            curr.children = nodes.ToArray();
        }
예제 #2
0
 public void Reset(SquirrelVersion squirrelVersion)
 {
     this.squirrelVersion = squirrelVersion;
     nodes = new List <CompletionNode>();
     curr  = new CompletionNode();
     AddKeywords();
 }
예제 #3
0
        private void AddKeyword(string name)
        {
            CompletionNode cn = new CompletionNode();

            cn.name  = cn.display = name;
            cn.glyph = (int)GlyphImageIndex.Keyword;
            cn.type  = "keyword";
            nodes.Add(cn);
        }
예제 #4
0
        void ParseNode(CompletionNode parent, XmlNode n)
        {
            if (n.ChildNodes.Count == 0)
            {
                return;
            }
            List <CompletionNode> nodes = new List <CompletionNode>();

            foreach (XmlNode xn in n.ChildNodes)
            {
                if (xn.NodeType == XmlNodeType.Element &&
                    xn.Name == "symbol")
                {
                    XmlElement     e    = (XmlElement)xn;
                    CompletionNode cn   = new CompletionNode();
                    string         name = e.GetAttribute("name");
                    cn.name    = name.ToLower();
                    cn.display = name;
                    cn.type    = e.GetAttribute("type");
                    cn.glyph   = GetImage(cn.type);
                    if (cn.type == "function")
                    {
                        cn.signature = e.GetAttribute("signature");
                        if (cn.signature.StartsWith("(") &&
                            cn.signature.EndsWith(")"))
                        {
                            string trimmed = cn.signature.Substring(1, cn.signature.Length - 2);
                            if (trimmed.IndexOf(',') != -1)
                            {
                                cn.parameters = trimmed.Split(new char[] { ',' });
                            }
                        }
                    }
                    nodes.Add(cn);
                    ParseNode(cn, xn);
                }
            }
            if (nodes.Count > 0)
            {
                nodes.Sort(delegate(CompletionNode a, CompletionNode b)
                {
                    return(a.display.CompareTo(b.display));
                });
                parent.children = nodes.ToArray();
            }
        }
예제 #5
0
        public int GetCandidates(List <CompletionNode> ret, String[] syms, int part, bool exactmatch)
        {
            if (children == null)
            {
                return(0);
            }
            int    len   = children.Length;
            int    found = 0;
            String s     = syms[part];

            for (int n = 0; n < len; n++)
            {
                CompletionNode cn = (CompletionNode)children[n];
                if (cn.name.StartsWith(s))
                {
                    int temp = found;

                    if (cn.name.Equals(s))
                    {
                        if (part < syms.Length - 1)
                        {
                            found += cn.GetCandidates(ret, syms, part + 1, exactmatch);
                        }

                        /*else
                         * {
                         *  //force all childrens to be in
                         *  found += cn.GetCandidates(ret, empty, 0);
                         * }*/
                    }
                    //add the parent only if no children were added
                    if (temp == found && cn.name.Equals(s) == exactmatch)
                    {
                        found++;
                        ret.Add(cn);
                    }
                }
            }
            return(found);
        }