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: 17 | Number of AST nodes: 17 | |||
1 | FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature);↵ | 1 | FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature);↵ | |
2 | int featureTargetIndex = -1;↵ | 2 | int featureTargetIndex = -1;↵ | |
3 | int featureSourceIndex = -1;↵ | 3 | int featureSourceIndex = -1;↵ | |
4 | int count = 0;↵ | 4 | int count = 0;↵ | |
5 | for (int i = 0, maxIndex= targetIndex > sourceIndex ? targetIndex : sourceIndex; i <= maxIndex; ++i)↵ | 5 | for (int i = 0, maxIndex= targetIndex > sourceIndex ? targetIndex : sourceIndex; i <= maxIndex; ++i)↵ | |
6 | {↵ | 6 | {↵ | |
7 | if (i == sourceIndex)↵ | 7 | if (i == sourceIndex)↵ | |
8 | {↵ | 8 | {↵ | |
9 | featureSourceIndex = count++;↵ | 9 | featureSourceIndex = count++;↵ | |
10 | }↵ | 10 | }↵ | |
11 | else↵ | 11 | else↵ | |
12 | {↵ | 12 | {↵ | |
13 | Entry entry = entries[i];↵ | 13 | Entry entry = delegateGet(i);↵ | |
14 | boolean isValid = validator.isValid(entry.getEStructuralFeature());↵ | 14 | boolean isValid = validator.isValid(entry.getEStructuralFeature());↵ | |
15 | if (i == targetIndex)↵ | 15 | if (i == targetIndex)↵ | |
16 | {↵ | 16 | {↵ | |
17 | featureTargetIndex = i == maxIndex && !isValid ? count-1 : count;↵ | 17 | featureTargetIndex = i == maxIndex && !isValid ? count-1 : count;↵ | |
18 | }↵ | 18 | }↵ | |
19 | ↵ | 19 | ↵ | |
20 | if (isValid)↵ | 20 | if (isValid)↵ | |
21 | {↵ | 21 | {↵ | |
22 | ++count;↵ | 22 | ++count;↵ | |
23 | }↵ | 23 | }↵ | |
24 | }↵ | 24 | }↵ | |
25 | }↵ | 25 | }↵ | |
26 | Entry result = super.move(targetIndex, sourceIndex);↵ | 26 | Entry result = super.move(targetIndex, sourceIndex);↵ | |
27 | ↵ | 27 | ↵ | |
28 | if (featureSourceIndex != featureTargetIndex)↵ | 28 | if (featureSourceIndex != featureTargetIndex)↵ | |
29 | {↵ | 29 | {↵ | |
30 | dispatchNotification↵ | 30 | dispatchNotification↵ | |
31 | (new ENotificationImpl↵ | 31 | (new ENotificationImpl↵ | |
32 | (owner, ↵ | 32 | (owner, ↵ | |
33 | Notification.MOVE, ↵ | 33 | Notification.MOVE, ↵ | |
34 | feature,↵ | 34 | feature,↵ | |
35 | new Integer(featureSourceIndex), ↵ | 35 | featureSourceIndex, ↵ | |
36 | sourceEntry.getValue(),↵ | 36 | sourceEntry.getValue(),↵ | |
37 | featureTargetIndex));↵ | 37 | featureTargetIndex));↵ | |
38 | }↵ | 38 | }↵ | |
39 | return result; | 39 |
| |
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.7 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 71 |
Number of mapped statements | 16 |
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.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 featureTargetIndex, featureSourceIndex , while Clone fragment #2 returns variables featureTargetIndex, featureSourceIndex |