100-1-2

if (isNotificationRequired()) { int index = size(); boolean oldIsSet = isSet(); doAddUnique(index, object); NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet); if (notifications == null) { notifications = notification; } else { notifications.add(notification); } } else { doAddUnique(size(), object); } return notifications;
if (isNotificationRequired()) { int index = size; boolean oldIsSet = isSet(); doAddUnique(index, object); NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet); if (notifications == null) { notifications = notification; } else { notifications.add(notification); } } else { doAddUnique(size, object); } return notifications;

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: `NotificationChain basicAdd(E, NotificationChain)` |  | Method name: `NotificationChain basicAdd(E, NotificationChain)`
Number of AST nodes: 10 |  | Number of AST nodes: 10

1

    if (isNotificationRequired())↵

1

    if (isNotificationRequired())↵

2

        {↵

2

        {↵

3

          int index = size();↵

3

          int index = size;↵

4

          boolean oldIsSet = isSet();↵

4

          boolean oldIsSet = isSet();↵

5

          doAddUnique(index, object);↵

5

          doAddUnique(index, object);↵

6

          NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet);↵

6

          NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet);↵

7

          if (notifications == null)↵

7

          if (notifications == null)↵

8

          {↵

8

          {↵

9

            notifications = notification;↵

9

            notifications = notification;↵

10

          }↵

10

          }↵

11

          else↵

11

          else↵

12

          {↵

12

          {↵

13

            notifications.add(notification);↵

13

            notifications.add(notification);↵

14

          }↵

14

          }↵

15

        }↵

15

        }↵

16

        else↵

16

        else↵

17

        {↵

17

        {↵

18

          doAddUnique(size(), object);↵

18

          doAddUnique(size, object);↵

19

        }↵

19

        }↵

20

        return notifications;

20

        return notifications;

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 having the same super class
Number of node comparisons | 46

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 10
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 20.4
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       if (isNotificationRequired())

   1

       if (isNotificationRequired())

   2

       int index = size();

   2 | int index = size();
   2 | int index = size;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   size() | size | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression size() is a method call throwing exception(s) that should be caught by a try block that will be extracted

   2

       int index = size;

   3

       boolean oldIsSet = isSet();

   3

       boolean oldIsSet = isSet();

   4

       doAddUnique(index, object);

   4

       doAddUnique(index, object);

   5

       NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet);

   5

       NotificationImpl notification = createNotification(Notification.ADD, null, object, index, oldIsSet);

   6

       if (notifications == null)

   6

       if (notifications == null)

   7

       notifications = notification;

   7

       notifications = notification;

       else

       else

   8

       notifications.add(notification);

   8

       notifications.add(notification);

       else

       else

   9

       doAddUnique(size(), object);

   9 | doAddUnique(size(), object);
   9 | doAddUnique(size, object);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   size() | size | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression size() is a method call throwing exception(s) that should be caught by a try block that will be extracted

   9

       doAddUnique(size, object);

   10

       return notifications;

   10

       return notifications;

   Precondition Violations (3)
   Row | Violation
   --- | ---
   1 | Expression size() is a method call throwing exception(s) that should be caught by a try block that will be extracted
   2 | Expression size() is a method call throwing exception(s) that should be caught by a try block that will be extracted
   3 | The refactoring of the clones is infeasible, because classes org.eclipse.emf.common.notify.impl.DelegatingNotifyingListImpl and org.eclipse.emf.common.notify.impl.NotifyingListImpl do not have a common superclass