Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–44 unchanged (44 lines)
45 private final Map values = new HashMap();
46 private final Map switches = new HashMap();
47 private final Map defaultValues = new HashMap();
48 private final Map defaultSwitches = new HashMap();
49 private final List normalised;
50 private final Set prefixes;
51
52 /**
53 * Creates a new WriteableCommandLineImpl rooted on the specified Option, to
54 * hold the parsed arguments.
55 *
56 * @param rootOption the CommandLine's root Option
57 * @param arguments the arguments this CommandLine represents
58 */
59 public WriteableCommandLineImpl(final Option rootOption,
60 final List arguments) {
61 this.prefixes = rootOption.getPrefixes();
62 this.normalised = arguments;
63 }
64
65
66
67 public void addOption(Option option) {
68 options.add(option);
69 nameToOption.put(option.getPreferredName(), option);
70
…lines 71–227 unchanged (157 lines)
228 *
229 * @param trigger the command line element to test
230 * @return a flag whether this element seems to be an option
231 */
232 public boolean looksLikeOption(final String trigger)
233 {
234 // this is a reentrant call
235
236 for (final Iterator i = prefixes.iterator(); i.hasNext();)
237 {
238 final String prefix = (String) i.next();
239
240 if (trigger.startsWith(prefix))
241 {
242 return true;
243 }
244 }
245 return false;
246 }
247
248 public String toString() {
249 final StringBuffer buffer = new StringBuffer();
250
251 // need to add group header
252 for (final Iterator i = normalised.iterator(); i.hasNext();) {
…lines 253–299 unchanged (47 lines)

After

…lines 1–44 unchanged (44 lines)
45 private final Map values = new HashMap();
46 private final Map switches = new HashMap();
47 private final Map defaultValues = new HashMap();
48 private final Map defaultSwitches = new HashMap();
49 private final List normalised;
50 private final Set prefixes;
51 private Option currentOption;
52 private String checkForOption;
53
54 /**
55 * Creates a new WriteableCommandLineImpl rooted on the specified Option, to
56 * hold the parsed arguments.
57 *
58 * @param rootOption the CommandLine's root Option
59 * @param arguments the arguments this CommandLine represents
60 */
61 public WriteableCommandLineImpl(final Option rootOption,
62 final List arguments) {
63 this.prefixes = rootOption.getPrefixes();
64 this.normalised = arguments;
65 setCurrentOption(rootOption);
66 }
67
68 public Option getCurrentOption() {
69 return currentOption;
70 }
71
72 public void setCurrentOption(Option currentOption) {
73 this.currentOption = currentOption;
74 }
75
76 public void addOption(Option option) {
77 options.add(option);
78 nameToOption.put(option.getPreferredName(), option);
79
80 for (Iterator i = option.getTriggers().iterator(); i.hasNext();) {
…lines 81–236 unchanged (156 lines)
237 *
238 * @param trigger the command line element to test
239 * @return a flag whether this element seems to be an option
240 */
241 public boolean looksLikeOption(final String trigger)
242 {
243 if (checkForOption != null)
244 {
245 // this is a reentrant call
246 return !checkForOption.equals(trigger);
247 }
248
249 checkForOption = trigger;
250 try
251 {
252 for (final Iterator i = prefixes.iterator(); i.hasNext();)
253 {
254 final String prefix = (String) i.next();
255
256 if (trigger.startsWith(prefix))
257 {
258 if (getCurrentOption().canProcess(this, trigger)
259 || getCurrentOption().findOption(trigger) != null)
260 {
261 return true;
262 }
263 }
264 }
265
266 return false;
267 }
268 finally
269 {
270 checkForOption = null;
271 }
272 }
273
274 public String toString() {
275 final StringBuffer buffer = new StringBuffer();
276
277 // need to add group header
…lines 278–325 unchanged (48 lines)

Before

program
block_comment "/*\n * Licensed to the Apache Software Foundation (ASF) under"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "commandline"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "ArrayList"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Collections"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashMap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Iterator"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Properties"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Set"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "Argument"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "Option"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "WriteableCommandLine"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "option"
. "."
identifier "PropertyOption"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "resource"
. "."
identifier "ResourceConstants"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "resource"
. "."
identifier "ResourceHelper"
; ";"
block_comment "/**\n * A WriteableCommandLine implementation allowing Option"...
class_declaration
modifiers
public "public"
class "class"
identifier "WriteableCommandLineImpl"
superclass
extends "extends"
type_identifier "CommandLineImpl"
super_interfaces
implements "implements"
type_list
type_identifier "WriteableCommandLine"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Map"
variable_declarator
identifier "optionToProperties"
= "="
object_creation_expression
new "new"
type_identifier "HashMap"
argument_list
( "("
) ")"
; ";"
line_comment "// private final Properties properties = new Properties()"...
field_declaration
modifiers
private "private"
final "final"
type_identifier "List"
variable_declarator
identifier "options"
= "="
object_creation_expression
new "new"
type_identifier "ArrayList"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Map"
variable_declarator
identifier "nameToOption"
= "="
object_creation_expression
new "new"
type_identifier "HashMap"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Map"
variable_declarator
identifier "values"
= "="
object_creation_expression
new "new"
type_identifier "HashMap"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Map"
variable_declarator
identifier "switches"
= "="
object_creation_expression
new "new"
type_identifier "HashMap"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Map"
variable_declarator
identifier "defaultValues"
= "="
object_creation_expression
new "new"
type_identifier "HashMap"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Map"
variable_declarator
identifier "defaultSwitches"
= "="
object_creation_expression
new "new"
type_identifier "HashMap"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "List"
variable_declarator
identifier "normalised"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Set"
variable_declarator
identifier "prefixes"
; ";"
block_comment "/**\n * Creates a new WriteableCommandLineImpl rooted on "...
constructor_declaration
modifiers
public "public"
identifier "WriteableCommandLineImpl"
formal_parameters
( "("
formal_parameter
modifiers
final "final"
type_identifier "Option"
identifier "rootOption"
, ","
formal_parameter
modifiers
final "final"
type_identifier "List"
identifier "arguments"
) ")"
constructor_body
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "prefixes"
= "="
method_invocation
identifier "rootOption"
. "."
identifier "getPrefixes"
argument_list
( "("
) ")"
; ";"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "normalised"
= "="
identifier "arguments"
; ";"
} "}"
method_declaration (+154 nodes collapsed)
method_declaration (+105 nodes collapsed)
method_declaration (+99 nodes collapsed)
method_declaration (+36 nodes collapsed)
method_declaration (+31 nodes collapsed)
method_declaration (+242 nodes collapsed)
method_declaration (+59 nodes collapsed)
method_declaration (+97 nodes collapsed)
method_declaration (+32 nodes collapsed)
method_declaration (+93 nodes collapsed)
method_declaration (+39 nodes collapsed)
method_declaration (+75 nodes collapsed)
method_declaration (+70 nodes collapsed)
method_declaration (+25 nodes collapsed)
block_comment "/**\n * Tests whether the passed in trigger looks like an"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "looksLikeOption"
formal_parameters
( "("
formal_parameter
modifiers
final "final"
type_identifier "String"
identifier "trigger"
) ")"
block
{ "{"
line_comment "// this is a reentrant call"
for_statement
for "for"
( "("
local_variable_declaration
modifiers
final "final"
type_identifier "Iterator"
variable_declarator
identifier "i"
= "="
method_invocation
identifier "prefixes"
. "."
identifier "iterator"
argument_list
( "("
) ")"
; ";"
method_invocation
identifier "i"
. "."
identifier "hasNext"
argument_list
( "("
) ")"
; ";"
) ")"
block
{ "{"
local_variable_declaration
modifiers
final "final"
type_identifier "String"
variable_declarator
identifier "prefix"
= "="
cast_expression
( "("
type_identifier "String"
) ")"
method_invocation
identifier "i"
. "."
identifier "next"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
identifier "trigger"
. "."
identifier "startsWith"
argument_list
( "("
identifier "prefix"
) ")"
) ")"
block
{ "{"
return_statement
return "return"
true "true"
; ";"
} "}"
} "}"
return_statement
return "return"
false "false"
; ";"
} "}"
method_declaration (+173 nodes collapsed)
method_declaration (+22 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration (+60 nodes collapsed)
method_declaration (+60 nodes collapsed)
method_declaration (+22 nodes collapsed)
} "}"

After

program
block_comment "/*\n * Licensed to the Apache Software Foundation (ASF) under"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "commandline"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "ArrayList"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Collections"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashMap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Iterator"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Properties"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Set"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "Argument"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "Option"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "WriteableCommandLine"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "option"
. "."
identifier "PropertyOption"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "resource"
. "."
identifier "ResourceConstants"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "cli2"
. "."
identifier "resource"
. "."
identifier "ResourceHelper"
; ";"
block_comment "/**\n * A WriteableCommandLine implementation allowing Option"...
class_declaration
modifiers
public "public"
class "class"
identifier "WriteableCommandLineImpl"
superclass
extends "extends"
type_identifier "CommandLineImpl"
super_interfaces
implements "implements"
type_list
type_identifier "WriteableCommandLine"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Map"
variable_declarator
identifier "optionToProperties"
= "="
object_creation_expression
new "new"
type_identifier "HashMap"
argument_list
( "("
) ")"
; ";"
line_comment "// private final Properties properties = new Properties()"...
field_declaration
modifiers
private "private"
final "final"
type_identifier "List"
variable_declarator
identifier "options"
= "="
object_creation_expression
new "new"
type_identifier "ArrayList"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Map"
variable_declarator
identifier "nameToOption"
= "="
object_creation_expression
new "new"
type_identifier "HashMap"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Map"
variable_declarator
identifier "values"
= "="
object_creation_expression
new "new"
type_identifier "HashMap"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Map"
variable_declarator
identifier "switches"
= "="
object_creation_expression
new "new"
type_identifier "HashMap"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Map"
variable_declarator
identifier "defaultValues"
= "="
object_creation_expression
new "new"
type_identifier "HashMap"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Map"
variable_declarator
identifier "defaultSwitches"
= "="
object_creation_expression
new "new"
type_identifier "HashMap"
argument_list
( "("
) ")"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "List"
variable_declarator
identifier "normalised"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Set"
variable_declarator
identifier "prefixes"
; ";"
field_declaration
modifiers
private "private"
type_identifier "Option"
variable_declarator
identifier "currentOption"
; ";"
field_declaration
modifiers
private "private"
type_identifier "String"
variable_declarator
identifier "checkForOption"
; ";"
block_comment "/**\n * Creates a new WriteableCommandLineImpl rooted on "...
constructor_declaration
modifiers
public "public"
identifier "WriteableCommandLineImpl"
formal_parameters
( "("
formal_parameter
modifiers
final "final"
type_identifier "Option"
identifier "rootOption"
, ","
formal_parameter
modifiers
final "final"
type_identifier "List"
identifier "arguments"
) ")"
constructor_body
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "prefixes"
= "="
method_invocation
identifier "rootOption"
. "."
identifier "getPrefixes"
argument_list
( "("
) ")"
; ";"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "normalised"
= "="
identifier "arguments"
; ";"
expression_statement
method_invocation
identifier "setCurrentOption"
argument_list
( "("
identifier "rootOption"
) ")"
; ";"
} "}"
method_declaration
modifiers
public "public"
type_identifier "Option"
identifier "getCurrentOption"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "currentOption"
; ";"
} "}"
method_declaration
modifiers
public "public"
void_type "void"
identifier "setCurrentOption"
formal_parameters
( "("
formal_parameter
type_identifier "Option"
identifier "currentOption"
) ")"
block
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "currentOption"
= "="
identifier "currentOption"
; ";"
} "}"
method_declaration (+154 nodes collapsed)
method_declaration (+105 nodes collapsed)
method_declaration (+99 nodes collapsed)
method_declaration (+36 nodes collapsed)
method_declaration (+31 nodes collapsed)
method_declaration (+242 nodes collapsed)
method_declaration (+59 nodes collapsed)
method_declaration (+97 nodes collapsed)
method_declaration (+32 nodes collapsed)
method_declaration (+93 nodes collapsed)
method_declaration (+39 nodes collapsed)
method_declaration (+75 nodes collapsed)
method_declaration (+70 nodes collapsed)
method_declaration (+25 nodes collapsed)
block_comment "/**\n * Tests whether the passed in trigger looks like an"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "looksLikeOption"
formal_parameters
( "("
formal_parameter
modifiers
final "final"
type_identifier "String"
identifier "trigger"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "checkForOption"
!= "!="
null_literal "null"
) ")"
block
{ "{"
line_comment "// this is a reentrant call"
return_statement
return "return"
unary_expression
! "!"
method_invocation
identifier "checkForOption"
. "."
identifier "equals"
argument_list
( "("
identifier "trigger"
) ")"
; ";"
} "}"
expression_statement
assignment_expression
identifier "checkForOption"
= "="
identifier "trigger"
; ";"
try_statement
try "try"
block
{ "{"
for_statement
for "for"
( "("
local_variable_declaration
modifiers
final "final"
type_identifier "Iterator"
variable_declarator
identifier "i"
= "="
method_invocation
identifier "prefixes"
. "."
identifier "iterator"
argument_list
( "("
) ")"
; ";"
method_invocation
identifier "i"
. "."
identifier "hasNext"
argument_list
( "("
) ")"
; ";"
) ")"
block
{ "{"
local_variable_declaration
modifiers
final "final"
type_identifier "String"
variable_declarator
identifier "prefix"
= "="
cast_expression
( "("
type_identifier "String"
) ")"
method_invocation
identifier "i"
. "."
identifier "next"
argument_list
( "("
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
method_invocation
identifier "trigger"
. "."
identifier "startsWith"
argument_list
( "("
identifier "prefix"
) ")"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
method_invocation
identifier "getCurrentOption"
argument_list
( "("
) ")"
. "."
identifier "canProcess"
argument_list
( "("
this "this"
, ","
identifier "trigger"
) ")"
|| "||"
binary_expression
method_invocation
method_invocation
identifier "getCurrentOption"
argument_list
( "("
) ")"
. "."
identifier "findOption"
argument_list
( "("
identifier "trigger"
) ")"
!= "!="
null_literal "null"
) ")"
block
{ "{"
return_statement
return "return"
true "true"
; ";"
} "}"
} "}"
} "}"
return_statement
return "return"
false "false"
; ";"
} "}"
finally_clause
finally "finally"
block
{ "{"
expression_statement
assignment_expression
identifier "checkForOption"
= "="
null_literal "null"
; ";"
} "}"
} "}"
method_declaration (+173 nodes collapsed)
method_declaration (+22 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration (+60 nodes collapsed)
method_declaration (+60 nodes collapsed)
method_declaration (+22 nodes collapsed)
} "}"