Beispiel #1
0
        public UmlClass(UmlBlock block)
            : base(block)
        {
            name = name.IfContains("class ", () => type = ClassType.Class);
            name = name.IfContains("struct ", () => type = ClassType.Struct);
            name = name.IfContains("interface ", () => type = ClassType.Interface);

            string[] p = name.Split(":");
            if (p.Length == 2)
            {
                name  = p [0].Trim();
                bases = p [1].Trim().Split(",").TrimAll().ToArray();
                if (bases.Length == 1 && bases [0].Length == 0)
                {
                    bases = new string[] {}
                }
                ;
            }
            else
            {
                bases = new string[] {};
            }

            Content = ParseContent(block.Content).ToArray();

            string _name = name;

            Packages.SplitName(_name, out Packages.CurrentPackage, out name);

            Comments.AddTo(commentsKey = Comments.Key(name), block.comments);
            Packages.AddToCurrentPackage(name);
        }
Beispiel #2
0
 public UmlObject(UmlBlock block)
     : this(block.Name)
 {
     name = name.IfContains("+ ", () => Publicity = Publicity.Public);
     name = name.IfContains("# ", () => Publicity = Publicity.Protected);
     name = name.IfContains("- ", () => Publicity = Publicity.Private);
 }
Beispiel #3
0
        public UmlAttribute(UmlBlock block, UmlClass classobj)
            : base(block)
        {
            if (name.Contains(":"))
            {
                string[] p = name.Split(":").TrimAll().ToArray();
                name = p [0];
                type = p [1];
            }

            Comments.AddTo(commentsKey = Comments.Key(classobj.Name, name), block.comments);
        }
Beispiel #4
0
        public UmlEnum(UmlBlock block)
            : base(block)
        {
            name   = name.IfContains("enum ", () => {});
            values = ParseContent(block.Content).ToArray();

            string _name = name;

            Packages.SplitName(_name, out Packages.CurrentPackage, out name);

            Comments.AddTo(commentsKey = Comments.Key(name), block.comments);
            Packages.AddToCurrentPackage(name);
        }
Beispiel #5
0
        private UmlBlock[] ParseBlocks(string[] lines, ref int i, int parentIndent)
        {
            int baseIndent = nextIndent(lines, i);

            List <UmlBlock> blocks = new List <UmlBlock> ();

            for (; i < lines.Length; ++i)
            {
                string line   = lines [i];
                int    indent = line.Indentation();
                // Console.WriteLine (indent + "  " + line + "  (" + baseIndent + ")");

                if (line.Trim().Contains("//"))
                {
                    //Console.WriteLine ("CurrentComments.add(" + line + ")");
                    Comments.AddParsedComment(line.TrimAll().Substring(2).TrimAll());
                }
                else if (indent < baseIndent)
                {
                    --i;
                    break;
                }
                else if (indent == baseIndent)
                {
                    UmlBlock block;
                    string[] comments = Comments.CurrentComments();
                    if (i + 1 < lines.Length && nextIndent(lines, i + 1) > indent)
                    {
                        i    += 1;
                        block = new UmlBlock(
                            name: line.TrimAll(),
                            content: ParseBlocks(lines, ref i, indent),
                            comments: comments
                            );
                    }
                    else
                    {
                        block = new UmlBlock(
                            name: line.TrimAll(),
                            comments: comments
                            );
                    }
                    blocks.Add(block);
                }
                else if (line.Trim().Length > 0)
                {
                    throw new InvalidOperationException("This should never happen! " + line);
                }
            }
            return(blocks.ToArray());
        }
Beispiel #6
0
        public UmlMethod(UmlBlock block, UmlClass classobj)
            : base(block)
        {
            parseParams();

            if (name.Contains(":"))
            {
                string[] p = name.Split(":").TrimAll().ToArray();
                name       = p [0];
                returntype = p [1];
            }
            else
            {
                returntype = "";
            }

            Comments.AddTo(commentsKey = Comments.Key(classobj.Name, name, parameters.Unique() + returntype),
                           block.comments);
        }
Beispiel #7
0
        public static bool Matches(UmlBlock block)
        {
            string line = block.Name;

            // index operator?
            if (line.Contains("this [") && line.Contains("]"))
            {
                return(false);
            }

            // normal method?
            int indexBracketOpen  = line.IndexOf("(");
            int indexBracketClose = line.IndexOf(")");

            if (indexBracketOpen == -1 && indexBracketClose == -1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #8
0
 public static bool Matches(UmlBlock block)
 {
     return(block.Name.Contains("enum"));
 }
Beispiel #9
0
 public static bool Matches(UmlBlock block)
 {
     return(block.Name.Contains("class ") || block.Name.Contains("struct ") || block.Name.Contains("interface "));
 }