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

1package org.mockito.internal.configuration.injection;
2
3import org.mockito.exceptions.base.MockitoException;
4import org.mockito.internal.util.reflection.FieldSetter;
5
6import java.lang.reflect.Field;
7import java.util.Collection;
8
9/**
…lines 10–17 unchanged (8 lines)
18 public OngoingInjecter filterCandidate(final Collection<Object> mocks, final Field field, final Object fieldInstance) {
19 if(mocks.size() == 1) {
20 final Object matchingMock = mocks.iterator().next();
21
22 return new OngoingInjecter() {
23 public boolean thenInject() {
24 try {
25 new FieldSetter(fieldInstance, field).set(matchingMock);
26 } catch (Exception e) {
27 throw new MockitoException("Problems injecting dependency in " + field.getName(), e);
28 }
29 return true;
30 }
31 };
…lines 32–42 unchanged (11 lines)

After

1package org.mockito.internal.configuration.injection;
2
3import org.mockito.exceptions.base.MockitoException;
4import org.mockito.internal.util.reflection.BeanPropertySetter;
5import org.mockito.internal.util.reflection.FieldSetter;
6
7import java.lang.reflect.Field;
8import java.util.Collection;
9
10/**
…lines 11–19 unchanged (9 lines)
20 if(mocks.size() == 1) {
21 final Object matchingMock = mocks.iterator().next();
22
23 return new OngoingInjecter() {
24 public boolean thenInject() {
25 try {
26 if (!new BeanPropertySetter(fieldInstance, field).set(matchingMock)) {
27 new FieldSetter(fieldInstance, field).set(matchingMock);
28 }
29 } catch (Exception e) {
30 throw new MockitoException("Problems injecting dependency in " + field.getName(), e);
31 }
32 return true;
33 }
34 };
…lines 35–45 unchanged (11 lines)

Before

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "mockito"
. "."
identifier "internal"
. "."
identifier "configuration"
. "."
identifier "injection"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "mockito"
. "."
identifier "exceptions"
. "."
identifier "base"
. "."
identifier "MockitoException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "mockito"
. "."
identifier "internal"
. "."
identifier "util"
. "."
identifier "reflection"
. "."
identifier "FieldSetter"
; ";"
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 "Collection"
; ";"
block_comment "/**\r\n * This node returns an actual injecter which will be e"...
class_declaration
modifiers
public "public"
class "class"
identifier "FinalMockCandidateFilter"
super_interfaces
implements "implements"
type_list
type_identifier "MockCandidateFilter"
class_body
{ "{"
method_declaration
modifiers
public "public"
type_identifier "OngoingInjecter"
identifier "filterCandidate"
formal_parameters (+25 nodes collapsed)
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "mocks"
. "."
identifier "size"
argument_list
( "("
) ")"
== "=="
decimal_integer_literal "1"
) ")"
block
{ "{"
local_variable_declaration (+21 nodes collapsed)
return_statement
return "return"
object_creation_expression
new "new"
type_identifier "OngoingInjecter"
argument_list
( "("
) ")"
class_body
{ "{"
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "thenInject"
formal_parameters
( "("
) ")"
block
{ "{"
try_statement
try "try"
block
{ "{"
expression_statement
method_invocation
object_creation_expression
new "new"
type_identifier "FieldSetter"
argument_list
( "("
identifier "fieldInstance"
, ","
identifier "field"
) ")"
. "."
identifier "set"
argument_list
( "("
identifier "matchingMock"
) ")"
; ";"
} "}"
catch_clause (+35 nodes collapsed)
return_statement
return "return"
true "true"
; ";"
} "}"
} "}"
; ";"
} "}"
return_statement (+27 nodes collapsed)
} "}"
} "}"

After

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "mockito"
. "."
identifier "internal"
. "."
identifier "configuration"
. "."
identifier "injection"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "mockito"
. "."
identifier "exceptions"
. "."
identifier "base"
. "."
identifier "MockitoException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "mockito"
. "."
identifier "internal"
. "."
identifier "util"
. "."
identifier "reflection"
. "."
identifier "BeanPropertySetter"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "mockito"
. "."
identifier "internal"
. "."
identifier "util"
. "."
identifier "reflection"
. "."
identifier "FieldSetter"
; ";"
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 "Collection"
; ";"
block_comment "/**\r\n * This node returns an actual injecter which will be e"...
class_declaration
modifiers
public "public"
class "class"
identifier "FinalMockCandidateFilter"
super_interfaces
implements "implements"
type_list
type_identifier "MockCandidateFilter"
class_body
{ "{"
method_declaration
modifiers
public "public"
type_identifier "OngoingInjecter"
identifier "filterCandidate"
formal_parameters (+25 nodes collapsed)
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
method_invocation
identifier "mocks"
. "."
identifier "size"
argument_list
( "("
) ")"
== "=="
decimal_integer_literal "1"
) ")"
block
{ "{"
local_variable_declaration (+21 nodes collapsed)
return_statement
return "return"
object_creation_expression
new "new"
type_identifier "OngoingInjecter"
argument_list
( "("
) ")"
class_body
{ "{"
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "thenInject"
formal_parameters
( "("
) ")"
block
{ "{"
try_statement
try "try"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
method_invocation
object_creation_expression
new "new"
type_identifier "BeanPropertySetter"
argument_list
( "("
identifier "fieldInstance"
, ","
identifier "field"
) ")"
. "."
identifier "set"
argument_list
( "("
identifier "matchingMock"
) ")"
) ")"
block
{ "{"
expression_statement
method_invocation
object_creation_expression
new "new"
type_identifier "FieldSetter"
argument_list
( "("
identifier "fieldInstance"
, ","
identifier "field"
) ")"
. "."
identifier "set"
argument_list
( "("
identifier "matchingMock"
) ")"
; ";"
} "}"
} "}"
catch_clause (+35 nodes collapsed)
return_statement
return "return"
true "true"
; ";"
} "}"
} "}"
; ";"
} "}"
return_statement (+27 nodes collapsed)
} "}"
} "}"