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
          }
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 comparisons11
  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
    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
                                                                                        
                                                                                  
    55
    int index = list.basicIndexOf(value);
    22
    if (position == -1)
    22
    if (position == -1)
    56
    if (index == -1)
    Differences
    Expression1Expression2Difference
    positionindexVARIABLE_NAME_MISMATCH
    56
    if (index == -1)
    23
    copyList.add(index, target);
                                                                  
    else
            
    24
    copyList.move(index, target);
                                                                    
                                                                
    58
    list.move(position, index);
                                                                          
    57
    list.addUnique(position, value);
    Precondition Violations (1)
    Row Violation
    1Unmatched 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