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<EStructuralFeature> attributes = getAttributes(eClass); if (!attributes.isEmpty()) { if (result == null) { return attributes; } else { if (!changeable) { result = new UniqueEList<EStructuralFeature>(result); } result.addAll(attributes); return result; } } else { return result == null ? Collections.<EStructuralFeature>emptyList() : result; }
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); } } } List<EStructuralFeature> elements = getElements(eClass); if (!elements.isEmpty()) { if (result == null) { return elements; } else { if (!changeable) { result = new UniqueEList<EStructuralFeature>(result); } result.addAll(elements); return result; } } else { return result == null ? Collections.<EStructuralFeature>emptyList() : result; }
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: 22 Number of AST nodes: 22
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
    }
25
    List<EStructuralFeature> attributes = getAttributes(eClass);
25
    List<EStructuralFeature> elements = getElements(eClass);
26
    if (!attributes.isEmpty())
26
    if (!elements.isEmpty())
27
    {
27
    {
28
      if (result == null)
28
      if (result == null)
29
      {
29
      {
30
        return attributes;
30
        return elements;
31
      }
31
      }
32
      else
32
      else
33
      {
33
      {
34
        if (!changeable)
34
        if (!changeable)
35
        {
35
        {
36
          result = new UniqueEList<EStructuralFeature>(result);
36
          result = new UniqueEList<EStructuralFeature>(result);
37
        }
37
        }
38
        result.addAll(attributes);
38
        result.addAll(elements);
39
        return result;
39
        return result;
40
      }
40
      }
41
    }
41
    }
42
    else
42
    else
43
    {
43
    {
44
      return result == null ? Collections.<EStructuralFeature>emptyList() : result;
44
      return result == null ? Collections.<EStructuralFeature>emptyList() : result;
45
    }
45
    }
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.9
Clones locationClones are declared in the same class
Number of node comparisons78
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements22
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)12.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);
    14
    List<EStructuralFeature> attributes = getAttributes(eClass);
    14
    List<EStructuralFeature> attributes = getAttributes(eClass);
    14
    List<EStructuralFeature> elements = getElements(eClass);
    Differences
    Expression1Expression2Difference
    attributeselementsVARIABLE_NAME_MISMATCH
    getAttributesgetElementsMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression getAttributes(eClass) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression getElements(eClass) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14
    List<EStructuralFeature> elements = getElements(eClass);
    15
    if (!attributes.isEmpty())
    15
    if (!attributes.isEmpty())
    15
    if (!elements.isEmpty())
    Differences
    Expression1Expression2Difference
    attributeselementsVARIABLE_NAME_MISMATCH
    15
    if (!elements.isEmpty())
    16
    if (result == null)
    16
    if (result == null)
    17
    return attributes;
    17
    return attributes;
    17
    return elements;
    Differences
    Expression1Expression2Difference
    attributeselementsVARIABLE_NAME_MISMATCH
    17
    return elements;
    else
    else
    18
    if (!changeable)
    18
    if (!changeable)
    19
    result = new UniqueEList<EStructuralFeature>(result);
    19
    result = new UniqueEList<EStructuralFeature>(result);
    20
    result.addAll(attributes);
    20
    result.addAll(attributes);
    20
    result.addAll(elements);
    Differences
    Expression1Expression2Difference
    attributeselementsVARIABLE_NAME_MISMATCH
    20
    result.addAll(elements);
    21
    return result;
    21
    return result;
    else
    else
    22
    return result == null ? Collections.<EStructuralFeature>emptyList() : result;
    22
    return result == null ? Collections.<EStructuralFeature>emptyList() : result;
    Precondition Violations (4)
    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
    3Expression getAttributes(eClass) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression getElements(eClass) cannot be parameterized, because it has dependencies to/from statements that will be extracted