146-1-2

for (EStructuralFeature feature : getAnyChildrenFeatures(eObject)) { if (feature == childFeature) { break; } if (feature.isMany()) { index -= ((List<?>)(eObject).eGet(feature)).size(); } else if (eObject.eGet(feature) != null) { index -= 1; } } if (index < 0) { break; }
for (EStructuralFeature feature : getAnyChildrenFeatures(eObject)) { if (feature == childFeature) { break; } if (feature.isMany()) { index -= ((List<?>)(eObject).eGet(feature)).size(); } else if (eObject.eGet(feature) != null) { index -= 1; } } // Create a command for this feature, // return createMoveCommand(domain, eObject, childFeature, value, index);

Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/edit/provider/ItemProviderAdapter.java |  | File path: /emf-2.4.1/src/org/eclipse/emf/edit/provider/ItemProviderAdapter.java
Method name: `Command factorAddCommand(EditingDomain, CommandParameter)` |  | Method name: `Command factorMoveCommand(EditingDomain, CommandParameter)`
Number of AST nodes: 9 |  | Number of AST nodes: 8

1

    for (EStructuralFeature feature : getAnyChildrenFeatures(eObject))↵

1

    for (EStructuralFeature feature : getAnyChildrenFeatures(eObject))↵

2

              {↵

2

          ↵

3

        ↵

3

    {↵

4

            if (feature == childFeature)↵

4

            if (feature == childFeature)↵

5

                {↵

5

            {↵

6

                  break;↵

6

              break;↵

7

                } ↵

7

            } ↵

8

                if (feature.isMany())↵

8

            if (feature.isMany())↵

9

                {↵

9

            ↵

10

        ↵

10

    {↵

11

              index -= ((List<?>)(eObject).eGet(feature)).size();↵

11

              index -= ((List<?>)(eObject).eGet(feature)).size();↵

12

                }↵

12

            }↵

13

                else if (eObject.eGet(feature) != null)↵

13

            else if (eObject.eGet(feature) != null)↵

14

                {↵

14

            ↵

15

      ↵

15

    {↵

16

                index -= 1;↵

16

              index -= 1;↵

17

                }↵

17

            }↵

18

              }↵

18

          }↵

19

              if (index < 0)↵

19

          // Create a command for this feature,↵

20

              {↵

20

          //↵

21

                break;↵

21

          ↵

22

              }

22

    return createMoveCommand(domain, eObject, childFeature, value, index);

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) | 1.0
Clones location | Clones are declared in the same class
Number of node comparisons | 24

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 7
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 1
   Time elapsed for statement mapping (ms) | 5.2
   Clone type | Type 3

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

   15

       for (EStructuralFeature feature : getAnyChildrenFeatures(eObject))

   6

       for (EStructuralFeature feature : getAnyChildrenFeatures(eObject))

   16

       if (feature == childFeature)

   7

       if (feature == childFeature)

   17

       break;

   8

       break;

   18

       if (feature.isMany())

   9

       if (feature.isMany())

   19

       index -= ((List<?>)(eObject).eGet(feature)).size();

   10

       index -= ((List<?>)(eObject).eGet(feature)).size();

   20

       else if (eObject.eGet(feature) != null)

   11

       else if (eObject.eGet(feature) != null)

   21

       index -= 1;

   12

       index -= 1;

   13 | return createMoveCommand(domain, eObject, childFeature, value, index);

   Preondition Violations
   Unmatched statement return createMoveCommand(domain,eObject,childFeature,value,index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   Unmatched return createMoveCommand(domain,eObject,childFeature,value,index);

   13

       return createMoveCommand(domain, eObject, childFeature, value, index);

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Unmatched statement return createMoveCommand(domain,eObject,childFeature,value,index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   2 | Unmatched return createMoveCommand(domain,eObject,childFeature,value,index);