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 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.9 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 85 |
Number of mapped statements | 18 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 4.7 |
Clone type | Type 2 |
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]; |
| 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)); | |||||||||||||
23 | dispatchNotification(new ENotificationImpl(owner, Notification.MOVE, feature, new Integer(featureSourceIndex), sourceEntry.getValue(), featureTargetIndex)); |
| | |||||||||||||
24 | return result; | 23 | return result; |
Row | Violation |
---|---|
1 | Expression entries[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression delegateGet(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | 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 |
4 | 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 |
5 | Clone fragment #1 returns variables feature, featureTargetIndex, featureSourceIndex , while Clone fragment #2 returns variables feature, featureTargetIndex, featureSourceIndex |