<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #copied {background-color:#ccccff;}
  tr.alt #copied {background-color:#bbbbf7;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="5">Commit in <b><tt>metaas/trunk/src</tt></b></td></tr>
<tr><td><tt>main/java/uk/co/badgersinfoil/metaas/dom/<a href="#file1">DocComment.java</a></tt> </td><td></td><td align="right" id="added">+5</td><td></td><td nowrap="nowrap" align="center">444 -&gt; 445</td></tr>
<tr class="alt"><td><tt>main/java/uk/co/badgersinfoil/metaas/impl/<a href="#file2">ASTDocComment.java</a></tt> </td><td></td><td align="right" id="added">+24</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center">444 -&gt; 445</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file3">ASTDocTag.java</a></tt> </td><td></td><td align="right" id="added">+4</td><td></td><td nowrap="nowrap" align="center">444 -&gt; 445</td></tr>
<tr class="alt"><td><tt>test/java/uk/co/badgersinfoil/metaas/<a href="#file4">DocCommentTests.java</a></tt> </td><td></td><td align="right" id="added">+44</td><td align="right" id="removed">-2</td><td nowrap="nowrap" align="center">444 -&gt; 445</td></tr>
<tr><td></td><td></td><td align="right" id="added">+77</td><td align="right" id="removed">-6</td><td></td></tr>
</table>
<small id="info">4 modified files</small><br />
<pre class="comment">
allow javadoc para-tags to be deleted, and improve the implementation of addParaTag()
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/dom</span><br />
<div class="fileheader"><big><b>DocComment.java</b></big> <small id="info">444 -&gt; 445</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/DocComment.java        2007-03-13 23:25:10 UTC (rev 444)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/DocComment.java        2007-03-13 23:27:34 UTC (rev 445)
@@ -166,6 +166,11 @@
</small></pre><pre class="diff" id="context">         public DocTag findFirstTag(String name);
 
         /**
</pre><pre class="diff" id="added">+         * Removes the given tag from this comment.
+         */
+        public void delete(DocTag tag);
+
+        /**
</pre><pre class="diff" id="context">          * Adds a tagged paragraph with the given tag-name and body text to
          * the end of this documentation comment.  The name should be given
          * without the '@'-prefix, and this will be added by metaas.
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/impl</span><br />
<div class="fileheader"><big><b>ASTDocComment.java</b></big> <small id="info">444 -&gt; 445</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTDocComment.java        2007-03-13 23:25:10 UTC (rev 444)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTDocComment.java        2007-03-13 23:27:34 UTC (rev 445)
@@ -11,6 +11,7 @@
</small></pre><pre class="diff" id="context"> import java.util.LinkedList;
 import uk.co.badgersinfoil.metaas.dom.DocComment;
 import uk.co.badgersinfoil.metaas.dom.DocTag;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.impl.antlr.ASTDot;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.impl.antlr.LinkedListToken;
 import uk.co.badgersinfoil.metaas.impl.antlr.LinkedListTree;
 import uk.co.badgersinfoil.metaas.impl.parser.javadoc.JavadocParser;
</pre><pre class="diff"><small id="info">@@ -70,6 +71,13 @@
</small></pre><pre class="diff" id="context">                 }
                 return null;
         }
</pre><pre class="diff" id="added">+        
+        public void delete(DocTag tag) {
+                LinkedListTree tagAST = ((ASTDocTag)tag).getAST();
+                int index = javadoc.getIndexOfChild(tagAST);
+                javadoc.deleteChild(index);
+                commitModifiedAST();
+        }
</pre><pre class="diff" id="context"> 
         public void addParaTag(String name, String body) {
                 DocCommentUtils.assertValidContent(body);
</pre><pre class="diff"><small id="info">@@ -80,11 +88,23 @@
</small></pre><pre class="diff" id="context">                         DocCommentUtils.setDocComment(ast, "\n "+tagname+" "+body+"\n");
                         javadoc = DocCommentUtils.buildJavadoc(ast);
                 } else {
</pre><pre class="diff" id="removed">-                        String comment = DocCommentUtils.getDocComment(ast);
-                        if (!comment.endsWith("\n")) {
-                                comment += "\n";  // TODO: match document line-ending format
</pre><pre class="diff" id="added">+                        LinkedListTree lastChild = javadoc.getLastChild();
+                        LinkedListTree para = DocCommentUtils.parseParaTag(tagname+" "+body);
+                        javadoc.addChildWithTokens(para);
+                        // the final NL token doesn't usually have a '*' in it
+                        // (as the end-of-comment provides on) so lets make
+                        // sure we find that and re-insert it at the new end
+                        // of the comment
+                        LinkedListTree trainingNL = null;
+                        int lastChildLast = lastChild.getChildCount()-1;
+                        lastChild.addChildWithTokens(ASTUtils.newAST(JavadocParser.NL, newline));
+                        if (lastChild.getChild(lastChildLast).getType() == JavadocParser.NL) {
+                                trainingNL = (LinkedListTree)lastChild.deleteChild(lastChildLast);
</pre><pre class="diff" id="context">                         }
</pre><pre class="diff" id="removed">-                        DocCommentUtils.setDocComment(ast, comment + tagname+" "+body);
</pre><pre class="diff" id="added">+                        if (trainingNL != null) {
+                                para.addChildWithTokens(trainingNL);
+                        }
+                        commitModifiedAST();
</pre><pre class="diff" id="context">                 }
         }
         
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/impl</span><br />
<div class="fileheader"><big><b>ASTDocTag.java</b></big> <small id="info">444 -&gt; 445</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTDocTag.java        2007-03-13 23:25:10 UTC (rev 444)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTDocTag.java        2007-03-13 23:27:34 UTC (rev 445)
@@ -21,6 +21,10 @@
</small></pre><pre class="diff" id="context">                 this.comment = comment;
                 this.ast = ast;
         }
</pre><pre class="diff" id="added">+        
+        public LinkedListTree getAST() {
+                return ast;
+        }
</pre><pre class="diff" id="context"> 
         public String getBodyString() {
                 StringBuffer result = new StringBuffer();
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname">metaas/trunk/src/test/java/uk/co/badgersinfoil/metaas</span><br />
<div class="fileheader"><big><b>DocCommentTests.java</b></big> <small id="info">444 -&gt; 445</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/java/uk/co/badgersinfoil/metaas/DocCommentTests.java        2007-03-13 23:25:10 UTC (rev 444)
+++ trunk/src/test/java/uk/co/badgersinfoil/metaas/DocCommentTests.java        2007-03-13 23:27:34 UTC (rev 445)
@@ -2,7 +2,7 @@
</small></pre><pre class="diff" id="context"> 
 import java.io.IOException;
 import java.io.StringWriter;
</pre><pre class="diff" id="removed">-
</pre><pre class="diff" id="added">+import java.util.Iterator;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASArg;
 import uk.co.badgersinfoil.metaas.dom.ASClassType;
 import uk.co.badgersinfoil.metaas.dom.ASCompilationUnit;
</pre><pre class="diff"><small id="info">@@ -10,7 +10,6 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASMethod;
 import uk.co.badgersinfoil.metaas.dom.DocTag;
 import uk.co.badgersinfoil.metaas.dom.Visibility;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.metaas.impl.ASTASClassType;
</pre><pre class="diff" id="context"> import junit.framework.TestCase;
 
 
</pre><pre class="diff"><small id="info">@@ -127,6 +126,7 @@
</small></pre><pre class="diff" id="context">         public void testReturnDocs() {
                 ASMethod meth = clazz.newMethod("test", Visibility.PUBLIC, "void");
                 assertNull(meth.getReturnDescriptionString());
</pre><pre class="diff" id="added">+                meth.setReturnDescription(null);  // should not fail
</pre><pre class="diff" id="context">                 meth.setReturnDescription("blah blah");
                 assertEquals("blah blah", meth.getReturnDescriptionString().trim());
         }
</pre><pre class="diff"><small id="info">@@ -136,4 +136,46 @@
</small></pre><pre class="diff" id="context">                 assertNotNull(doc);
                 assertNull(doc.getDescriptionString());
         }
</pre><pre class="diff" id="added">+
+        public void testFindTags() {
+                DocComment doc = clazz.getDocumentation();
+                doc.addParaTag("param", "arg0 blah");
+                doc.addParaTag("param", "arg1 blah blah");
+                doc.addParaTag("param", "arg2 blah blah blah");
+                Iterator i = doc.findTags("param");
+                assertTrue(i.hasNext());
+                assertTrue(((DocTag)i.next()).getBodyString().trim().startsWith("arg0"));
+                assertTrue(i.hasNext());
+                assertTrue(((DocTag)i.next()).getBodyString().trim().startsWith("arg1"));
+                assertTrue(i.hasNext());
+                assertTrue(((DocTag)i.next()).getBodyString().trim().startsWith("arg2"));
+        }
+
+        public void testDelete() {
+                DocComment doc = clazz.getDocumentation();
+                doc.setDescriptionString("boo\nfoo");
+                doc.addParaTag("param", "arg0 blah");
+                doc.addParaTag("param", "arg1 blah blah");
+                doc.addParaTag("param", "arg2 blah blah blah");
+                DocTag arg1 = null;
+                for (Iterator i=doc.findTags("param"); i.hasNext(); ) {
+                        DocTag tag = (DocTag)i.next();
+                        if (tag.getBodyString().trim().startsWith("arg1")) {
+                                arg1 = tag;
+                                break;
+                        }
+                }
+                assertNotNull(arg1);
+                doc.delete(arg1);
+                // check it's gone,
+                Iterator i = doc.findTags("param");
+                assertTrue(i.hasNext());
+                assertTrue(((DocTag)i.next()).getBodyString().trim().startsWith("arg0"));
+                assertTrue(i.hasNext());
+                assertTrue(((DocTag)i.next()).getBodyString().trim().startsWith("arg2"));
+//                doc.delete(doc.findFirstTag("param"));
+//                doc.delete(doc.findFirstTag("param"));
+//                i = doc.findTags();
+//                assertFalse(i.hasNext());
+        }
</pre><pre class="diff" id="context"> }
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.12</small></center>
</body></html>