if (result) { if (positions != null) { int collectionSize = collection.size(); NotificationImpl notification = (collectionSize == 1 ? createNotification(Notification.REMOVE, collection.iterator().next(), null, positions[0], oldIsSet) : createNotification(Notification.REMOVE_MANY, collection, positions, positions[0], oldIsSet)); NotificationChain notifications = createNotificationChain(collectionSize); if (hasInverse()) { for (Iterator<?> i = collection.iterator(); i.hasNext(); ) { @SuppressWarnings("unchecked") E object = (E)i.next(); notifications = inverseRemove(object, notifications); } if (notifications == null) { dispatchNotification(notification); } else { notifications.add(notification); notifications.dispatch(); } } else { if (notifications == null) { dispatchNotification(notification); } else { notifications.add(notification); notifications.dispatch(); } } } else if (hasInverse()) { NotificationChain notifications = createNotificationChain(collection.size()); for (Iterator<?> i = collection.iterator(); i.hasNext(); ) { @SuppressWarnings("unchecked") E object = (E)i.next(); notifications = inverseRemove(object, notifications); } if (notifications != null) notifications.dispatch(); } return true; } else { return false; }
if (result) { if (positions != null) { int collectionSize = collection.size(); NotificationImpl notification = (collectionSize == 1 ? createNotification(Notification.REMOVE, collection.iterator().next(), null, positions[0], oldIsSet) : createNotification(Notification.REMOVE_MANY, collection, positions, positions[0], oldIsSet)); NotificationChain notifications = createNotificationChain(collectionSize); if (hasInverse()) { for (Iterator<?> i = collection.iterator(); i.hasNext(); ) { @SuppressWarnings("unchecked") E object = (E)i.next(); notifications = inverseRemove(object, notifications); } if (notifications == null) { dispatchNotification(notification); } else { notifications.add(notification); notifications.dispatch(); } } else { if (notifications == null) { dispatchNotification(notification); } else { notifications.add(notification); notifications.dispatch(); } } } else if (hasInverse()) { NotificationChain notifications = createNotificationChain(collection.size()); for (Iterator<?> i = collection.iterator(); i.hasNext(); ) { @SuppressWarnings("unchecked") E object = (E)i.next(); notifications = inverseRemove(object, notifications); } if (notifications != null) notifications.dispatch(); } return true; } else { return false; }
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/common/notify/impl/DelegatingNotifyingListImpl.java File path: /emf-2.4.1/src/org/eclipse/emf/common/notify/impl/NotifyingListImpl.java
Method name: boolean removeAll(Collection) Method name: boolean removeAll(Collection)
Number of AST nodes: 26 Number of AST nodes: 26
1
if (result)
1
if (result)
2
    {
2
    {
3
      if (positions != null)
3
      if (positions != null)
4
      {
4
      {
5
        int collectionSize = collection.size();
5
        int collectionSize = collection.size();
6
        NotificationImpl notification =
6
        NotificationImpl notification =
7
          (collectionSize == 1 ?
7
          (collectionSize == 1 ?
8
            createNotification(Notification.REMOVE, collection.iterator().next(), null, positions[0], oldIsSet) :
8
            createNotification(Notification.REMOVE, collection.iterator().next(), null, positions[0], oldIsSet) :
9
            createNotification(Notification.REMOVE_MANY, collection, positions, positions[0], oldIsSet));
9
            createNotification(Notification.REMOVE_MANY, collection, positions, positions[0], oldIsSet));
10
        NotificationChain notifications = createNotificationChain(collectionSize);
10
        NotificationChain notifications = createNotificationChain(collectionSize);
11
        if (hasInverse())
11
        if (hasInverse())
12
        {
12
        {
13
          for (Iterator<?> i = collection.iterator(); i.hasNext(); )
13
          for (Iterator<?> i = collection.iterator(); i.hasNext(); )
14
          {
14
          {
15
            @SuppressWarnings("unchecked") E object = (E)i.next();
15
            @SuppressWarnings("unchecked") E object = (E)i.next();
16
            notifications = inverseRemove(object, notifications);
16
            notifications = inverseRemove(object, notifications);
17
          }
17
          }
18
          if (notifications == null)
18
          if (notifications == null)
19
          {
19
          {
20
            dispatchNotification(notification);
20
            dispatchNotification(notification);
21
          }
21
          }
22
          else
22
          else
23
          {
23
          {
24
            notifications.add(notification);
24
            notifications.add(notification);
25
            notifications.dispatch();
25
            notifications.dispatch();
26
          }
26
          }
27
        }
27
        }
28
        else
28
        else
29
        {
29
        {
30
          if (notifications == null)
30
          if (notifications == null)
31
          {
31
          {
32
            dispatchNotification(notification);
32
            dispatchNotification(notification);
33
          }
33
          }
34
          else
34
          else
35
          {
35
          {
36
            notifications.add(notification);
36
            notifications.add(notification);
37
            notifications.dispatch();
37
            notifications.dispatch();
38
          }
38
          }
39
        }
39
        }
40
      }
40
      }
41
      else if (hasInverse())
41
      else if (hasInverse())
42
      {
42
      {
43
        NotificationChain notifications = createNotificationChain(collection.size());
43
        NotificationChain notifications = createNotificationChain(collection.size());
44
        for (Iterator<?> i = collection.iterator(); i.hasNext(); )
44
        for (Iterator<?> i = collection.iterator(); i.hasNext(); )
45
        {
45
        {
46
          @SuppressWarnings("unchecked") E object = (E)i.next();
46
          @SuppressWarnings("unchecked") E object = (E)i.next();
47
          notifications = inverseRemove(object, notifications);
47
          notifications = inverseRemove(object, notifications);
48
        }
48
        }
49
        if (notifications != null) notifications.dispatch();
49
        if (notifications != null) notifications.dispatch();
50
      }
50
      }
51
      return true;
51
      return true;
52
    }
52
    }
53
    else
53
    else
54
    {
54
    {
55
      return false;
55
      return false;
56
    }
56
    }
Summary
Number of common nesting structure subtrees2
Number of refactorable cases0
Number of non-refactorable cases2
Time elapsed for finding largest common nesting structure subtrees (ms)2.2
Clones locationClones are in different classes having the same super class
Number of node comparisons109
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)7191.9
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    74
    int collectionSize = collection.size();
    74
    int collectionSize = collection.size();
    74
    int collectionSize = collection.size();
    Differences
    Expression1Expression2Difference
    java.util.Collection<>java.util.Collection<>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection<> of variable collection does not match with type java.util.Collection<> of variable collection
    • Make classes java.util.Collection<> and java.util.Collection<> extend a common superclass
    74
    int collectionSize = collection.size();
    75
    NotificationImpl notification = (collectionSize == 1 ? createNotification(Notification.REMOVE, collection.iterator().next(), null, positions[0], oldIsSet) : createNotification(Notification.REMOVE_MANY, collection, positions, positions[0], oldIsSet));
    75
    NotificationImpl notification = (collectionSize == 1 ? createNotification(Notification.REMOVE, collection.iterator().next(), null, positions[0], oldIsSet) : createNotification(Notification.REMOVE_MANY, collection, positions, positions[0], oldIsSet));
    75
    NotificationImpl notification = (collectionSize == 1 ? createNotification(Notification.REMOVE, collection.iterator().next(), null, positions[0], oldIsSet) : createNotification(Notification.REMOVE_MANY, collection, positions, positions[0], oldIsSet));
    Differences
    Expression1Expression2Difference
    VARIABLE_TYPE_MISMATCH
    java.util.Iterator<>java.util.Iterator<>VARIABLE_TYPE_MISMATCH
    java.util.Collection<>java.util.Collection<>VARIABLE_TYPE_MISMATCH
    java.util.Collection<>java.util.Collection<>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type of variable collection.iterator().next() does not match with type of variable collection.iterator().next()
    • Make classes and extend a common superclass
    Type java.util.Iterator<> of variable collection.iterator() does not match with type java.util.Iterator<> of variable collection.iterator()
    • Make classes java.util.Iterator<> and java.util.Iterator<> extend a common superclass
    Type java.util.Collection<> of variable collection does not match with type java.util.Collection<> of variable collection
    • Make classes java.util.Collection<> and java.util.Collection<> extend a common superclass
    Type java.util.Collection<> of variable collection does not match with type java.util.Collection<> of variable collection
    • Make classes java.util.Collection<> and java.util.Collection<> extend a common superclass
    75
    NotificationImpl notification = (collectionSize == 1 ? createNotification(Notification.REMOVE, collection.iterator().next(), null, positions[0], oldIsSet) : createNotification(Notification.REMOVE_MANY, collection, positions, positions[0], oldIsSet));
    76
    NotificationChain notifications = createNotificationChain(collectionSize);
    76
    NotificationChain notifications = createNotificationChain(collectionSize);
    77
    if (hasInverse())
    77
    if (hasInverse())
                                                                                                                      
    78
    for (Iterator<?> i = collection.iterator(); i.hasNext(); )
    Preondition Violations
    Unmatched statement for(Iterator<?> i=collection.iterator(); i.hasNext()) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    78
    for (Iterator<?> i = collection.iterator(); i.hasNext(); )
                                                                                                                    
    79
    @SuppressWarnings("unchecked") E object = (E)i.next();
                                                                                                                
    80
    notifications = inverseRemove(object, notifications);
    Preondition Violations
    Unmatched statement notifications=inverseRemove(object,notifications); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    80
    notifications = inverseRemove(object, notifications);
    78
    for (Iterator<?> i = collection.iterator(); i.hasNext(); )
    78
    for (Iterator<?> i = collection.iterator(); i.hasNext(); )
    Preondition Violations
    Unmatched statement for(Iterator<?> i=collection.iterator(); i.hasNext()) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                      
    79
    @SuppressWarnings("unchecked") E object = (E)i.next();
                                                                                                                    
    80
    notifications = inverseRemove(object, notifications);
    80
    notifications = inverseRemove(object, notifications);
    Preondition Violations
    Unmatched statement notifications=inverseRemove(object,notifications); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                
    81
    if (notifications == null)
    81
    if (notifications == null)
    82
    dispatchNotification(notification);
    82
    dispatchNotification(notification);
    else
    else
    83
    notifications.add(notification);
    83
    notifications.add(notification);
    84
    notifications.dispatch();
    84
    notifications.dispatch();
    else
    else
    85
    if (notifications == null)
    85
    if (notifications == null)
    86
    dispatchNotification(notification);
    86
    dispatchNotification(notification);
    else
    else
    87
    notifications.add(notification);
    87
    notifications.add(notification);
    88
    notifications.dispatch();
    88
    notifications.dispatch();
    Precondition Violations (9)
    Row Violation
    1Type java.util.Collection<> of variable collection does not match with type java.util.Collection<> of variable collection
    2Type of variable collection.iterator().next() does not match with type of variable collection.iterator().next()
    3Type java.util.Iterator<> of variable collection.iterator() does not match with type java.util.Iterator<> of variable collection.iterator()
    4Type java.util.Collection<> of variable collection does not match with type java.util.Collection<> of variable collection
    5Type java.util.Collection<> of variable collection does not match with type java.util.Collection<> of variable collection
    6Unmatched statement for(Iterator<?> i=collection.iterator(); i.hasNext()) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7Unmatched statement notifications=inverseRemove(object,notifications); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement for(Iterator<?> i=collection.iterator(); i.hasNext()) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    9Unmatched statement notifications=inverseRemove(object,notifications); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
  2. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    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.5
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    90
    NotificationChain notifications = createNotificationChain(collection.size());
    90
    NotificationChain notifications = createNotificationChain(collection.size());
    90
    NotificationChain notifications = createNotificationChain(collection.size());
    Differences
    Expression1Expression2Difference
    java.util.Collection<>java.util.Collection<>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection<> of variable collection does not match with type java.util.Collection<> of variable collection
    • Make classes java.util.Collection<> and java.util.Collection<> extend a common superclass
    90
    NotificationChain notifications = createNotificationChain(collection.size());
                                                                                                                      
    91
    for (Iterator<?> i = collection.iterator(); i.hasNext(); )
                                                                                                                    
    92
    @SuppressWarnings("unchecked") E object = (E)i.next();
                                                                                                                
    93
    notifications = inverseRemove(object, notifications);
    Preondition Violations
    Unmatched statement notifications=inverseRemove(object,notifications); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    93
    notifications = inverseRemove(object, notifications);
    91
    for (Iterator<?> i = collection.iterator(); i.hasNext(); )
                                                                                                                      
    92
    @SuppressWarnings("unchecked") E object = (E)i.next();
                                                                                                                    
    93
    notifications = inverseRemove(object, notifications);
    93
    notifications = inverseRemove(object, notifications);
    Preondition Violations
    Unmatched statement notifications=inverseRemove(object,notifications); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                
    94
    if (notifications != null)
    94
    if (notifications != null)
    95
    notifications.dispatch();
    95
    notifications.dispatch();
    Precondition Violations (3)
    Row Violation
    1Type java.util.Collection<> of variable collection does not match with type java.util.Collection<> of variable collection
    2Unmatched statement notifications=inverseRemove(object,notifications); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement notifications=inverseRemove(object,notifications); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted