예제 #1
0
        public AutocompleteItems GetFilteredList(string type)
        {
            AutocompleteItems list = new AutocompleteItems();

            type = type.ToLower();
            foreach (var item in this)
            {
                if (item.Type.ToLower() == type)
                {
                    list.Add(item);
                }
            }
            return(list);
        }
예제 #2
0
        private static void BuildAutocompleteItemsFromResourse(string file, int imageIndex, string toolTipText, AutocompleteItems itemsList, DefKind kind)
        {
            string   section  = "";
            string   filter   = "";
            Assembly assembly = Assembly.GetExecutingAssembly();
            Stream   stream   = assembly.GetManifestResourceStream(file);

            try {
                using (StreamReader reader = new StreamReader(stream)) {
                    stream = null; string line; HMSItem item = null; Match m;
                    while ((line = reader.ReadLine()) != null)
                    {
                        m = Regex.Match(line, @"^\*\s*?\[(.*)\]"); if (m.Success)
                        {
                            section = m.Groups[1].Value.Trim(); continue;
                        }
                        m = Regex.Match(line, @"^\*sm\w+\s*?<(.*?)>"); if (m.Success)
                        {
                            filter = m.Groups[1].Value.Trim(); continue;
                        }
                        if (filter == "-")
                        {
                            continue;
                        }
                        if (line.StartsWith("*") || (line.Trim().Length == 0))
                        {
                            continue;                                                    // Skip comments and blank lines
                        }
                        int indent = line.Length - line.TrimStart().Length;
                        if (indent == 0)
                        {
                            item             = GetHmsItemFromLine(line);
                            item.ImageIndex  = imageIndex;
                            item.ToolTipText = toolTipText + ((section.Length > 0) ? (" (" + section + ")") : "");
                            item.Kind        = kind;
                            item.Filter      = filter;
                            if (kind == DefKind.Function)
                            {
                                item.Kind = (item.Type.Length > 0) ? DefKind.Function : DefKind.Procedure;
                            }
                            itemsList.Add(item);
                        }
                        else if ((indent == 2) || (line[0] == '\t'))
                        {
                            // it's help for parameters of last method
                            if (itemsList.Count > 0)
                            {
                                item = itemsList[itemsList.Count - 1];
                                item.Params.Add(StylishHelp(line));
                            }
                        }
                    }
                }
            } catch (Exception e) {
                HMS.LogError(e.ToString());
            } finally {
                if (stream != null)
                {
                    stream.Dispose();
                }
            }
        }