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–16 unchanged (16 lines)
17
18 public NameBasedCandidateFilter(MockCandidateFilter next) {
19 this.next = next;
20 }
21
22 public OngoingInjecter filterCandidate(Collection<Object> mocks,
23 Field field, Object fieldInstance) {
24 List<Object> mockNameMatches = new ArrayList<Object>();
25 if (mocks.size() > 1) {
26 for (Object mock : mocks) {
27 if (field.getName().equals(mockUtil.getMockName(mock).toString())) {
28 mockNameMatches.add(mock);
29 }
30 }
31 return next.filterCandidate(mockNameMatches, field,
32 fieldInstance);
33 /*
34 * In this case we have to check whether we have conflicting naming
35 * fields. E.g. 2 fields of the same type, but we have to make sure
36 * we match on the correct name.
37 *
38 * Therefore we have to go through all other fields and make sure
39 * whenever we find a field that does match its name with the mock
40 * name, we should take that field instead.
41 */
42 }
43 return next.filterCandidate(mocks, field, fieldInstance);
44 }
45}
46

After

…lines 1–16 unchanged (16 lines)
17
18 public NameBasedCandidateFilter(MockCandidateFilter next) {
19 this.next = next;
20 }
21
22 public OngoingInjecter filterCandidate(Collection<Object> mocks,
23 Field field, List<Field> fields, Object fieldInstance) {
24 List<Object> mockNameMatches = new ArrayList<Object>();
25 if (mocks.size() > 1) {
26 for (Object mock : mocks) {
27 if (field.getName().equals(mockUtil.getMockName(mock).toString())) {
28 mockNameMatches.add(mock);
29 }
30 }
31 return next.filterCandidate(mockNameMatches, field, fields,
32 fieldInstance);
33 /*
34 * In this case we have to check whether we have conflicting naming
35 * fields. E.g. 2 fields of the same type, but we have to make sure
36 * we match on the correct name.
37 *
38 * Therefore we have to go through all other fields and make sure
39 * whenever we find a field that does match its name with the mock
40 * name, we should take that field instead.
41 */
42 } else if (mocks.size() == 1) {
43 String mockName = mockUtil.getMockName(mocks.iterator().next())
44 .toString();
45
46 for (Field otherField : fields) {
47 if (!otherField.equals(field)
48 && otherField.getType().equals(field.getType())
49 && otherField.getName().equals(mockName)) {
50
51 return new OngoingInjecter() {
52 public Object thenInject() {
53 return null;
54 }
55 };
56 }
57 }
58 }
59 return next.filterCandidate(mocks, field, fields, fieldInstance);
60 }
61}
62

Before

program
block_comment "/*\n * Copyright (c) 2007 Mockito contributors\n * This progra"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "mockito"
. "."
identifier "internal"
. "."
identifier "configuration"
. "."
identifier "injection"
. "."
identifier "filter"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "mockito"
. "."
identifier "internal"
. "."
identifier "util"
. "."
identifier "MockUtil"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "Field"
; ";"
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 "Collection"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
class_declaration
modifiers
public "public"
class "class"
identifier "NameBasedCandidateFilter"
super_interfaces
implements "implements"
type_list
type_identifier "MockCandidateFilter"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
type_identifier "MockCandidateFilter"
variable_declarator
identifier "next"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "MockUtil"
variable_declarator
identifier "mockUtil"
= "="
object_creation_expression
new "new"
type_identifier "MockUtil"
argument_list
( "("
) ")"
; ";"
constructor_declaration (+22 nodes collapsed)
method_declaration
modifiers
public "public"
type_identifier "OngoingInjecter"
identifier "filterCandidate"
formal_parameters
( "("
formal_parameter
generic_type
type_identifier "Collection"
type_arguments
< "<"
type_identifier "Object"
> ">"
identifier "mocks"
, ","
formal_parameter
type_identifier "Field"
identifier "field"
, ","
formal_parameter
type_identifier "Object"
identifier "fieldInstance"
) ")"
block
{ "{"
local_variable_declaration (+22 nodes collapsed)
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "mocks"
. "."
identifier "size"
argument_list
( "("
) ")"
> ">"
decimal_integer_literal "1"
) ")"
block
{ "{"
enhanced_for_statement (+56 nodes collapsed)
return_statement
return "return"
method_invocation
identifier "next"
. "."
identifier "filterCandidate"
argument_list
( "("
identifier "mockNameMatches"
, ","
identifier "field"
, ","
identifier "fieldInstance"
) ")"
; ";"
block_comment "/*\n\t\t\t * In this case we have to check whether we have confl"...
} "}"
return_statement
return "return"
method_invocation
identifier "next"
. "."
identifier "filterCandidate"
argument_list
( "("
identifier "mocks"
, ","
identifier "field"
, ","
identifier "fieldInstance"
) ")"
; ";"
} "}"
} "}"

After

program
block_comment "/*\n * Copyright (c) 2007 Mockito contributors\n * This progra"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "mockito"
. "."
identifier "internal"
. "."
identifier "configuration"
. "."
identifier "injection"
. "."
identifier "filter"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "mockito"
. "."
identifier "internal"
. "."
identifier "util"
. "."
identifier "MockUtil"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "lang"
. "."
identifier "reflect"
. "."
identifier "Field"
; ";"
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 "Collection"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
class_declaration
modifiers
public "public"
class "class"
identifier "NameBasedCandidateFilter"
super_interfaces
implements "implements"
type_list
type_identifier "MockCandidateFilter"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
type_identifier "MockCandidateFilter"
variable_declarator
identifier "next"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "MockUtil"
variable_declarator
identifier "mockUtil"
= "="
object_creation_expression
new "new"
type_identifier "MockUtil"
argument_list
( "("
) ")"
; ";"
constructor_declaration (+22 nodes collapsed)
method_declaration
modifiers
public "public"
type_identifier "OngoingInjecter"
identifier "filterCandidate"
formal_parameters
( "("
formal_parameter
generic_type
type_identifier "Collection"
type_arguments
< "<"
type_identifier "Object"
> ">"
identifier "mocks"
, ","
formal_parameter
type_identifier "Field"
identifier "field"
, ","
formal_parameter
generic_type
type_identifier "List"
type_arguments
< "<"
type_identifier "Field"
> ">"
identifier "fields"
, ","
formal_parameter
type_identifier "Object"
identifier "fieldInstance"
) ")"
block
{ "{"
local_variable_declaration (+22 nodes collapsed)
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "mocks"
. "."
identifier "size"
argument_list
( "("
) ")"
> ">"
decimal_integer_literal "1"
) ")"
block
{ "{"
enhanced_for_statement (+56 nodes collapsed)
return_statement
return "return"
method_invocation
identifier "next"
. "."
identifier "filterCandidate"
argument_list
( "("
identifier "mockNameMatches"
, ","
identifier "field"
, ","
identifier "fields"
, ","
identifier "fieldInstance"
) ")"
; ";"
block_comment "/*\n\t\t\t * In this case we have to check whether we have confl"...
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "mocks"
. "."
identifier "size"
argument_list
( "("
) ")"
== "=="
decimal_integer_literal "1"
) ")"
block
{ "{"
local_variable_declaration
type_identifier "String"
variable_declarator
identifier "mockName"
= "="
method_invocation
method_invocation
identifier "mockUtil"
. "."
identifier "getMockName"
argument_list
( "("
method_invocation
method_invocation
identifier "mocks"
. "."
identifier "iterator"
argument_list
( "("
) ")"
. "."
identifier "next"
argument_list
( "("
) ")"
) ")"
. "."
identifier "toString"
argument_list
( "("
) ")"
; ";"
enhanced_for_statement
for "for"
( "("
type_identifier "Field"
identifier "otherField"
: ":"
identifier "fields"
) ")"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
unary_expression
! "!"
method_invocation
identifier "otherField"
. "."
identifier "equals"
argument_list
( "("
identifier "field"
) ")"
&& "&&"
method_invocation
method_invocation
identifier "otherField"
. "."
identifier "getType"
argument_list
( "("
) ")"
. "."
identifier "equals"
argument_list
( "("
method_invocation
identifier "field"
. "."
identifier "getType"
argument_list
( "("
) ")"
) ")"
&& "&&"
method_invocation
method_invocation
identifier "otherField"
. "."
identifier "getName"
argument_list
( "("
) ")"
. "."
identifier "equals"
argument_list
( "("
identifier "mockName"
) ")"
) ")"
block
{ "{"
return_statement
return "return"
object_creation_expression
new "new"
type_identifier "OngoingInjecter"
argument_list
( "("
) ")"
class_body
{ "{"
method_declaration
modifiers
public "public"
type_identifier "Object"
identifier "thenInject"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
null_literal "null"
; ";"
} "}"
} "}"
; ";"
} "}"
} "}"
} "}"
return_statement
return "return"
method_invocation
identifier "next"
. "."
identifier "filterCandidate"
argument_list
( "("
identifier "mocks"
, ","
identifier "field"
, ","
identifier "fields"
, ","
identifier "fieldInstance"
) ")"
; ";"
} "}"
} "}"