173-116-203

if (contents == null) { contents = new ContentsEList<EObject>(); } return contents;
if (targets == null) { targets = new ArrayList<Notifier>(); } targets.add(target);

Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/resource/impl/ResourceImpl.java |  | File path: /emf-2.4.1/src/org/eclipse/emf/common/notify/impl/SingletonAdapterImpl.java
Method name: `EList getContents()` |  | Method name: `void setTarget(Notifier)`
Number of AST nodes: 3 |  | Number of AST nodes: 3

1

    if (contents == null)↵

1

    if (targets == null)↵

2

        {↵

2

        {↵

3

          contents = new ContentsEList<EObject>();↵

3

          targets = new ↵

4

        }↵

5

        return contents↵

4

    ArrayList<Notifier>();↵

5

        }↵

6

    ;

6

        targets.add(target);

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
Number of node comparisons | 5

1. {Non-refactorable}

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

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

   1

       if (contents == null)

   1 | if (contents == null)
   1 | if (targets == null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   contents | targets | VARIABLE_NAME_MISMATCH
   org.eclipse.emf.ecore.resource.impl.ResourceImpl.ContentsEList | java.util.List | SUBCLASS_TYPE_MISMATCH

   1

       if (targets == null)

   2

       contents = new ContentsEList<EObject>();

   2 | contents = new ContentsEList<EObject>();
   2 | targets = new ArrayList<Notifier>();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   contents | targets | VARIABLE_NAME_MISMATCH
   org.eclipse.emf.ecore.resource.impl.ResourceImpl.ContentsEList | java.util.List | SUBCLASS_TYPE_MISMATCH
   org.eclipse.emf.ecore.resource.impl.ResourceImpl.ContentsEList | java.util.ArrayList | SUBCLASS_TYPE_MISMATCH
   org.eclipse.emf.ecore.EObject | org.eclipse.emf.common.notify.Notifier | SUBCLASS_TYPE_MISMATCH

   2

       targets = new ArrayList<Notifier>();

   3 | targets.add(target);

   Preondition Violations
   Unmatched statement targets.add(target); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted

   3

       targets.add(target);

   3

       return contents;

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Unmatched statement targets.add(target); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
   2 | The refactoring of the clones is infeasible, because classes org.eclipse.emf.ecore.resource.impl.ResourceImpl and org.eclipse.emf.common.notify.impl.SingletonAdapterImpl do not have a common superclass