Ejemplo n.º 1
0
        public void AnalyzeHeader(string HeaderContent)
        {
			Regex find_comments = new Regex(@"/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/", RegexOptions.ExplicitCapture);
			Regex find_class_definition = new Regex(@"class\s*([\w_:\.]+)\s*(?::\s*([^{]+)|class\s*([\w_:\.]+))?");

			int index = 0;
			while (index != -1)
			{
				//Search for the next ClassDefinition string
				index = HeaderContent.IndexOf(ClassDefinition, index);

				if (index != -1)
				{
					//We found one, let's check it out.
					//We first need to find just this line (no multiline definitions!)
					int line_end = HeaderContent.IndexOf('\n', index);
					//Now, we only need the arguments, so skip over the length of the ClassDefinition + 1 for the (
					int arg_start = index + ClassDefinition.Length + 1;
					string arguments = HeaderContent.Substring(arg_start, line_end - arg_start - 2);

					//Split the arguments into a list!
					var arg_list = this.ParseList(arguments);
					
					foreach (string x in arg_list)
					{
						
					//	Console.WriteLine(x.Trim());
					}

					index = line_end + 1;

					//Now let's find the associated class definition.
					var match = find_class_definition.Match(HeaderContent, index);
					Console.WriteLine(match.Success);
					if (match.Success)
					{
						current = new CodeClass();
						current.Name = match.Groups[1].Value;

						//Do we have an inheritance list?
						if (match.Groups.Count > 2)
						{
							var inherited_list = this.ParseList(match.Groups[2].Value);

							foreach (string parent_class in inherited_list)
							{
								CodeParentClass parent = new CodeParentClass();
								parent.Access = CodeAccessLevel.Private;

								//Does our string start with public?
								string p = parent_class.Trim();
								if (p.Substring(0, "public".Length) == "public")
								{
									parent.Access = CodeAccessLevel.Public;
									p = p.Substring("public".Length + 1);
								}
								if (p.Substring(0, "protected".Length) == "protected")
								{
									parent.Access = CodeAccessLevel.Private;
									p = p.Substring("protected".Length + 1);
								}
								if (p.Substring(0, "private".Length) == "private")
								{
									parent.Access = CodeAccessLevel.Private;
									p = p.Substring("private".Length + 1);
								}

								parent.Name = p.Trim();

								current.InheritsFrom.Add(parent);
							}
						}
					}
				}
			}
        }
Ejemplo n.º 2
0
        public void AnalyzeHeader(string HeaderContent)
        {
            Regex find_comments         = new Regex(@"/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/", RegexOptions.ExplicitCapture);
            Regex find_class_definition = new Regex(@"class\s*([\w_:\.]+)\s*(?::\s*([^{]+)|class\s*([\w_:\.]+))?");

            int index = 0;

            while (index != -1)
            {
                //Search for the next ClassDefinition string
                index = HeaderContent.IndexOf(ClassDefinition, index);

                if (index != -1)
                {
                    //We found one, let's check it out.
                    //We first need to find just this line (no multiline definitions!)
                    int line_end = HeaderContent.IndexOf('\n', index);
                    //Now, we only need the arguments, so skip over the length of the ClassDefinition + 1 for the (
                    int    arg_start = index + ClassDefinition.Length + 1;
                    string arguments = HeaderContent.Substring(arg_start, line_end - arg_start - 2);

                    //Split the arguments into a list!
                    var arg_list = this.ParseList(arguments);

                    foreach (string x in arg_list)
                    {
                        //	Console.WriteLine(x.Trim());
                    }

                    index = line_end + 1;

                    //Now let's find the associated class definition.
                    var match = find_class_definition.Match(HeaderContent, index);
                    Console.WriteLine(match.Success);
                    if (match.Success)
                    {
                        current      = new CodeClass();
                        current.Name = match.Groups[1].Value;

                        //Do we have an inheritance list?
                        if (match.Groups.Count > 2)
                        {
                            var inherited_list = this.ParseList(match.Groups[2].Value);

                            foreach (string parent_class in inherited_list)
                            {
                                CodeParentClass parent = new CodeParentClass();
                                parent.Access = CodeAccessLevel.Private;

                                //Does our string start with public?
                                string p = parent_class.Trim();
                                if (p.Substring(0, "public".Length) == "public")
                                {
                                    parent.Access = CodeAccessLevel.Public;
                                    p             = p.Substring("public".Length + 1);
                                }
                                if (p.Substring(0, "protected".Length) == "protected")
                                {
                                    parent.Access = CodeAccessLevel.Private;
                                    p             = p.Substring("protected".Length + 1);
                                }
                                if (p.Substring(0, "private".Length) == "private")
                                {
                                    parent.Access = CodeAccessLevel.Private;
                                    p             = p.Substring("private".Length + 1);
                                }

                                parent.Name = p.Trim();

                                current.InheritsFrom.Add(parent);
                            }
                        }
                    }
                }
            }
        }