maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r643859 - /maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
Date Wed, 02 Apr 2008 11:43:11 GMT
Author: hboutemy
Date: Wed Apr  2 04:43:10 2008
New Revision: 643859

URL: http://svn.apache.org/viewvc?rev=643859&view=rev
Log:
generate mode readable code

Modified:
    maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java

Modified: maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java?rev=643859&r1=643858&r2=643859&view=diff
==============================================================================
--- maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
(original)
+++ maven/plugin-tools/trunk/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginHelpGenerator.java
Wed Apr  2 04:43:10 2008
@@ -263,8 +263,8 @@
         writer.write( "    /** 80-character display buffer */" + LS );
         writer.write( "    private static final int DEFAULT_WIDTH = 80;" + LS );
         writer.write( LS );
-        writer.write( "    /** 4 indent spaces */" + LS );
-        writer.write( "    private static final String DEFAULT_INDENT = repeat( \" \", 2
);" + LS );
+        writer.write( "    /** 2 indent spaces */" + LS );
+        writer.write( "    private static final int DEFAULT_INDENT = 2;" + LS );
         writer.write( LS );
         writer.write( "    /**" + LS );
         writer.write( "     * If true, display all settable properies for each goal." + LS
);
@@ -300,11 +300,7 @@
                 StringUtils.escape( toText( descriptor.getDescription() ) ) : "No description
available.";
 
             writer.write( "        sb.append( \"" + goal + "\" ).append( \"\\n\" );" + LS
);
-            writer.write( "        for ( Iterator it = toLines( \"" + description + "\" ).iterator();
it.hasNext(); )"
-                + LS );
-            writer.write( "        {" + LS );
-            writer.write( "            sb.append( it.next().toString() ).append( \"\\n\"
);" + LS );
-            writer.write( "        }" + LS );
+            writer.write( "        appendDescription( sb, \"" + description + "\", DEFAULT_INDENT
);" + LS );
 
             if ( descriptor.getParameters() != null && descriptor.getParameters().size()
> 0 )
             {
@@ -337,17 +333,8 @@
                                 + ( StringUtils.isNotEmpty( parameter.getDefaultValue() )
? " (Default: '"
                                     + parameter.getDefaultValue() + "')" : "" );
 
-                            writer.write( "        for ( Iterator it = toLines( \"" + parameterDefaultValue
-                                + "\", repeat( \" \", 4 ), DEFAULT_WIDTH ).iterator(); it.hasNext();
)" + LS );
-                            writer.write( "        {" + LS );
-                            writer.write( "            sb.append( it.next().toString() ).append(
\"\\n\" );" + LS );
-                            writer.write( "        }" + LS );
-
-                            writer.write( "            for ( Iterator it = toLines( \"" +
parameterDescription
-                                + "\", repeat( \" \", 6 ), DEFAULT_WIDTH ).iterator(); it.hasNext();
)" + LS );
-                            writer.write( "            {" + LS );
-                            writer.write( "                sb.append( it.next().toString()
).append( \"\\n\" );" + LS );
-                            writer.write( "            }" + LS );
+                            writer.write( "            appendDescription( sb, \"" + parameterDefaultValue
+ "\", 4 );" + LS );
+                            writer.write( "            appendDescription( sb, \"" + parameterDescription
+ "\", 6 );" + LS );
                         }
                     }
                 }
@@ -363,11 +350,7 @@
         // TODO Should be discovered
         writer.write( "        sb.append( \"" + getFullHelpGoalName( pluginDescriptor ) +
"\" ).append( \"\\n\" );"
             + LS );
-        writer.write( "        for ( Iterator it = toLines( \"" + getHelpDescription( pluginDescriptor
)
-            + "\" ).iterator(); it.hasNext(); )" + LS );
-        writer.write( "        {" + LS );
-        writer.write( "            sb.append( it.next().toString() ).append( \"\\n\" );"
+ LS );
-        writer.write( "        }" + LS );
+        writer.write( "        appendDescription( sb, \"" + getHelpDescription( pluginDescriptor
) + "\", DEFAULT_INDENT );" + LS );
 
         writer.write( LS );
 
@@ -403,20 +386,6 @@
         writer.write( "    }" + LS );
         writer.write( LS );
         writer.write( "    /**" + LS );
-        writer.write( "     * <p>Give a list of lines for the <code>str</code>.
" + "Each line is indented by 4 spaces"
-            + LS );
-        writer.write( "     * and has a maximum of <code>80</code> characters.</p>"
+ LS );
-        writer.write( "     *" + LS );
-        writer.write( "     * @param str String to split in lines" + LS );
-        writer.write( "     * @return List of lines" + LS );
-        writer.write( "     * @throws NullPointerException if str is <code>null</code>"
+ LS );
-        writer.write( "     */" + LS );
-        writer.write( "    private static List toLines( String str )" + LS );
-        writer.write( "    {" + LS );
-        writer.write( "        return toLines( str, DEFAULT_INDENT, DEFAULT_WIDTH );" + LS
);
-        writer.write( "    }" + LS );
-        writer.write( LS );
-        writer.write( "    /**" + LS );
         writer
             .write( "     * <p>Give a list of lines for the <code>str</code>.
Each line is indented by <code>indent</code>"
                 + LS );
@@ -467,6 +436,14 @@
         writer.write( "        }" + LS );
         writer.write( LS );
         writer.write( "        return sentences;" + LS );
+        writer.write( "    }" + LS );
+        writer.write( LS );
+        writer.write( "    private static void appendDescription( StringBuffer sb, String
description, int indent )" + LS );
+        writer.write( "    {" + LS );
+        writer.write( "        for ( Iterator it = toLines( description, repeat( \" \", indent
), DEFAULT_WIDTH ).iterator(); it.hasNext(); )" + LS );
+        writer.write( "        {" + LS );
+        writer.write( "            sb.append( it.next().toString() ).append( \"\\n\" );"
+ LS );
+        writer.write( "        }" + LS );
         writer.write( "    }" + LS );
     }
 



Mime
View raw message