EStructuralFeature feature = eStructuralFeatures[featureCursor++]; if (isIncluded(feature) && (!useIsSet() || eObject.eIsSet(feature))) { Object value = eObject.eGet(feature, resolve()); isHandlingFeatureMap = FeatureMapUtil.isFeatureMap(feature); if (isHandlingFeatureMap || feature.isMany()) { if (resolve()) { @SuppressWarnings("unchecked") List<E> newValueList = (List<E>)value; valueList = newValueList; } else { @SuppressWarnings("unchecked") InternalEList<E> newValueList = (InternalEList<E>)value; valueList = valueInternalEList = newValueList; } if (valueList instanceof RandomAccess) { values = null; valueListSize = valueList.size(); valueListIndex = 0; } else { values = valueInternalEList == null ? valueList.listIterator() : valueInternalEList.basicListIterator(); } if (values == null ? scanNext() : scanNext(values)) { Object result = values == null ? valueInternalEList == null ? valueList.get(valueListIndex++) : valueInternalEList.basicGet(valueListIndex++) : values.next(); if (isHandlingFeatureMap) { FeatureMap.Entry entry = (FeatureMap.Entry)result; preparedFeature = entry.getEStructuralFeature(); @SuppressWarnings("unchecked") E newPreparedResult = (E)entry.getValue(); preparedResult = newPreparedResult; } else { @SuppressWarnings("unchecked") E newPreparedResult = (E)result; preparedResult = newPreparedResult; preparedFeature = feature; } prepared = 3; return true; } } else if (value != null) { valueList = null; values = null; @SuppressWarnings("unchecked") E newPreparedResult = (E)value; preparedResult = newPreparedResult; preparedFeature = feature; prepared = 2; return true; } }
EStructuralFeature feature = eStructuralFeatures[--featureCursor]; if (isIncluded(feature) && (!useIsSet() || eObject.eIsSet(feature))) { Object value = eObject.eGet(feature, resolve()); isHandlingFeatureMap = FeatureMapUtil.isFeatureMap(feature); if (isHandlingFeatureMap || feature.isMany()) { if (resolve()) { @SuppressWarnings("unchecked") List<E> newValueList = (List<E>)value; valueList = newValueList; } else { @SuppressWarnings("unchecked") InternalEList<E> newValueList = (InternalEList<E>)value; valueList = valueInternalEList = newValueList; } if (valueList instanceof RandomAccess) { valueListSize = valueList.size(); valueListIndex = valueListSize; } else { values = valueInternalEList == null ? valueList.listIterator(valueList.size()) : valueInternalEList.basicListIterator(valueList.size()); } if (values == null ? scanPrevious() : scanPrevious(values)) { Object result = values == null ? valueInternalEList == null ? valueList.get(--valueListIndex) : valueInternalEList.basicGet(--valueListIndex) : values.previous(); if (isHandlingFeatureMap) { FeatureMap.Entry entry = (FeatureMap.Entry)result; preparedFeature = entry.getEStructuralFeature(); @SuppressWarnings("unchecked") E newPreparedResult = (E)entry.getValue(); preparedResult = newPreparedResult; } else { @SuppressWarnings("unchecked") E newPreparedResult = (E)result; preparedResult = newPreparedResult; preparedFeature = feature; } prepared = -3; return true; } } else if (value != null) { valueList = null; values = null; @SuppressWarnings("unchecked") E newPreparedResult = (E)value; preparedResult = newPreparedResult; preparedFeature = feature; prepared = -2; return true; } }
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/EContentsEList.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/EContentsEList.java
Method name: boolean hasNext() Method name: boolean hasPrevious()
Number of AST nodes: 35 Number of AST nodes: 34
1
EStructuralFeature feature = eStructuralFeatures[featureCursor++];
1
EStructuralFeature feature = eStructuralFeatures[--featureCursor];
2
              if (isIncluded(feature) && (!useIsSet() || eObject.eIsSet(feature)))
2
              if (isIncluded(feature) && (!useIsSet() || eObject.eIsSet(feature)))
3
              {
3
              {
4
                Object value = eObject.eGet(feature, resolve());
4
                Object value = eObject.eGet(feature, resolve());
5
                isHandlingFeatureMap = FeatureMapUtil.isFeatureMap(feature);
5
                isHandlingFeatureMap = FeatureMapUtil.isFeatureMap(feature);
6
                if (isHandlingFeatureMap || feature.isMany())
6
                if (isHandlingFeatureMap || feature.isMany())
7
                {
7
                {
8
                  if (resolve())
8
                  if (resolve())
9
                  {
9
                  {
10
                    @SuppressWarnings("unchecked") List<E> newValueList = (List<E>)value;
10
                    @SuppressWarnings("unchecked") List<E> newValueList = (List<E>)value;
11
                    valueList = newValueList;
11
                    valueList = newValueList;
12
                  }
12
                  }
13
                  else
13
                  else
14
                  {
14
                  {
15
                    @SuppressWarnings("unchecked") InternalEList<E> newValueList = (InternalEList<E>)value;
15
                    @SuppressWarnings("unchecked") InternalEList<E> newValueList = (InternalEList<E>)value;
16
                    valueList = valueInternalEList = newValueList;
16
                    valueList = valueInternalEList = newValueList;
17
                  }
17
                  }
18
                  if (valueList instanceof RandomAccess)
18
                  if (valueList instanceof RandomAccess)
19
                  {
19
                  {
20
                    values = null;
21
                    valueListSize = valueList.size();
20
                    valueListSize = valueList.size();
22
                    valueListIndex = 0;
21
                    valueListIndex = valueListSize;
23
                  }
22
                  }
24
                  else
23
                  else
25
                  {
24
                  {
26
                    values = 
25
                    values = 
27
                      valueInternalEList == null ? 
26
                      valueInternalEList == null ? 
28
                        valueList.listIterator() : 
27
                        valueList.listIterator(valueList.size()) : 
29
                        valueInternalEList.basicListIterator();
28
                        valueInternalEList.basicListIterator(valueList.size());
30
                  }
29
                  }
31
                  if (values == null ? scanNext() : scanNext(values))
30
                  if (values == null ? scanPrevious() : scanPrevious(values))
32
                  {
31
                  {
33
                    Object result = 
32
                    Object result =
34
 
35
                      values == null ? 
33
                      values == null ? 
36
                         valueInternalEList == null ? 
34
                        valueInternalEList == null ? 
37
                           valueList.get(valueListIndex++) : 
35
                          valueList.get(--valueListIndex) : 
38
                           valueInternalEList.basicGet(valueListIndex++) : 
36
                          valueInternalEList.basicGet(--valueListIndex) : 
39
                         values.next();
37
                        values.previous();
40
                    if (isHandlingFeatureMap)
38
                    if (isHandlingFeatureMap)
41
                    {
39
                    {
42
                      FeatureMap.Entry entry = (FeatureMap.Entry)result; 
40
                      FeatureMap.Entry entry = (FeatureMap.Entry)result; 
43
                      preparedFeature = entry.getEStructuralFeature();
41
                      preparedFeature = entry.getEStructuralFeature();
44
                      @SuppressWarnings("unchecked") E newPreparedResult = (E)entry.getValue();
42
                      @SuppressWarnings("unchecked") E newPreparedResult = (E)entry.getValue();
45
                      preparedResult = newPreparedResult;
43
                      preparedResult = newPreparedResult;
46
                    }
44
                    }
47
                    else
45
                    else
48
                    {
46
                    {
49
                      @SuppressWarnings("unchecked") E newPreparedResult = (E)result;
47
                      @SuppressWarnings("unchecked") E newPreparedResult = (E)result;
50
                      preparedResult = newPreparedResult;
48
                      preparedResult = newPreparedResult;
51
                      preparedFeature = feature;
49
                      preparedFeature = feature;
52
                    }
50
                    }
53
                    prepared = 3;
51
                    prepared = -3;
54
                    return true;
52
                    return true;
55
                  }
53
                  }
56
                }
54
                }
57
                else if (value != null)
55
                else if (value != null)
58
                {
56
                {
59
                  valueList = null;
57
                  valueList = null;
60
                  values = null;
58
                  values = null;
61
                  @SuppressWarnings("unchecked") E newPreparedResult = (E)value;
59
                  @SuppressWarnings("unchecked") E newPreparedResult = (E)value;
62
                  preparedResult = newPreparedResult;
60
                  preparedResult = newPreparedResult;
63
                  preparedFeature = feature;
61
                  preparedFeature = feature;
64
                  prepared = 2;
62
                  prepared = -2;
65
                  return true;
63
                  return true;
66
                }
64
                }
67
              }
65
              }
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)1.6
Clones locationClones are declared in the same class
Number of node comparisons222
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements34
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)19.2
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    14
    EStructuralFeature feature = eStructuralFeatures[featureCursor++];
    14
    EStructuralFeature feature = eStructuralFeatures[--featureCursor];
    15
    if (isIncluded(feature) && (!useIsSet() || eObject.eIsSet(feature)))
    15
    if (isIncluded(feature) && (!useIsSet() || eObject.eIsSet(feature)))
    16
    Object value = eObject.eGet(feature, resolve());
    16
    Object value = eObject.eGet(feature, resolve());
    17
    isHandlingFeatureMap = FeatureMapUtil.isFeatureMap(feature);
    17
    isHandlingFeatureMap = FeatureMapUtil.isFeatureMap(feature);
    18
    if (isHandlingFeatureMap || feature.isMany())
    18
    if (isHandlingFeatureMap || feature.isMany())
    19
    if (resolve())
    19
    if (resolve())
    20
    @SuppressWarnings("unchecked") List<E> newValueList = (List<E>)value;
    20
    @SuppressWarnings("unchecked") List<E> newValueList = (List<E>)value;
    21
    valueList = newValueList;
    21
    valueList = newValueList;
    else
    else
    22
    @SuppressWarnings("unchecked") InternalEList<E> newValueList = (InternalEList<E>)value;
    22
    @SuppressWarnings("unchecked") InternalEList<E> newValueList = (InternalEList<E>)value;
    23
    valueList = valueInternalEList = newValueList;
    23
    valueList = valueInternalEList = newValueList;
    24
    if (valueList instanceof RandomAccess)
    24
    if (valueList instanceof RandomAccess)
    25
    values = null;
    25
    values = null;
    Preondition Violations
    Unmatched statement values=null; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                    
    26
    valueListSize = valueList.size();
    25
    valueListSize = valueList.size();
    27
    valueListIndex = 0;
    27
    valueListIndex = 0;
    26
    valueListIndex = valueListSize;
    Differences
    Expression1Expression2Difference
    0valueListSizeTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression valueListSize cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26
    valueListIndex = valueListSize;
    else
    else
    28
    values = valueInternalEList == null ? valueList.listIterator() : valueInternalEList.basicListIterator();
    28
    values = valueInternalEList == null ? valueList.listIterator() : valueInternalEList.basicListIterator();
    27
    values = valueInternalEList == null ? valueList.listIterator(valueList.size()) : valueInternalEList.basicListIterator(valueList.size());
    Differences
    Expression1Expression2Difference
    valueList.listIterator()valueList.listIterator(valueList.size())ARGUMENT_NUMBER_MISMATCH
    valueInternalEList.basicListIterator()valueInternalEList.basicListIterator(valueList.size())ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression valueList.listIterator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression valueList.listIterator(valueList.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression valueInternalEList.basicListIterator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression valueInternalEList.basicListIterator(valueList.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    27
    values = valueInternalEList == null ? valueList.listIterator(valueList.size()) : valueInternalEList.basicListIterator(valueList.size());
    29
    if (values == null ? scanNext() : scanNext(values))
    29
    if (values == null ? scanNext() : scanNext(values))
    28
    if (values == null ? scanPrevious() : scanPrevious(values))
    Differences
    Expression1Expression2Difference
    scanNextscanPreviousMETHOD_INVOCATION_NAME_MISMATCH
    scanNextscanPreviousMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression scanNext(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression scanPrevious(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    28
    if (values == null ? scanPrevious() : scanPrevious(values))
    30
    Object result = values == null ? valueInternalEList == null ? valueList.get(valueListIndex++) : valueInternalEList.basicGet(valueListIndex++) : values.next();
    30
    Object result = values == null ? valueInternalEList == null ? valueList.get(valueListIndex++) : valueInternalEList.basicGet(valueListIndex++) : values.next();
    29
    Object result = values == null ? valueInternalEList == null ? valueList.get(--valueListIndex) : valueInternalEList.basicGet(--valueListIndex) : values.previous();
    Differences
    Expression1Expression2Difference
    nextpreviousMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression values.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression values.previous() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    29
    Object result = values == null ? valueInternalEList == null ? valueList.get(--valueListIndex) : valueInternalEList.basicGet(--valueListIndex) : values.previous();
    31
    if (isHandlingFeatureMap)
    30
    if (isHandlingFeatureMap)
    32
    FeatureMap.Entry entry = (FeatureMap.Entry)result;
    31
    FeatureMap.Entry entry = (FeatureMap.Entry)result;
    33
    preparedFeature = entry.getEStructuralFeature();
    32
    preparedFeature = entry.getEStructuralFeature();
    34
    @SuppressWarnings("unchecked") E newPreparedResult = (E)entry.getValue();
    33
    @SuppressWarnings("unchecked") E newPreparedResult = (E)entry.getValue();
    35
    preparedResult = newPreparedResult;
    34
    preparedResult = newPreparedResult;
    else
    else
    36
    @SuppressWarnings("unchecked") E newPreparedResult = (E)result;
    35
    @SuppressWarnings("unchecked") E newPreparedResult = (E)result;
    37
    preparedResult = newPreparedResult;
    36
    preparedResult = newPreparedResult;
    38
    preparedFeature = feature;
    37
    preparedFeature = feature;
    39
    prepared = 3;
    39
    prepared = 3;
    38
    prepared = -3;
    Differences
    Expression1Expression2Difference
    3-3TYPE_COMPATIBLE_REPLACEMENT
    38
    prepared = -3;
    40
    return true;
    40
    return true;
    39
    return true;
    Preondition Violations
    Conditional return true;
    Conditional return true;
    39
    return true;
    41
    else if (value != null)
    40
    else if (value != null)
    42
    valueList = null;
    41
    valueList = null;
    43
    values = null;
    42
    values = null;
    44
    @SuppressWarnings("unchecked") E newPreparedResult = (E)value;
    43
    @SuppressWarnings("unchecked") E newPreparedResult = (E)value;
    45
    preparedResult = newPreparedResult;
    44
    preparedResult = newPreparedResult;
    46
    preparedFeature = feature;
    45
    preparedFeature = feature;
    47
    prepared = 2;
    47
    prepared = 2;
    46
    prepared = -2;
    Differences
    Expression1Expression2Difference
    2-2TYPE_COMPATIBLE_REPLACEMENT
    46
    prepared = -2;
    48
    return true;
    48
    return true;
    47
    return true;
    Preondition Violations
    Conditional return true;
    Conditional return true;
    47
    return true;
    Precondition Violations (14)
    Row Violation
    1Unmatched statement values=null; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression valueListSize cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression valueList.listIterator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression valueList.listIterator(valueList.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression valueInternalEList.basicListIterator() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression valueInternalEList.basicListIterator(valueList.size()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression scanNext(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression scanPrevious(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression values.next() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression values.previous() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Conditional return true;
    12Conditional return true;
    13Conditional return true;
    14Conditional return true;