int count = 0; for (InternalEObject parent = ((InternalEObject)eObject).eInternalContainer(); parent != null; parent = parent.eInternalContainer()) { if (++count > 100000) { return getRootContainer(parent, false); } result = parent; if (parent == eObject) { throw new IllegalStateException("There is a cycle in the containment hierarchy of " + eObject); } }
int count = 0; for (EObject parent = eObject.eContainer(); parent != null; parent = parent.eContainer()) { if (++count > 100000) { return getRootContainer(parent); } result = parent; if (parent == eObject) { throw new IllegalStateException("There is a cycle in the containment hierarchy of " + eObject); } }
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/EcoreUtil.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/EcoreUtil.java
Method name: EObject getRootContainer(EObject, boolean) Method name: EObject getRootContainer(EObject)
Number of AST nodes: 7 Number of AST nodes: 7
1
int count = 0;
1
int count = 0;
2
        for (InternalEObject parent = ((InternalEObject)eObject).eInternalContainer(); parent != null; parent = parent.eInternalContainer())
2
      for (EObject parent = eObject.eContainer(); parent != null; parent = parent.eContainer())
3
        {
3
      {
4
          if (++count > 100000)
4
        if (++count > 100000)
5
          {
5
        {
6
            return getRootContainer(parent, false);
6
          return getRootContainer(parent);
7
          }
7
        }
8
          result = parent;
8
        result = parent;
9
          if (parent == eObject)
9
        if (parent == eObject)
10
          {
10
        
11
  
11
{
12
          throw new IllegalStateException("There is a cycle in the containment hierarchy of " + eObject);
12
          throw new IllegalStateException("There is a cycle in the containment hierarchy of " + eObject);
13
          }
13
        
14
  
14
}
15
      }
15
      }
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)0.3
Clones locationClones are declared in the same class
Number of node comparisons15
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    7
    if (++count > 100000)
    5
    if (++count > 100000)
    8
    return getRootContainer(parent, false);
    8
    return getRootContainer(parent, false);
    6
    return getRootContainer(parent);
    Differences
    Expression1Expression2Difference
    getRootContainer(parent,false)getRootContainer(parent)ARGUMENT_NUMBER_MISMATCH
    6
    return getRootContainer(parent);
                                      
    7
    result = parent;
    9
    result = parent;
                                      
    10
    if (parent == eObject)
    10
    if (parent == eObject)
    8
    if (parent == eObject)
    Differences
    Expression1Expression2Difference
    org.eclipse.emf.ecore.InternalEObjectorg.eclipse.emf.ecore.EObjectVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.eclipse.emf.ecore.InternalEObject of variable parent does not match with type org.eclipse.emf.ecore.EObject of variable parent
    • Make classes org.eclipse.emf.ecore.InternalEObject and org.eclipse.emf.ecore.EObject extend a common superclass
    8
    if (parent == eObject)
    11
    throw new IllegalStateException("There is a cycle in the containment hierarchy of " + eObject);
    9
    throw new IllegalStateException("There is a cycle in the containment hierarchy of " + eObject);
    Precondition Violations (1)
    Row Violation
    1Type org.eclipse.emf.ecore.InternalEObject of variable parent does not match with type org.eclipse.emf.ecore.EObject of variable parent