Ejemplo n.º 1
0
        DocBlock ParseDocBlock(String javaFilePath,
                               String line)
        {
            bool IsEnd()
            {
                line = line.Trim();
                if (line.Trim().EndsWith("*/") == false)
                {
                    return(false);
                }
                line = line.Substring(line.Length - 2);
                return(true);
            }

            StringBuilder docLines = new StringBuilder();

            docLines.AppendLine(line);
            bool end = IsEnd();

            while (end == false)
            {
                line = lines[this.lineIndex++];
                end  = IsEnd();
                if (line.Length > 0)
                {
                    docLines.AppendLine(line);
                }
            }
            return(DocBlock.Parse(docLines.ToString()));
        }
Ejemplo n.º 2
0
        public override void ParseFile(String javaFilePath)
        {
            lastBlock      = null;
            lines          = File.ReadAllLines(javaFilePath);
            this.lineIndex = 0;

            while (this.lineIndex < lines.Length)
            {
                String line = lines[this.lineIndex++];
                String hdr  = LineHdr(ref line);

                switch (hdr)
                {
                case "/**":
                    lastBlock = ParseDocBlock(javaFilePath, line);
                    break;

                case "interface":
                case "class":
                case "record":
                    StartClass(hdr, GetWord(ref line));
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 3
0
 void StartClass(string type, String name)
 {
     if (this.lastBlock != null)
     {
         this.Docs.Add(name, this.lastBlock);
         this.lastBlock = null;
     }
 }
Ejemplo n.º 4
0
        bool ProcessJavaAttribute(SyntaxList <AttributeListSyntax> attListLists,
                                  ref SyntaxTriviaList sf)
        {
            if (JavaAttribute(attListLists, out String argumentValue) == false)
            {
                return(false);
            }

            DocBlock docBlock = this.csParser.GetBlock(argumentValue);

            if (docBlock == null)
            {
                Trace.WriteLine($"{argumentValue} contains no documentation");
                return(false);
            }

            List <String> textLines = new List <string>(docBlock.Text.ToString().Replace("\r", "").Split("\n"));

            while ((textLines.Count > 0) && (String.IsNullOrWhiteSpace(textLines[0])))
            {
                textLines.RemoveAt(0);
            }
            while ((textLines.Count > 0) && (String.IsNullOrWhiteSpace(textLines[textLines.Count - 1])))
            {
                textLines.RemoveAt(textLines.Count - 1);
            }
            if (textLines.Count == 0)
            {
                return(false);
            }

            StringBuilder sb = new StringBuilder();

            sb
            .AppendLine("/// <summary>")
            .AppendCommentLines(textLines)
            .AppendLine("/// </summary>")
            ;
            //sf = SyntaxFactory.Comment(sb.ToString());

            return(true);
        }
Ejemplo n.º 5
0
        public static DocBlock Parse(IEnumerable <String> javaDoc)
        {
            String[] lines  = javaDoc.ToArray();
            DocBlock retVal = new DocBlock();
            Int32    i      = 0;
            String   line;

            bool ParseAttributes()
            {
                String GetWord(String l,
                               out String restOfLine)
                {
                    l = l.Trim();

                    Int32 i = l.IndexOf(" ");

                    if (i < 0)
                    {
                        String retVal = l;
                        restOfLine = String.Empty;
                        return(retVal);
                    }

                    {
                        String retVal = l.Substring(0, i);
                        restOfLine = l.Substring(i);
                        return(retVal);
                    }
                }

                String blockTagName = GetWord(line, out String restOfLine);

                switch (blockTagName.Trim())
                {
                case "@author":
                    retVal.Author = restOfLine.Trim();
                    return(true);

                case "@param":
                    //retVal.Author = blockTagContent.ToString();
                    return(true);

                case "@return":
                    retVal.Return = restOfLine.Trim();
                    return(true);

                case "@throws":
                case "@version":
                case "@see":
                case "@since":
                case "@serial":
                case "@deprecated":
                    return(true);

                default:
                    return(false);
                }
            }

            while (i < lines.Length - 1)
            {
                line = lines[i++].Trim();
                if (line.StartsWith("*/"))
                {
                    return(retVal);
                }
                if (line.StartsWith("*"))
                {
                    line = line.Substring(1);
                }
                if (line.Trim().StartsWith("@"))
                {
                    if (ParseAttributes() == false)
                    {
                        retVal.Text.AppendLine(line);
                    }
                }
                else if ((line.Length > 0) || (retVal.Text.Length > 0))
                {
                    retVal.Text.AppendLine(line);
                }
            }
            return(retVal);
        }