protected AutocompleteInfo[] FromPythonType(AutocompleteInput input)
        {
            List<AutocompleteInfo> ret = new List<AutocompleteInfo>();

            string dirCommand = "dir(" + input.name + ")";
            object value = engine.CreateScriptSourceFromString(dirCommand, SourceCodeKind.Expression).Execute(this.scope);

            foreach (object member in (value as IronPython.Runtime.List))
            {
                string member_str = (string)member;

                if (input.have_filter && !member_str.StartsWith (input.filter))
                    continue;

                AutocompleteInfo temp = new AutocompleteInfo();
                temp.name = input.name;
                temp.stub = member_str;
                temp.complete = member_str.Substring (input.filter.Length);

                ret.Add(temp);
            }

            if (ret.Count != 0 && ret.Count != 1) {
                string common_starter = this.GetCommonStarter (ret.ToArray ());
                AutocompleteInfo temp = ret [0];
                temp.common_starter = common_starter;

                temp.common_starter_complete = common_starter.Substring (input.filter.Length);

                ret [0] = temp;
            }

            return ret.ToArray();
        }
        AutocompleteInput AnalyzeInput(string input)
        {
            AutocompleteInput ret = new AutocompleteInput ();

            string text = input.Replace("\t", "   ");

            char[] start_index_chars = {' ', '(', '-', '+', ',', '*', '=', '&'};

            int startIndex = -1;

            foreach (char c in start_index_chars)
            {
                int temp_index = text.LastIndexOf(c);

                if (temp_index > startIndex)
                    startIndex = temp_index;
            }

            int end_index = input.LastIndexOf ('.');

            if (end_index == -1) {
                ret.name = string.Empty;
                ret.filter = input.Substring(startIndex + 1);
                ret.have_filter = true;
            } else {
                ret.name = text.Substring (startIndex + 1, (end_index) - (startIndex + 1));

                ret.raw_input = input;
                ret.filter = input.Substring (end_index + 1);
                ret.have_filter = true;

                if (ret.filter == string.Empty) {
                    ret.have_filter = false;
                }
            }

            return ret;
        }
        protected AutocompleteInfo[] FromCLRType(Type type, AutocompleteInput input)
        {
            List<AutocompleteInfo> ret = new List<AutocompleteInfo>();

            List<string> completionsList = new List<string> ();
            MethodInfo[] methodInfo = type.GetMethods ();
            PropertyInfo[] propertyInfo = type.GetProperties ();
            FieldInfo[] fieldInfo = type.GetFields ();
            foreach (MethodInfo methodInfoItem in methodInfo) {
                if ((methodInfoItem.IsPublic)
                    && (methodInfoItem.Name.IndexOf ("get_") != 0) && (methodInfoItem.Name.IndexOf ("set_") != 0)
                    && (methodInfoItem.Name.IndexOf ("add_") != 0) && (methodInfoItem.Name.IndexOf ("remove_") != 0)
                    && (methodInfoItem.Name.IndexOf ("__") != 0))
                    completionsList.Add (methodInfoItem.Name);
            }
            foreach (PropertyInfo propertyInfoItem in propertyInfo) {
                completionsList.Add (propertyInfoItem.Name);
            }
            foreach (FieldInfo fieldInfoItem in fieldInfo) {
                completionsList.Add (fieldInfoItem.Name);
            }
            completionsList.Sort ();
            string last = "";
            for (int i = completionsList.Count - 1; i > 0; --i) {
                if (completionsList [i] == last)
                    completionsList.RemoveAt (i);
                else
                    last = completionsList [i];
            }

            foreach (string completion in completionsList) {
                if (input.have_filter && !completion.StartsWith (input.filter))
                    continue;

                AutocompleteInfo temp = new AutocompleteInfo();
                temp.name = input.name;
                temp.stub = completion;
                temp.complete = completion.Substring (input.filter.Length);
                ret.Add (temp);
            }

            if (ret.Count != 0 && ret.Count != 1) {
                string common_starter = this.GetCommonStarter (ret.ToArray ());
                AutocompleteInfo temp = ret [0];
                temp.common_starter = common_starter;

                temp.common_starter_complete = common_starter.Substring (input.filter.Length);

                ret [0] = temp;
            }

            return ret.ToArray ();
        }