maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r793739 - in /maven/plugins/trunk/maven-javadoc-plugin/src: main/java/org/apache/maven/plugin/javadoc/ test/java/org/apache/maven/plugin/javadoc/ test/resources/unit/fix-jdk5-test/expected/src/main/java/fix/test/ test/resources/unit/fix-jdk...
Date Mon, 13 Jul 2009 22:47:27 GMT
Author: vsiveton
Date: Mon Jul 13 22:47:26 2009
New Revision: 793739

URL: http://svn.apache.org/viewvc?rev=793739&view=rev
Log:
o take care of generic
o add test cases

Modified:
    maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-jdk5-test/expected/src/main/java/fix/test/ClassWithJavadoc.java
    maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-jdk5-test/src/main/java/fix/test/ClassWithJavadoc.java

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java?rev=793739&r1=793738&r2=793739&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java
(original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/main/java/org/apache/maven/plugin/javadoc/AbstractFixJavadocMojo.java
Mon Jul 13 22:47:26 2009
@@ -3105,7 +3105,8 @@
         String line;
         while ( ( line = lr.readLine() ) != null )
         {
-            if ( StringUtils.removeDuplicateWhitespace( line ).startsWith( " * @" ) )
+            if ( StringUtils.removeDuplicateWhitespace( line.trim() ).startsWith( "* @" )
+                || StringUtils.removeDuplicateWhitespace( line.trim() ).startsWith( "*@"
) )
             {
                 break;
             }
@@ -3160,22 +3161,33 @@
 
         String originalJavadoc = extractOriginalJavadocContent( javaClassContent, entity
);
 
+        String paramValue = docletTag.getParameters()[0];
+        if ( docletTag.getParameters().length > 3 && docletTag.getParameters()[0].trim().equals(
"<" )
+            && docletTag.getParameters()[2].trim().equals( ">" ) )
+        {
+            paramValue = "<" + docletTag.getParameters()[1] + ">";
+        }
+
         StringBuffer sb = new StringBuffer();
         BufferedReader lr = new BufferedReader( new StringReader( originalJavadoc ) );
         String line;
         boolean found = false;
         while ( ( line = lr.readLine() ) != null )
         {
-            if ( StringUtils.removeDuplicateWhitespace( line ).startsWith(
-                                                                           " * @" + docletTag.getName()
+ " "
-                                                                               + docletTag.getParameters()[0]
) )
+            if ( StringUtils.removeDuplicateWhitespace( line.trim() ).startsWith(
+                                                                                  "* @" +
docletTag.getName()
+                                                                                      + "
" + paramValue )
+                || StringUtils.removeDuplicateWhitespace( line.trim() ).startsWith(
+                                                                                    "*@"
+ docletTag.getName()
+                                                                                        +
" " + paramValue ) )
             {
                 sb.append( line ).append( EOL );
                 found = true;
             }
             else
             {
-                if ( StringUtils.removeDuplicateWhitespace( line ).startsWith( " * @" ) )
+                if ( StringUtils.removeDuplicateWhitespace( line.trim() ).startsWith( "*
@" )
+                    || StringUtils.removeDuplicateWhitespace( line.trim() ).startsWith( "*@"
) )
                 {
                     found = false;
                 }

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java?rev=793739&r1=793738&r2=793739&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java
(original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/java/org/apache/maven/plugin/javadoc/FixJavadocMojoTest.java
Mon Jul 13 22:47:26 2009
@@ -440,6 +440,85 @@
         assertTrue( withoutEmptyJavadocLines.endsWith( "any" ) );
     }
 
+    /**
+     * @throws Throwable if any
+     */
+    public void testJavadocCommentJdk5()
+        throws Throwable
+    {
+        if ( !SystemUtils.isJavaVersionAtLeast( 1.5f ) )
+        {
+            getContainer().getLogger().warn(
+                                             "JDK 5.0 or more is required to run fix for
'" + getClass().getName()
+                                                 + "#" + getName() + "()'." );
+            return;
+        }
+
+        String content = "/**" + EOL +
+                " * Dummy Class." + EOL +
+                " */" + EOL +
+                "public class DummyClass" + EOL +
+                "{" + EOL +
+                "    /**" + EOL +
+                "     * Dummy method." + EOL +
+                "     *" + EOL +
+                "     * @param <K>  The Key type for the method" + EOL +
+                "     * @param <V>  The Value type for the method" + EOL +
+                "     * @param name The name." + EOL +
+                "     * @return A map configured." + EOL +
+                "     */" + EOL +
+                "    public <K, V> java.util.Map<K, V> dummyMethod( String name
)" + EOL +
+                "    {" + EOL +
+                "        return null;" + EOL +
+                "    }" + EOL +
+                "}";
+
+        JavaDocBuilder builder = new JavaDocBuilder();
+        builder.setEncoding( "UTF-8" );
+        builder.addSource( new StringReader( content ) );
+
+        JavaClass[] classes = builder.getClasses();
+        JavaClass clazz = classes[0];
+
+        JavaMethod javaMethod = clazz.getMethods()[0];
+
+        String methodJavadoc =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "getJavadocComment",
new Class[] {
+                String.class, AbstractJavaEntity.class }, new Object[] { content, javaMethod
} );
+        assertEquals( "     * Dummy method." + EOL +
+                "     *", methodJavadoc );
+
+        assertEquals( 4, javaMethod.getTags().length );
+
+        DocletTag tag = javaMethod.getTags()[0];
+        String tagJavadoc =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "getJavadocComment",
new Class[] {
+                String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new
Object[] { content,
+                javaMethod, tag } );
+        assertEquals( "     * @param <K>  The Key type for the method", tagJavadoc
);
+
+        tag = javaMethod.getTags()[1];
+        tagJavadoc =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "getJavadocComment",
new Class[] {
+                String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new
Object[] { content,
+                javaMethod, tag } );
+        assertEquals( "     * @param <V>  The Value type for the method", tagJavadoc
);
+
+        tag = javaMethod.getTags()[2];
+        tagJavadoc =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "getJavadocComment",
new Class[] {
+                String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new
Object[] { content,
+                javaMethod, tag } );
+        assertEquals( "     * @param name The name.", tagJavadoc );
+
+        tag = javaMethod.getTags()[3];
+        tagJavadoc =
+            (String) PrivateAccessor.invoke( AbstractFixJavadocMojo.class, "getJavadocComment",
new Class[] {
+                String.class, AbstractInheritableJavaEntity.class, DocletTag.class }, new
Object[] { content,
+                javaMethod, tag } );
+        assertEquals( "     * @return A map configured.", tagJavadoc );
+    }
+
     // ----------------------------------------------------------------------
     // private methods
     // ----------------------------------------------------------------------

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-jdk5-test/expected/src/main/java/fix/test/ClassWithJavadoc.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-jdk5-test/expected/src/main/java/fix/test/ClassWithJavadoc.java?rev=793739&r1=793738&r2=793739&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-jdk5-test/expected/src/main/java/fix/test/ClassWithJavadoc.java
(original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-jdk5-test/expected/src/main/java/fix/test/ClassWithJavadoc.java
Mon Jul 13 22:47:26 2009
@@ -61,6 +61,19 @@
         return null;
     }
 
+    /**
+     * Dummy method.
+     *
+     * @param <K>  The Key type for the method
+     * @param <V>  The Value type for the method
+     * @param name The name.
+     * @return A map configured.
+     */
+    public <K, V> java.util.Map<K, V> dummyMethod( String name )
+    {
+        return null;
+    }
+
     // ----------------------------------------------------------------------
     // Inheritance
     // ----------------------------------------------------------------------

Modified: maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-jdk5-test/src/main/java/fix/test/ClassWithJavadoc.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-jdk5-test/src/main/java/fix/test/ClassWithJavadoc.java?rev=793739&r1=793738&r2=793739&view=diff
==============================================================================
--- maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-jdk5-test/src/main/java/fix/test/ClassWithJavadoc.java
(original)
+++ maven/plugins/trunk/maven-javadoc-plugin/src/test/resources/unit/fix-jdk5-test/src/main/java/fix/test/ClassWithJavadoc.java
Mon Jul 13 22:47:26 2009
@@ -51,6 +51,19 @@
         return null;
     }
 
+    /**
+     * Dummy method.
+     *
+     * @param <K>  The Key type for the method
+     * @param <V>  The Value type for the method
+     * @param name The name.
+     * @return A map configured.
+     */
+    public <K, V> java.util.Map<K, V> dummyMethod( String name )
+    {
+        return null;
+    }
+
     // ----------------------------------------------------------------------
     // Inheritance
     // ----------------------------------------------------------------------



Mime
View raw message