Example #1
0
        public UmlEnum(CSharpBlock block)
            : base(block)
        {
            name = name.IfContains ("enum ", () => {});
            values = ParseContent (block.Content).ToArray ();

            commentsKey = Comments.Key (name);
            Packages.AddToCurrentPackage (name);
        }
Example #2
0
        public UmlAttribute(CSharpBlock block, UmlClass classobj)
            : base(block)
        {
            name = name.Split ('=') [0].TrimAll ();

            if (name.Contains (" ")) {
                string[] p = name.CleanGenerics ()
                    .Split (new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);
                type = p [0];
                name = "";
                for (int i = 0; i < p.Length; ++i) {
                    name += i == 0 ? "" : " " + p [i];
                }
            }
            name = name.TrimAll ();

            commentsKey = Comments.Key (classobj.Name, name);
        }
Example #3
0
 public CSharpBlock[] Parse(char[] chars, ref int i)
 {
     List<CSharpBlock> blocks = new List<CSharpBlock> ();
     string desc = "";
     int inBrackets = 0;
     for (; i < chars.Length; ++i) {
         char c = chars [i];
         if (c == '(')
             ++inBrackets;
         else if (c == ')')
             --inBrackets;
         if (c == '{' && inBrackets == 0) {
             desc = desc.Split (new string[]{ ": base" }, StringSplitOptions.None) [0];
             desc = desc.TrimAll ();
             //if (desc.Count () > 0) {
             ++i;
             CSharpBlock block = new CSharpBlock (
                     name: desc,
                     content: Parse (chars, ref i)
             );
             blocks.Add (block);
             desc = "";
         } else if (c == '}' && inBrackets == 0) {
             desc = desc.TrimAll ();
             break;
         } else if (c == ';' && inBrackets == 0) {
             desc = desc.Split (new string[]{ ": base" }, StringSplitOptions.None) [0];
             desc = desc.TrimAll ();
             if (desc.Count () > 0) {
                 CSharpBlock block = new CSharpBlock (name: desc);
                 blocks.Add (block);
                 desc = "";
             }
         } else {
             desc += c;
         }
     }
     desc = desc.TrimAll ();
     if (desc.Count () > 0) {
         CSharpBlock block = new CSharpBlock (name: desc);
         blocks.Add (block);
     }
     return blocks.ToArray ();
 }
Example #4
0
        public static bool Matches(CSharpBlock 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 (")");
            int indexEqualSign = line.IndexOf ("=");
            if (indexBracketOpen == -1 && indexBracketClose == -1) {
                return true;
            } else if (indexEqualSign < indexBracketOpen) {
                return true;
            } else {
                return false;
            }
        }
Example #5
0
        public UmlMethod(CSharpBlock block, UmlClass classobj)
            : base(block)
        {
            parseParams ();

            if (name.Contains (" ")) {
                string[] p = name.CleanGenerics ()
                    .Split (new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);
                returntype = p [0];
                name = "";
                for (int i = 0; i < p.Length; ++i) {
                    name += i == 0 ? "" : " " + p [i];
                }
            }
            if (name == "") {
                name = returntype;
                returntype = "";
            }
            if (returntype == "void")
                returntype = "";
            name = name.TrimAll ();

            commentsKey = Comments.Key (classobj.Name, name, parameters.Unique () + returntype);
        }
Example #6
0
        private void AddBlockChildNodes(BlockSyntax node, string memberName)
        {
            CSharpBlock codeBlock = null;

            foreach (var blockChildNode in node.ChildNodes())
            {
                if (blockChildNode.HasLeadingTrivia)
                {
                    var trivia = blockChildNode.GetLeadingTrivia();

                    // inside method multiline comment
                    AddMultiLineDocumentationComment(trivia, () =>
                    {
                        // flush what we may have collected so far
                        if (codeBlock != null)
                        {
                            Blocks.Add(codeBlock);
                            codeBlock = null;
                        }
                    });

                    if (blockChildNode.ShouldBeHidden(trivia))
                    {
                        continue;
                    }

                    if (blockChildNode.ShouldBeConvertedToJson(trivia))
                    {
                        string json;
                        if (blockChildNode.TryGetJsonForSyntaxNode(out json))
                        {
                            // flush what we may have collected so far
                            if (codeBlock != null)
                            {
                                Blocks.Add(codeBlock);
                                codeBlock = null;
                            }

                            var startingLine = blockChildNode.StartingLine();
                            Blocks.Add(new JavaScriptBlock(json, startingLine, ClassDepth, memberName));
                            continue;
                        }
                    }
                }

                if (codeBlock == null)
                {
                    codeBlock = new CSharpBlock(blockChildNode, ClassDepth, memberName);
                }
                else
                {
                    codeBlock.AddNode(blockChildNode);
                }

                if (blockChildNode.HasTrailingTrivia)
                {
                    var trivia = blockChildNode.GetTrailingTrivia();
                    AddMultiLineDocumentationComment(trivia, () =>
                    {
                        // flush what we may have collected so far
                        if (codeBlock != null)
                        {
                            Blocks.Add(codeBlock);
                            codeBlock = null;
                        }
                    });
                }
            }

            if (codeBlock != null)
            {
                Blocks.Add(codeBlock);
            }
        }
Example #7
0
 public static bool Matches(CSharpBlock block)
 {
     return block.Name.Contains ("enum");
 }
Example #8
0
 public UmlObject(CSharpBlock block)
     : this(block.Name)
 {
 }