int position = copyList.indexOf(target);
if (position == -1)
{
copyList.add(index, target);
}
else
{
copyList.move(index, target);
}
int index = list.basicIndexOf(value);
if (index == -1)
{
list.addUnique(position, value);
}
else
{
list.move(position, index);
}
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/edit/command/InitializeCopyCommand.java
|
|
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xmi/impl/XMLHelperImpl.java
|
Method name: void copyReferences()
|
|
Method name: void setValue(EObject, EStructuralFeature, Object, int)
|
Number of AST nodes: 4
|
|
Number of AST nodes: 4
|
|
1 | int position = copyList.indexOf(target);↵ | | 1 | int ↵
|
2 | ↵ | | 2 | index = list.basicIndexOf(value);↵
|
3 | if (position == -1)↵ | | 3 | if (index == -1)↵
|
4 | {↵ | | 4 | {↵
|
5 | copyList.add(index, target);↵ | | 5 | list.addUnique(position, value);↵
|
6 | }↵ | | 6 | ↵
|
7 | ↵ | | 7 | }↵
|
8 | else↵ | | 8 | else↵
|
9 | {↵ | | 9 | ↵
|
10 | ↵ | | 10 | {↵
|
11 | copyList.move(index, target);↵ | | 11 | list.move(↵
|
12 | ↵ | | 12 | position, index);↵
|
13 | } | | 13 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2 |
Clones location | Clones are in different classes |
Number of node comparisons | 11 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 1 |
Number of unmapped statements in the first code fragment | 3 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 1.0 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
21 | int position = copyList.indexOf(target); | | | |
| | | 55 | int index = list.basicIndexOf(value); |
22 | if (position == -1) | | 56 | if (index == -1) |
23 | copyList.add(index, target); | | | |
| | | | |
24 | copyList.move(index, target); | | | |
| | | 58 | list.move(position, index); |
| | | 57 | list.addUnique(position, value); |
Precondition Violations (1)
Row |
Violation |
1 | Unmatched statement int position=copyList.indexOf(target); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |