113-1-2

if (actions != null) { IContributionItem[] items = manager.getItems(); for (int i = 0; i < items.length; i++) { // Look into SubContributionItems // IContributionItem contributionItem = items[i]; while (contributionItem instanceof SubContributionItem) { contributionItem = ((SubContributionItem)contributionItem).getInnerItem(); } // Delete the ActionContributionItems with matching action. // if (contributionItem instanceof ActionContributionItem) { IAction action = ((ActionContributionItem)contributionItem).getAction(); if (actions.contains(action)) { manager.remove(contributionItem); } } } }
if (actions != null) { IContributionItem[] items = manager.getItems(); for (int i = 0; i < items.length; i++) { // Look into SubContributionItems // IContributionItem contributionItem = items[i]; while (contributionItem instanceof SubContributionItem) { contributionItem = ((SubContributionItem)contributionItem).getInnerItem(); } // Delete the ActionContributionItems with matching action. // if (contributionItem instanceof ActionContributionItem) { IAction action = ((ActionContributionItem)contributionItem).getAction(); if (actions.contains(action)) { manager.remove(contributionItem); } } } }

Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/presentation/EcoreActionBarContributor.java |  | File path: /emf-2.4.1/src/org/eclipse/emf/mapping/ecore2xml/presentation/Ecore2XMLActionBarContributor.java
Method name: `void depopulateManager(IContributionManager, Collection)` |  | Method name: `void depopulateManager(IContributionManager, Collection)`
Number of AST nodes: 10 |  | Number of AST nodes: 10

1

    if (actions != null)↵

1

    if (actions != null)↵

2

        {↵

2

        {↵

3

          IContributionItem[] items = manager.getItems();↵

3

          IContributionItem[] items = manager.getItems();↵

4

          for (int i = 0; i < items.length; i++)↵

4

          for (int i = 0; i < items.length; i++)↵

5

          {↵

5

          {↵

6

            // Look into SubContributionItems↵

6

            // Look into SubContributionItems↵

7

            //↵

7

            //↵

8

            IContributionItem contributionItem = items[i];↵

8

            IContributionItem contributionItem = items[i];↵

9

            while (contributionItem instanceof SubContributionItem)↵

9

            while (contributionItem instanceof SubContributionItem)↵

10

            {↵

10

            {↵

11

              contributionItem = ((SubContributionItem)contributionItem).getInnerItem();↵

11

              contributionItem = ((SubContributionItem)contributionItem).getInnerItem();↵

12

            }↵

12

            }↵

13

            // Delete the ActionContributionItems with matching action.↵

13

            // Delete the ActionContributionItems with matching action.↵

14

            //↵

14

            //↵

15

            if (contributionItem instanceof ActionContributionItem)↵

15

            if (contributionItem instanceof ActionContributionItem)↵

16

            {↵

16

            {↵

17

              IAction action = ((ActionContributionItem)contributionItem).getAction();↵

17

              IAction action = ((ActionContributionItem)contributionItem).getAction();↵

18

              if (actions.contains(action))↵

18

              if (actions.contains(action))↵

19

              {↵

19

              {↵

20

                manager.remove(contributionItem);↵

20

                manager.remove(contributionItem);↵

21

              }↵

21

              }↵

22

            }↵

22

            }↵

23

          }↵

23

          }↵

24

        }

24

        }

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.4
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 22

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) | 1.2
   Clone type | Type 2

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

   1

       if (actions != null)

   1 | if (actions != null)
   1 | if (actions != null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   java.util.Collection<> | java.util.Collection<> | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type java.util.Collection<> of variable actions does not match with type java.util.Collection<> of variable actions
   - Make classes java.util.Collection<> and java.util.Collection<> extend a common superclass

   1

       if (actions != null)

   2

       IContributionItem[] items = manager.getItems();

   2

       IContributionItem[] items = manager.getItems();

   3

       for (int i = 0; i < items.length; i++)

   3

       for (int i = 0; i < items.length; i++)

   4

       IContributionItem contributionItem = items[i];

   4

       IContributionItem contributionItem = items[i];

   5

       while (contributionItem instanceof SubContributionItem)

   5

       while (contributionItem instanceof SubContributionItem)

   6

       contributionItem = ((SubContributionItem)contributionItem).getInnerItem();

   6

       contributionItem = ((SubContributionItem)contributionItem).getInnerItem();

   7

       if (contributionItem instanceof ActionContributionItem)

   7

       if (contributionItem instanceof ActionContributionItem)

   8

       IAction action = ((ActionContributionItem)contributionItem).getAction();

   8

       IAction action = ((ActionContributionItem)contributionItem).getAction();

   9

       if (actions.contains(action))

   9 | if (actions.contains(action))
   9 | if (actions.contains(action))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   java.util.Collection<> | java.util.Collection<> | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type java.util.Collection<> of variable actions does not match with type java.util.Collection<> of variable actions
   - Make classes java.util.Collection<> and java.util.Collection<> extend a common superclass

   9

       if (actions.contains(action))

   10

       manager.remove(contributionItem);

   10

       manager.remove(contributionItem);

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Type java.util.Collection<> of variable actions does not match with type java.util.Collection<> of variable actions
   2 | Type java.util.Collection<> of variable actions does not match with type java.util.Collection<> of variable actions