int collectionSize = end - start; if (collectionSize == 0) { return false; } else { if (isNotificationRequired()) { boolean oldIsSet = isSet(); doAddAllUnique(index, objects, start, end); NotificationImpl notification; if (collectionSize == 1) { notification = createNotification(Notification.ADD, null, objects[0], index, oldIsSet); } else { if (start != 0 || end != objects.length) { Object [] actualObjects = new Object [collectionSize]; for (int i = 0, j = start; j < end; ++i, ++j) { actualObjects[i] = objects[j]; } notification = createNotification(Notification.ADD_MANY, null, Arrays.asList(actualObjects), index, oldIsSet); } else { notification = createNotification(Notification.ADD_MANY, null, Arrays.asList(objects), index, oldIsSet); } } if (hasInverse()) { NotificationChain notifications = createNotificationChain(collectionSize); int lastIndex = index + collectionSize; for (int i = index; i < lastIndex; ++i) { @SuppressWarnings("unchecked") E value = (E)data[i]; notifications = inverseAdd(value, notifications); notifications = shadowAdd(value, notifications); } if (notifications == null) { dispatchNotification(notification); } else { notifications.add(notification); notifications.dispatch(); } } else { dispatchNotification(notification); } } else { doAddAllUnique(index, objects, start, end); if (hasInverse()) { NotificationChain notifications = createNotificationChain(collectionSize); int lastIndex = index + collectionSize; for (int i = index; i < lastIndex; ++i) { @SuppressWarnings("unchecked") E object = (E)data[i]; notifications = inverseAdd(object, notifications); } if (notifications != null) notifications.dispatch(); } } return true; }
int collectionSize = end - start; if (collectionSize == 0) { return false; } else { if (isNotificationRequired()) { boolean oldIsSet = isSet(); doAddAllUnique(index, objects, start, end); NotificationImpl notification; if (collectionSize == 1) { notification = createNotification(Notification.ADD, null, objects[0], index, oldIsSet); } else { if (start != 0 || end != objects.length) { Object [] actualObjects = new Object [collectionSize]; for (int i = 0, j = start; j < end; ++i, ++j) { actualObjects[i] = objects[j]; } notification = createNotification(Notification.ADD_MANY, null, Arrays.asList(actualObjects), index, oldIsSet); } else { notification = createNotification(Notification.ADD_MANY, null, Arrays.asList(objects), index, oldIsSet); } } if (hasInverse()) { NotificationChain notifications = createNotificationChain(collectionSize); int lastIndex = index + collectionSize; for (int i = index; i < lastIndex; ++i) { E value = delegateGet(i); notifications = inverseAdd(value, notifications); notifications = shadowAdd(value, notifications); } if (notifications == null) { dispatchNotification(notification); } else { notifications.add(notification); notifications.dispatch(); } } else { dispatchNotification(notification); } } else { doAddAllUnique(index, objects, start, end); if (hasInverse()) { NotificationChain notifications = createNotificationChain(collectionSize); int lastIndex = index + collectionSize; for (int i = index; i < lastIndex; ++i) { notifications = inverseAdd(delegateGet(i), notifications); } if (notifications != null) notifications.dispatch(); } } return true; }
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/common/notify/impl/NotifyingListImpl.java File path: /emf-2.4.1/src/org/eclipse/emf/common/notify/impl/DelegatingNotifyingListImpl.java
Method name: boolean addAllUnique(int, Object[], int, int) Method name: boolean addAllUnique(int, Object[], int, int)
Number of AST nodes: 37 Number of AST nodes: 36
1
int collectionSize = end - start;
1
int collectionSize = end - start;
2
    if (collectionSize == 0)
2
    if (collectionSize == 0)
3
    {
3
    {
4
      return false;
4
      return false;
5
    }
5
    }
6
    else
6
    else
7
    {
7
    {
8
      if (isNotificationRequired())
8
      if (isNotificationRequired())
9
      {
9
      {
10
        boolean oldIsSet = isSet();
10
        boolean oldIsSet = isSet();
11
        doAddAllUnique(index, objects, start, end);
11
        doAddAllUnique(index, objects, start, end);
12
        NotificationImpl notification;
12
        NotificationImpl notification;
13
        if (collectionSize == 1)
13
        if (collectionSize == 1)
14
        {
14
        {
15
          notification = createNotification(Notification.ADD, null, objects[0], index, oldIsSet);
15
          notification = createNotification(Notification.ADD, null, objects[0], index, oldIsSet);
16
        }
16
        }
17
        else
17
        else
18
        {
18
        {
19
          if (start != 0 || end != objects.length)
19
          if (start != 0 || end != objects.length)
20
          {
20
          {
21
            Object [] actualObjects = new Object [collectionSize];
21
            Object [] actualObjects = new Object [collectionSize];
22
            for (int i = 0, j = start; j < end; ++i, ++j)
22
            for (int i = 0, j = start; j < end; ++i, ++j)
23
            {
23
            {
24
              actualObjects[i] = objects[j];
24
              actualObjects[i] = objects[j];
25
            }
25
            }
26
            notification = createNotification(Notification.ADD_MANY, null, Arrays.asList(actualObjects), index, oldIsSet);
26
            notification = createNotification(Notification.ADD_MANY, null, Arrays.asList(actualObjects), index, oldIsSet);
27
          }
27
          }
28
          else
28
          else
29
          {
29
          {
30
            notification =  createNotification(Notification.ADD_MANY, null, Arrays.asList(objects), index, oldIsSet);
30
            notification =  createNotification(Notification.ADD_MANY, null, Arrays.asList(objects), index, oldIsSet);
31
          }
31
          }
32
        }
32
        }
33
        if (hasInverse())
33
        if (hasInverse())
34
        {
34
        {
35
          NotificationChain notifications = createNotificationChain(collectionSize);
35
          NotificationChain notifications = createNotificationChain(collectionSize);
36
          int lastIndex = index + collectionSize;
36
          int lastIndex = index + collectionSize;
37
          for (int i = index; i < lastIndex; ++i)
37
          for (int i = index; i < lastIndex; ++i)
38
          {            
38
          {            
39
            @SuppressWarnings("unchecked") E value = (E)data[i];
39
            E value = delegateGet(i);
40
            notifications = inverseAdd(value, notifications);
40
            notifications = inverseAdd(value, notifications);
41
            notifications = shadowAdd(value, notifications);
41
            notifications = shadowAdd(value, notifications);
42
          }
42
          }
43
          if (notifications == null)
43
          if (notifications == null)
44
          {
44
          {
45
            dispatchNotification(notification);
45
            dispatchNotification(notification);
46
          }
46
          }
47
          else
47
          else
48
          {
48
          {
49
            notifications.add(notification);
49
            notifications.add(notification);
50
            notifications.dispatch();
50
            notifications.dispatch();
51
          }
51
          }
52
        }
52
        }
53
        else
53
        else
54
        {
54
        {
55
          dispatchNotification(notification);
55
          dispatchNotification(notification);
56
        }
56
        }
57
      }
57
      }
58
      else
58
      else
59
      {
59
      {
60
        doAddAllUnique(index, objects, start, end);
60
        doAddAllUnique(index, objects, start, end);
61
        if (hasInverse())
61
        if (hasInverse())
62
        {
62
        {
63
          NotificationChain notifications = createNotificationChain(collectionSize);
63
          NotificationChain notifications = createNotificationChain(collectionSize);
64
          int lastIndex = index + collectionSize;
64
          int lastIndex = index + collectionSize;
65
          for (int i = index; i < lastIndex; ++i)
65
          for (int i = index; i < lastIndex; ++i)
66
          {            
66
          {            
67
            @SuppressWarnings("unchecked") E object = (E)data[i];
68
            notifications = inverseAdd(object, notifications);
67
            notifications = inverseAdd(delegateGet(i), notifications);
69
          }
68
          }
70
          if (notifications != null) notifications.dispatch();
69
          if (notifications != null) notifications.dispatch();
71
        }
70
        }
72
      }
71
      }
73
      return true;
72
      return true;
74
    }
73
    }
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)3.5
Clones locationClones are in different classes having the same super class
Number of node comparisons183
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements35
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)15.1
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    int collectionSize = end - start;
    1
    int collectionSize = end - start;
    2
    if (collectionSize == 0)
    2
    if (collectionSize == 0)
    3
    return false;
    3
    return false;
    else
    else
    4
    if (isNotificationRequired())
    4
    if (isNotificationRequired())
    5
    boolean oldIsSet = isSet();
    5
    boolean oldIsSet = isSet();
    6
    doAddAllUnique(index, objects, start, end);
    6
    doAddAllUnique(index, objects, start, end);
    7
    NotificationImpl notification;
    7
    NotificationImpl notification;
    8
    if (collectionSize == 1)
    8
    if (collectionSize == 1)
    9
    notification = createNotification(Notification.ADD, null, objects[0], index, oldIsSet);
    9
    notification = createNotification(Notification.ADD, null, objects[0], index, oldIsSet);
    else
    else
    10
    if (start != 0 || end != objects.length)
    10
    if (start != 0 || end != objects.length)
    11
    Object[] actualObjects = new Object[collectionSize];
    11
    Object[] actualObjects = new Object[collectionSize];
    12
    for (int i = 0, j = start; j < end; ++i, ++j)
    12
    for (int i = 0, j = start; j < end; ++i, ++j)
    13
    actualObjects[i] = objects[j];
    13
    actualObjects[i] = objects[j];
    14
    notification = createNotification(Notification.ADD_MANY, null, Arrays.asList(actualObjects), index, oldIsSet);
    14
    notification = createNotification(Notification.ADD_MANY, null, Arrays.asList(actualObjects), index, oldIsSet);
    else
    else
    15
    notification = createNotification(Notification.ADD_MANY, null, Arrays.asList(objects), index, oldIsSet);
    15
    notification = createNotification(Notification.ADD_MANY, null, Arrays.asList(objects), index, oldIsSet);
    16
    if (hasInverse())
    16
    if (hasInverse())
    17
    NotificationChain notifications = createNotificationChain(collectionSize);
    17
    NotificationChain notifications = createNotificationChain(collectionSize);
    18
    int lastIndex = index + collectionSize;
    18
    int lastIndex = index + collectionSize;
    19
    for (int i = index; i < lastIndex; ++i)
    19
    for (int i = index; i < lastIndex; ++i)
                                                          
    20
    E value = delegateGet(i);
    Preondition Violations
    Unmatched statement E value=delegateGet(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20
    E value = delegateGet(i);
    20
    @SuppressWarnings("unchecked") E value = (E)data[i];
    20
    @SuppressWarnings("unchecked") E value = (E)data[i];
    Preondition Violations
    Unmatched statement @SuppressWarnings("unchecked") E value=(E)data[i]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                
    21
    notifications = inverseAdd(value, notifications);
    21
    notifications = inverseAdd(value, notifications);
    22
    notifications = shadowAdd(value, notifications);
    22
    notifications = shadowAdd(value, notifications);
    23
    if (notifications == null)
    23
    if (notifications == null)
    24
    dispatchNotification(notification);
    24
    dispatchNotification(notification);
    else
    else
    25
    notifications.add(notification);
    25
    notifications.add(notification);
    26
    notifications.dispatch();
    26
    notifications.dispatch();
    else
    else
    27
    dispatchNotification(notification);
    27
    dispatchNotification(notification);
    else
    else
    28
    doAddAllUnique(index, objects, start, end);
    28
    doAddAllUnique(index, objects, start, end);
    29
    if (hasInverse())
    29
    if (hasInverse())
    30
    NotificationChain notifications = createNotificationChain(collectionSize);
    30
    NotificationChain notifications = createNotificationChain(collectionSize);
    31
    int lastIndex = index + collectionSize;
    31
    int lastIndex = index + collectionSize;
    32
    for (int i = index; i < lastIndex; ++i)
    32
    for (int i = index; i < lastIndex; ++i)
    33
    @SuppressWarnings("unchecked") E object = (E)data[i];
    33
    @SuppressWarnings("unchecked") E object = (E)data[i];
    Preondition Violations
    Unmatched statement @SuppressWarnings("unchecked") E object=(E)data[i]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                  
    34
    notifications = inverseAdd(object, notifications);
    34
    notifications = inverseAdd(object, notifications);
    33
    notifications = inverseAdd(delegateGet(i), notifications);
    Differences
    Expression1Expression2Difference
    objectdelegateGet(i)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression delegateGet(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    33
    notifications = inverseAdd(delegateGet(i), notifications);
    35
    if (notifications != null)
    34
    if (notifications != null)
    36
    notifications.dispatch();
    35
    notifications.dispatch();
    37
    return true;
    36
    return true;
    Precondition Violations (5)
    Row Violation
    1Unmatched statement E value=delegateGet(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement @SuppressWarnings("unchecked") E value=(E)data[i]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement @SuppressWarnings("unchecked") E object=(E)data[i]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Expression delegateGet(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Clone fragment #1 returns variables i, i , while Clone fragment #2 returns variables i