Esempio n. 1
0
        public void LoadClassData(string filename)
        {
            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Enter - " + filename);
            _obj = new Hashtable();

            StreamReader reader   = new StreamReader(filename);
            string       fulldata = reader.ReadToEnd();

            reader.Close();

            Regex classes = new Regex(@"\s*class\s*(\b[A-Z_][A-Z0-9_]*\b)\s*(\:\s*public\s*(\b[A-Z][A-Z0-9]*\b)\s*)?\s*\{\s*(.*?)\};", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Multiline);

            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Loading classes");
            foreach (Match m in classes.Matches(fulldata))
            {
                // Define the object and declare their functions
                if (this._obj.ContainsKey(m.Groups[1].Value.ToLower()))
                {
                    continue;
                }

                ClassEntry cls = new ClassEntry();
                cls.ClassName         = m.Groups[1].Value;
                cls.ClassInheritsFrom = m.Groups[3].Value;

                // Run a regex on the list of functions
                Regex funcs = new Regex(@"(^\s*\/\*\!\s*(.*)\s*\*\/\n)?^\s*virtual\s*(void|bool|string|int|float|double)\s*(\b[A-Z_][A-Z0-9_]*)\s*\((.*)\)\s*\{\}\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline);

                foreach (Match func_m in funcs.Matches(m.Groups[4].Value))
                {
                    // Insert function data into the arraylists
                    if (cls.func_list.ContainsKey(func_m.Groups[4].Value.ToLower()))
                    {
                        continue;
                    }

                    ClassEntry.FuncEntry func = new ClassEntry.FuncEntry();
                    func.func_descr  = func_m.Groups[2].Value;
                    func.func_name   = func_m.Groups[4].Value;
                    func.func_ret    = func_m.Groups[3].Value;
                    func.func_params = func_m.Groups[5].Value;

                    cls.func_list.Add(func.func_name.ToLower(), func);
                }

                // ^\s*\/\*\!\s*\n\s*\*\/\n\s*(\b[A-Z_][A-Z0-9_]+\b)\s*(\b[A-Z_][A-Z0-9_]+\b)\s*\;\s*$

                // Pull the list of parameters next
                Regex param_list = new Regex(@"^\s*\/\*\!\s*(\n)?\s*\*\/(\n)?\s*(\b[A-Z_][A-Z0-9_]+\b)\s*(\b[A-Z_][A-Z0-9_]+\b)\s*\;\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline);

                foreach (Match param_m in param_list.Matches(m.Groups[4].Value))
                {
                    // Insert parameter data into the arraylists
                    if (cls.prop_list.ContainsKey(param_m.Groups[4].Value.ToLower()))
                    {
                        continue;
                    }

                    ClassEntry.PropEntry prop = new ClassEntry.PropEntry();
                    prop.prop_name = param_m.Groups[4].Value;
                    prop.prop_type = param_m.Groups[3].Value;

                    cls.prop_list.Add(prop.prop_name.ToLower(), prop);
                }

                this._obj.Add(m.Groups[1].Value.ToLower(), cls);
            }

            // Merge the inherited functions and properties into the list:
            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Merging inheritence tree");
            foreach (CAutoComplete.ClassEntry cls in this._obj.Values)
            {
                if (cls.ClassInheritsFrom != "")
                {
                    MergeInherited(cls, cls.ClassInheritsFrom);
                }
            }

            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Done");
        }
Esempio n. 2
0
        public void LoadClassData(string filename)
        {
            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Enter - " + filename);
            _obj = new Hashtable();

            StreamReader reader = new StreamReader(filename);
            string fulldata = reader.ReadToEnd();
            reader.Close();

            Regex classes = new Regex(@"\s*class\s*(\b[A-Z_][A-Z0-9_]*\b)\s*(\:\s*public\s*(\b[A-Z][A-Z0-9]*\b)\s*)?\s*\{\s*(.*?)\};", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Multiline);

            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Loading classes");
            foreach(Match m in classes.Matches(fulldata)) {
                // Define the object and declare their functions
                if (this._obj.ContainsKey(m.Groups[1].Value.ToLower()))
                    continue;

                ClassEntry cls = new ClassEntry();
                cls.ClassName = m.Groups[1].Value;
                cls.ClassInheritsFrom = m.Groups[3].Value;

                // Run a regex on the list of functions
                Regex funcs = new Regex(@"(^\s*\/\*\!\s*(.*)\s*\*\/\n)?^\s*virtual\s*(void|bool|string|int|float|double)\s*(\b[A-Z_][A-Z0-9_]*)\s*\((.*)\)\s*\{\}\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline);

                foreach(Match func_m in funcs.Matches(m.Groups[4].Value)) {
                    // Insert function data into the arraylists
                    if (cls.func_list.ContainsKey(func_m.Groups[4].Value.ToLower()))
                        continue;

                    ClassEntry.FuncEntry func = new ClassEntry.FuncEntry();
                    func.func_descr = func_m.Groups[2].Value;
                    func.func_name = func_m.Groups[4].Value;
                    func.func_ret = func_m.Groups[3].Value;
                    func.func_params = func_m.Groups[5].Value;

                    cls.func_list.Add(func.func_name.ToLower(), func);
                }

                // ^\s*\/\*\!\s*\n\s*\*\/\n\s*(\b[A-Z_][A-Z0-9_]+\b)\s*(\b[A-Z_][A-Z0-9_]+\b)\s*\;\s*$

                // Pull the list of parameters next
                Regex param_list = new Regex(@"^\s*\/\*\!\s*(\n)?\s*\*\/(\n)?\s*(\b[A-Z_][A-Z0-9_]+\b)\s*(\b[A-Z_][A-Z0-9_]+\b)\s*\;\s*$", RegexOptions.IgnoreCase | RegexOptions.Multiline);

                foreach(Match param_m in param_list.Matches(m.Groups[4].Value)) {
                    // Insert parameter data into the arraylists
                    if (cls.prop_list.ContainsKey(param_m.Groups[4].Value.ToLower()))
                        continue;

                    ClassEntry.PropEntry prop = new ClassEntry.PropEntry();
                    prop.prop_name = param_m.Groups[4].Value;
                    prop.prop_type = param_m.Groups[3].Value;

                    cls.prop_list.Add(prop.prop_name.ToLower(), prop);
                }

                this._obj.Add(m.Groups[1].Value.ToLower(), cls);
            }

            // Merge the inherited functions and properties into the list:
            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Merging inheritence tree");
            foreach(CAutoComplete.ClassEntry cls in this._obj.Values) {
                if (cls.ClassInheritsFrom != "")
                    MergeInherited(cls, cls.ClassInheritsFrom);
            }

            g.LogDebug("CAUTOCOMPLETE::LoadClassData: Done");
        }