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: List setManyReference(ManyReference, String)
Number of AST nodes: 4 Number of AST nodes: 4
1
int position = copyList.indexOf(target);
1
int index = list.basicIndexOf(value);
2
              if (position == -1)
2
              if (index == -1)
3
              {
3
              {
4
                copyList.add(index, target);
4
                list.addUnique(position, value);
5
              }
5
              }
6
              else
6
              else
7
              {
7
              {
8
                copyList.move(index, target);
8
                list.move(position, index);
9
              }
9
              }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are in different classes
Number of node comparisons12
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements1
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)1.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                  
    15
    int index = list.basicIndexOf(value);
    Preondition Violations
    Unmatched statement int index=list.basicIndexOf(value); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15
    int index = list.basicIndexOf(value);
    21
    int position = copyList.indexOf(target);
    21
    int position = copyList.indexOf(target);
    Preondition Violations
    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
                                                                                        
    22
    if (position == -1)
    22
    if (position == -1)
    16
    if (index == -1)
    Differences
    Expression1Expression2Difference
    positionindexVARIABLE_NAME_MISMATCH
    16
    if (index == -1)
                                                                          
    17
    list.addUnique(position, value);
    23
    copyList.add(index, target);
                                                                  
    else
            
                                                                
    18
    list.move(position, index);
    24
    copyList.move(index, target);
                                                                    
    Precondition Violations (2)
    Row Violation
    1Unmatched statement int index=list.basicIndexOf(value); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched 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