EStructuralFeature feature = sourceEntry.getEStructuralFeature(); if (isMany(feature)) { FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature); int featureTargetIndex = -1; int featureSourceIndex = -1; int count = 0; for (int i = 0, maxIndex= targetIndex > sourceIndex ? targetIndex : sourceIndex; i <= maxIndex; ++i) { if (i == sourceIndex) { featureSourceIndex = count++; } else { Entry entry = entries[i]; boolean isValid = validator.isValid(entry.getEStructuralFeature()); if (i == targetIndex) { featureTargetIndex = i == maxIndex && !isValid ? count-1 : count; } if (isValid) { ++count; } } } Entry result = super.move(targetIndex, sourceIndex); if (featureSourceIndex != featureTargetIndex) { dispatchNotification (new ENotificationImpl (owner, Notification.MOVE, feature, new Integer(featureSourceIndex), sourceEntry.getValue(), featureTargetIndex)); } return result; }
EStructuralFeature feature = sourceEntry.getEStructuralFeature(); if (isMany(feature)) { FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature); int featureTargetIndex = -1; int featureSourceIndex = -1; int count = 0; for (int i = 0, maxIndex= targetIndex > sourceIndex ? targetIndex : sourceIndex; i <= maxIndex; ++i) { if (i == sourceIndex) { featureSourceIndex = count++; } else { Entry entry = delegateGet(i); boolean isValid = validator.isValid(entry.getEStructuralFeature()); if (i == targetIndex) { featureTargetIndex = i == maxIndex && !isValid ? count-1 : count; } if (isValid) { ++count; } } } Entry result = super.move(targetIndex, sourceIndex); if (featureSourceIndex != featureTargetIndex) { dispatchNotification (new ENotificationImpl (owner, Notification.MOVE, feature, featureSourceIndex, sourceEntry.getValue(), featureTargetIndex)); } return result; }
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/BasicFeatureMap.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/DelegatingFeatureMap.java
Method name: Entry move(int, int) Method name: Entry move(int, int)
Number of AST nodes: 19 Number of AST nodes: 19
1
EStructuralFeature feature = sourceEntry.getEStructuralFeature();
1
EStructuralFeature feature = sourceEntry.getEStructuralFeature();
2
      if (isMany(feature))
2
      if (isMany(feature))
3
      {
3
      {
4
        FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature);
4
        FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature);
5
        int featureTargetIndex = -1;
5
        int featureTargetIndex = -1;
6
        int featureSourceIndex = -1;
6
        int featureSourceIndex = -1;
7
        int count = 0;
7
        int count = 0;
8
        for (int i = 0, maxIndex= targetIndex > sourceIndex ? targetIndex : sourceIndex; i <= maxIndex; ++i)
8
        for (int i = 0, maxIndex= targetIndex > sourceIndex ? targetIndex : sourceIndex; i <= maxIndex; ++i)
9
        {
9
        {
10
          if (i == sourceIndex)
10
          if (i == sourceIndex)
11
          {
11
          {
12
            featureSourceIndex = count++;
12
            featureSourceIndex = count++;
13
          }
13
          }
14
          else
14
          else
15
          {
15
          {
16
            Entry entry = entries[i];
16
            Entry entry = delegateGet(i);
17
            boolean isValid = validator.isValid(entry.getEStructuralFeature());
17
            boolean isValid = validator.isValid(entry.getEStructuralFeature());
18
            if (i == targetIndex)
18
            if (i == targetIndex)
19
            {
19
            {
20
              featureTargetIndex = i == maxIndex && !isValid ? count-1 : count;
20
              featureTargetIndex = i == maxIndex && !isValid ? count-1 : count;
21
            }
21
            }
22
            
22
            
23
            if (isValid)
23
            if (isValid)
24
            {
24
            {
25
                ++count;
25
                ++count;
26
            }
26
            }
27
          }
27
          }
28
        }
28
        }
29
        Entry result = super.move(targetIndex, sourceIndex);
29
        Entry result = super.move(targetIndex, sourceIndex);
30
        
30
        
31
        if (featureSourceIndex != featureTargetIndex)
31
        if (featureSourceIndex != featureTargetIndex)
32
        {
32
        {
33
          dispatchNotification
33
          dispatchNotification
34
            (new ENotificationImpl
34
            (new ENotificationImpl
35
               (owner, 
35
               (owner, 
36
                Notification.MOVE, 
36
                Notification.MOVE, 
37
                feature,
37
                feature,
38
                new Integer(featureSourceIndex), 
38
                featureSourceIndex, 
39
                sourceEntry.getValue(),
39
                sourceEntry.getValue(),
40
                featureTargetIndex));
40
                featureTargetIndex));
41
        }
41
        }
42
        return result;
42
        return result;
43
      }
43
      }
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 in different classes having the same super class
Number of node comparisons85
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements18
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)4.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    6
    EStructuralFeature feature = sourceEntry.getEStructuralFeature();
    5
    EStructuralFeature feature = sourceEntry.getEStructuralFeature();
    7
    if (isMany(feature))
    6
    if (isMany(feature))
    8
    FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature);
    7
    FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature);
    9
    int featureTargetIndex = -1;
    8
    int featureTargetIndex = -1;
    10
    int featureSourceIndex = -1;
    9
    int featureSourceIndex = -1;
    11
    int count = 0;
    10
    int count = 0;
    12
    for (int i = 0, maxIndex = targetIndex > sourceIndex ? targetIndex : sourceIndex; i <= maxIndex; ++i)
    11
    for (int i = 0, maxIndex = targetIndex > sourceIndex ? targetIndex : sourceIndex; i <= maxIndex; ++i)
    13
    if (i == sourceIndex)
    12
    if (i == sourceIndex)
    14
    featureSourceIndex = count++;
    13
    featureSourceIndex = count++;
    else
    else
    15
    Entry entry = entries[i];
    15
    Entry entry = entries[i];
    14
    Entry entry = delegateGet(i);
    Differences
    Expression1Expression2Difference
    entries[i]delegateGet(i)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression entries[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression delegateGet(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14
    Entry entry = delegateGet(i);
    16
    boolean isValid = validator.isValid(entry.getEStructuralFeature());
    15
    boolean isValid = validator.isValid(entry.getEStructuralFeature());
    17
    if (i == targetIndex)
    16
    if (i == targetIndex)
    18
    featureTargetIndex = i == maxIndex && !isValid ? count - 1 : count;
    17
    featureTargetIndex = i == maxIndex && !isValid ? count - 1 : count;
    19
    if (isValid)
    18
    if (isValid)
    20
    ++count;
    19
    ++count;
    21
    Entry result = super.move(targetIndex, sourceIndex);
    20
    Entry result = super.move(targetIndex, sourceIndex);
    22
    if (featureSourceIndex != featureTargetIndex)
    21
    if (featureSourceIndex != featureTargetIndex)
                                                                                                                                                                                                                                                                                                
    22
    dispatchNotification(new ENotificationImpl(owner, Notification.MOVE, feature, featureSourceIndex, sourceEntry.getValue(), featureTargetIndex));
    Preondition Violations
    Unmatched statement dispatchNotification(new ENotificationImpl(owner,Notification.MOVE,feature,featureSourceIndex,sourceEntry.getValue(),featureTargetIndex)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    22
    dispatchNotification(new ENotificationImpl(owner, Notification.MOVE, feature, featureSourceIndex, sourceEntry.getValue(), featureTargetIndex));
    23
    dispatchNotification(new ENotificationImpl(owner, Notification.MOVE, feature, new Integer(featureSourceIndex), sourceEntry.getValue(), featureTargetIndex));
    23
    dispatchNotification(new ENotificationImpl(owner, Notification.MOVE, feature, new Integer(featureSourceIndex), sourceEntry.getValue(), featureTargetIndex));
    Preondition Violations
    Unmatched statement dispatchNotification(new ENotificationImpl(owner,Notification.MOVE,feature,new Integer(featureSourceIndex),sourceEntry.getValue(),featureTargetIndex)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                                                                                                                                                                                                                                          
    24
    return result;
    23
    return result;
    Precondition Violations (5)
    Row Violation
    1Expression entries[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression delegateGet(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Unmatched statement dispatchNotification(new ENotificationImpl(owner,Notification.MOVE,feature,featureSourceIndex,sourceEntry.getValue(),featureTargetIndex)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement dispatchNotification(new ENotificationImpl(owner,Notification.MOVE,feature,new Integer(featureSourceIndex),sourceEntry.getValue(),featureTargetIndex)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Clone fragment #1 returns variables feature, featureTargetIndex, featureSourceIndex , while Clone fragment #2 returns variables feature, featureTargetIndex, featureSourceIndex