code improvement
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1342976 13f79535-47bb-0310-9956-ffa450edef68master
parent
aa60192803
commit
b8269c2016
|
|
@ -178,12 +178,11 @@ public class HelpMojo
|
||||||
|
|
||||||
for ( Xpp3Dom parameter : parameters )
|
for ( Xpp3Dom parameter : parameters )
|
||||||
{
|
{
|
||||||
Xpp3Dom name = parameter.getChild( "name" );
|
String name = parameter.getChild( "name" ).getValue();
|
||||||
Xpp3Dom fieldConfigurationElement = configurationElement.getChild( name.getValue() );
|
Xpp3Dom fieldConfigurationElement = configurationElement.getChild( name );
|
||||||
if ( fieldConfigurationElement != null && fieldConfigurationElement.getValue() != null )
|
if ( fieldConfigurationElement != null && fieldConfigurationElement.getValue() != null )
|
||||||
{
|
{
|
||||||
append( sb, name.getValue() + " (default: " + configurationElement.getChild(
|
append( sb, name + " (default: " + configurationElement.getChild( name ).getAttribute( "default-value" ) + ")", 2 );
|
||||||
name.getValue() ).getAttribute( "default-value" ) + ")", 2 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
append( sb, parameter.getChild( "description" ).getValue(), 3 );
|
append( sb, parameter.getChild( "description" ).getValue(), 3 );
|
||||||
|
|
@ -234,9 +233,9 @@ public class HelpMojo
|
||||||
*/
|
*/
|
||||||
private void append( StringBuilder sb, String description, int indent )
|
private void append( StringBuilder sb, String description, int indent )
|
||||||
{
|
{
|
||||||
for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); )
|
for ( String line : toLines( description, indent, indentSize, lineLength ) )
|
||||||
{
|
{
|
||||||
sb.append( it.next().toString() ).append( '\n' );
|
sb.append( line ).append( '\n' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,15 +249,17 @@ public class HelpMojo
|
||||||
* @return The sequence of display lines, never <code>null</code>.
|
* @return The sequence of display lines, never <code>null</code>.
|
||||||
* @throws NegativeArraySizeException if <code>indent < 0</code>
|
* @throws NegativeArraySizeException if <code>indent < 0</code>
|
||||||
*/
|
*/
|
||||||
private static List toLines( String text, int indent, int indentSize, int lineLength )
|
private static List<String> toLines( String text, int indent, int indentSize, int lineLength )
|
||||||
{
|
{
|
||||||
List<String> lines = new ArrayList<String>();
|
List<String> lines = new ArrayList<String>();
|
||||||
|
|
||||||
String ind = repeat( "\t", indent );
|
String ind = repeat( "\t", indent );
|
||||||
|
|
||||||
String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" );
|
String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" );
|
||||||
for ( int i = 0; i < plainLines.length; i++ )
|
|
||||||
|
for ( String plainLine : plainLines )
|
||||||
{
|
{
|
||||||
toLines( lines, ind + plainLines[i], indentSize, lineLength );
|
toLines( lines, ind + plainLine, indentSize, lineLength );
|
||||||
}
|
}
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
|
|
@ -276,11 +277,12 @@ public class HelpMojo
|
||||||
{
|
{
|
||||||
int lineIndent = getIndentLevel( line );
|
int lineIndent = getIndentLevel( line );
|
||||||
StringBuilder buf = new StringBuilder( 256 );
|
StringBuilder buf = new StringBuilder( 256 );
|
||||||
|
|
||||||
String[] tokens = line.split( " +" );
|
String[] tokens = line.split( " +" );
|
||||||
for ( int i = 0; i < tokens.length; i++ )
|
|
||||||
|
for ( String token : tokens )
|
||||||
{
|
{
|
||||||
String token = tokens[i];
|
if ( buf.length() > 0 )
|
||||||
if ( i > 0 )
|
|
||||||
{
|
{
|
||||||
if ( buf.length() + token.length() >= lineLength )
|
if ( buf.length() + token.length() >= lineLength )
|
||||||
{
|
{
|
||||||
|
|
@ -293,6 +295,7 @@ public class HelpMojo
|
||||||
buf.append( ' ' );
|
buf.append( ' ' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int j = 0; j < token.length(); j++ )
|
for ( int j = 0; j < token.length(); j++ )
|
||||||
{
|
{
|
||||||
char c = token.charAt( j );
|
char c = token.charAt( j );
|
||||||
|
|
@ -336,6 +339,4 @@ public class HelpMojo
|
||||||
}
|
}
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue