List<EClass> superTypes = eClass.getESuperTypes(); List<EStructuralFeature> result = null; boolean changeable = false; for (int i = 0, size = superTypes.size(); i < size; ++i) { EClass eSuperType = superTypes.get(i); List<EStructuralFeature> allAttributes = getAllAttributes(eSuperType); if (!allAttributes.isEmpty()) { if (result == null) { result = allAttributes; } else { if (!changeable) { changeable = true; result = new UniqueEList<EStructuralFeature>(result); } result.addAll(allAttributes); } } }
List<EClass> superTypes = eClass.getESuperTypes(); List<EStructuralFeature> result = null; boolean changeable = false; for (int i = 0, size = superTypes.size(); i < size; ++i) { EClass eSuperType = superTypes.get(i); List<EStructuralFeature> allElements = getAllElements(eSuperType); if (!allElements.isEmpty()) { if (result == null) { result = allElements; } else { if (!changeable) { changeable = true; result = new UniqueEList<EStructuralFeature>(result); } result.addAll(allElements); } } }
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/BasicExtendedMetaData.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/BasicExtendedMetaData.java
Method name: List getAllAttributes(EClass) Method name: List getAllElements(EClass)
Number of AST nodes: 13 Number of AST nodes: 13
1
List<EClass> superTypes = eClass.getESuperTypes();
1
List<EClass> superTypes = eClass.getESuperTypes();
2
    List<EStructuralFeature> result = null;
2
    List<EStructuralFeature> result = null;
3
    boolean changeable = false;
3
    boolean changeable = false;
4
    for (int i = 0, size = superTypes.size(); i < size; ++i) 
4
    for (int i = 0, size = superTypes.size(); i < size; ++i) 
5
    {
5
    {
6
      EClass eSuperType = superTypes.get(i);
6
      EClass eSuperType = superTypes.get(i);
7
      List<EStructuralFeature> allAttributes =  getAllAttributes(eSuperType);
7
      List<EStructuralFeature> allElements =  getAllElements(eSuperType);
8
      if (!allAttributes.isEmpty())
8
      if (!allElements.isEmpty())
9
      {
9
      {
10
        if (result == null)
10
        if (result == null)
11
        {
11
        {
12
          result = allAttributes;
12
          result = allElements;
13
        }
13
        }
14
        else
14
        else
15
        {
15
        {
16
          if (!changeable)
16
          if (!changeable)
17
          {
17
          {
18
            changeable = true;
18
            changeable = true;
19
            result = new UniqueEList<EStructuralFeature>(result);
19
            result = new UniqueEList<EStructuralFeature>(result);
20
          }
20
          }
21
          result.addAll(allAttributes);
21
          result.addAll(allElements);
22
        }
22
        }
23
      }
23
      }
24
    }
24
    }
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.5
Clones locationClones are declared in the same class
Number of node comparisons37
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements13
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)10.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    List<EClass> superTypes = eClass.getESuperTypes();
    1
    List<EClass> superTypes = eClass.getESuperTypes();
    2
    List<EStructuralFeature> result = null;
    2
    List<EStructuralFeature> result = null;
    3
    boolean changeable = false;
    3
    boolean changeable = false;
    4
    for (int i = 0, size = superTypes.size(); i < size; ++i)
    4
    for (int i = 0, size = superTypes.size(); i < size; ++i)
    5
    EClass eSuperType = superTypes.get(i);
    5
    EClass eSuperType = superTypes.get(i);
    6
    List<EStructuralFeature> allAttributes = getAllAttributes(eSuperType);
    6
    List<EStructuralFeature> allAttributes = getAllAttributes(eSuperType);
    6
    List<EStructuralFeature> allElements = getAllElements(eSuperType);
    Differences
    Expression1Expression2Difference
    allAttributesallElementsVARIABLE_NAME_MISMATCH
    getAllAttributesgetAllElementsMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression getAllAttributes(eSuperType) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression getAllElements(eSuperType) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    List<EStructuralFeature> allElements = getAllElements(eSuperType);
    7
    if (!allAttributes.isEmpty())
    7
    if (!allAttributes.isEmpty())
    7
    if (!allElements.isEmpty())
    Differences
    Expression1Expression2Difference
    allAttributesallElementsVARIABLE_NAME_MISMATCH
    7
    if (!allElements.isEmpty())
    8
    if (result == null)
    8
    if (result == null)
    9
    result = allAttributes;
    9
    result = allAttributes;
    9
    result = allElements;
    Differences
    Expression1Expression2Difference
    allAttributesallElementsVARIABLE_NAME_MISMATCH
    9
    result = allElements;
    else
    else
    10
    if (!changeable)
    10
    if (!changeable)
    11
    changeable = true;
    11
    changeable = true;
    12
    result = new UniqueEList<EStructuralFeature>(result);
    12
    result = new UniqueEList<EStructuralFeature>(result);
    13
    result.addAll(allAttributes);
    13
    result.addAll(allAttributes);
    13
    result.addAll(allElements);
    Differences
    Expression1Expression2Difference
    allAttributesallElementsVARIABLE_NAME_MISMATCH
    13
    result.addAll(allElements);
    Precondition Violations (3)
    Row Violation
    1Expression getAllAttributes(eSuperType) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression getAllElements(eSuperType) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Clone fragment #1 returns variables result, changeable , while Clone fragment #2 returns variables result, changeable