Skip to content

Commit 83a5efc

Browse files
authored
Merge pull request #4 from moosetechnology/fix/dependency-to-comment
Fix/dependency to comment
2 parents 72927a8 + f05f1ef commit 83a5efc

File tree

4 files changed

+38
-21
lines changed

4 files changed

+38
-21
lines changed

src/Famix-Diff-Core/FamixDiffResolver.class.st

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,17 @@ FamixDiffResolver >> hasParentMatched: entity [
187187
188188
We use #parentsDo: instead of #parents because this is faster."
189189

190-
entity parentsDo: [ :parent | ((self shouldMatch: parent) not or: [ self matched: parent ]) ifFalse: [ ^ false ] ].
190+
entity containersDo: [ :parent | ((self shouldMatch: parent) not or: [ self matched: parent ]) ifFalse: [ ^ false ] ].
191191

192192
^ true
193193
]
194194

195195
{ #category : 'testing' }
196196
FamixDiffResolver >> hasParentMatched: entity ignoringParentsIn: aCollection [
197197

198-
entity parentsDo: [ :parent | ((aCollection includes: parent) or: [ (self shouldMatch: parent) not or: [ self matched: parent ] ]) ifFalse: [ ^ false ] ].
198+
entity containersDo: [ :parent |
199+
((aCollection includes: parent) or: [ (self shouldMatch: parent) not or: [ self matched: parent ] ]) ifFalse: [
200+
^ false ] ].
199201

200202
^ true
201203
]

src/Famix-Diff-Core/FamixDiffResult.class.st

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ FamixDiffResult >> groupAdditionsAndRemovalsByRoots [
5151
"When entities are not found in the base or target model we create additions and removals. This API method return a new set of changes that keeps only the top level additions and removals. If we add a package for example it will remove all its added classes methods and variables to keep a high level view of the changes."
5252

5353
^ self select: [ :change |
54-
change entity isAssociation not and: [
55-
(change isAddition and: [ change entity parents noneSatisfy: [ :parent | self additions anySatisfy: [ :change2 | change2 entity = parent ] ] ]) or: [
56-
change isRemoval and: [ change entity parents noneSatisfy: [ :parent | self removals anySatisfy: [ :change2 | change2 entity = parent ] ] ] ] ] ]
54+
change entity isAssociation not and: [
55+
(change isAddition and: [
56+
change entity containers noneSatisfy: [ :parent |
57+
self additions anySatisfy: [ :change2 | change2 entity = parent ] ] ]) or: [
58+
change isRemoval and: [
59+
change entity containers noneSatisfy: [ :parent |
60+
self removals anySatisfy: [ :change2 | change2 entity = parent ] ] ] ] ] ]
5761
]
5862

5963
{ #category : 'accessing' }

src/Famix-Diff-Core/MooseEntity.extension.st

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
Extension { #name : 'MooseEntity' }
22

3+
{ #category : '*Famix-Diff-Core' }
4+
MooseEntity >> isComment [
5+
6+
^ false
7+
]
8+
39
{ #category : '*Famix-Diff-Core' }
410
MooseEntity >> shouldBeConsideredForDiff [
511

src/Famix-Diff-Core/TEntityMetaLevelDependency.extension.st

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,21 @@ TEntityMetaLevelDependency >> can: baseSize beSameAs: targetSize withThreashold:
1818

1919
{ #category : '*Famix-Diff-Core' }
2020
TEntityMetaLevelDependency >> compareParentsWith: otherEntity resolver: resolver [
21-
2221
"I check that the parents of both entities are the same."
2322

2423
<famixDiff: #identity priority: 5>
2524
<famixDiff: #rename priority: 5>
2625
| baseParents targetParents |
27-
baseParents := self parents.
28-
targetParents := otherEntity parents.
26+
baseParents := self containers.
27+
targetParents := otherEntity containers.
2928

3029
baseParents size = targetParents size ifFalse: [ ^ false ].
3130

32-
baseParents do: [ :baseParent |
33-
targetParents
34-
detect: [ :targetParent | "We delegate the comparison to the resolver because it's possible a parent is the same but got renamed. This should deal with this case."
35-
resolver is: baseParent sameAs: targetParent ]
36-
ifNone: [ ^ false "A parent of the base entity does not have a matching parent so we escape." ] ].
31+
baseParents do: [ :baseParent |
32+
targetParents
33+
detect: [ :targetParent | "We delegate the comparison to the resolver because it's possible a parent is the same but got renamed. This should deal with this case."
34+
resolver is: baseParent sameAs: targetParent ]
35+
ifNone: [ ^ false "A parent of the base entity does not have a matching parent so we escape." ] ].
3736

3837
^ true
3938
]
@@ -91,8 +90,8 @@ TEntityMetaLevelDependency >> hasEqualContentAndDependencies: otherEntity resolv
9190
<famixDiff: #rename priority: 10>
9291
<famixDiff: #move priority: 10>
9392
| baseChildren targetChildren intersect baseOutgoingDependencies targetOutgoingDependencies baseIncomingDependencies targetIncomingDependencies |
94-
baseChildren := self children.
95-
targetChildren := otherEntity children.
93+
baseChildren := self containedEntities.
94+
targetChildren := otherEntity containedEntities.
9695

9796
baseOutgoingDependencies := self queryAllLocalOutgoing.
9897
targetOutgoingDependencies := otherEntity queryAllLocalOutgoing.
@@ -101,8 +100,10 @@ TEntityMetaLevelDependency >> hasEqualContentAndDependencies: otherEntity resolv
101100
targetIncomingDependencies := otherEntity queryAllLocalIncoming.
102101

103102
"If we have nothing in the class we consider they are different."
104-
(baseChildren isEmpty and: [ baseOutgoingDependencies isEmpty and: [ baseIncomingDependencies isEmpty ] ]) ifTrue: [ ^ false ].
105-
(targetChildren isEmpty and: [ targetOutgoingDependencies isEmpty and: [ targetIncomingDependencies isEmpty ] ]) ifTrue: [ ^ false ].
103+
(baseChildren isEmpty and: [ baseOutgoingDependencies isEmpty and: [ baseIncomingDependencies isEmpty ] ]) ifTrue: [
104+
^ false ].
105+
(targetChildren isEmpty and: [ targetOutgoingDependencies isEmpty and: [ targetIncomingDependencies isEmpty ] ])
106+
ifTrue: [ ^ false ].
106107

107108
"This is for perf. If the number of entity is too different, no need to compare them."
108109
(self
@@ -113,22 +114,26 @@ TEntityMetaLevelDependency >> hasEqualContentAndDependencies: otherEntity resolv
113114
intersect := OrderedCollection new.
114115

115116
"Since we did not treat the children with the resolver yet we do not check via the resolver if they are the same entities because even if they are renamed we will not know it yet."
116-
intersect addAll: (baseChildren select: [ :baseChild | targetChildren anySatisfy: [ :targetChild | baseChild name = targetChild name ] ]).
117+
intersect addAll:
118+
(baseChildren select: [ :baseChild | targetChildren anySatisfy: [ :targetChild | baseChild name = targetChild name ] ]).
117119

118120
intersect addAll: (baseOutgoingDependencies select: [ :baseDependency |
119121
targetOutgoingDependencies anySatisfy: [ :targetDependency |
120122
targetDependency class = baseDependency class and: [
121123
(baseDependency target isNotNil and: [ targetDependency target isNotNil ]) and: [ "<=== THIS SHOULD NOT BE HERE. Target should never be nil but verveineJ has a bug. Remove this once the bug is fixed."
122-
baseDependency allTargets allSatisfy: [ :baseTarget | targetDependency allTargets anySatisfy: [ :targetTarget | baseTarget name = targetTarget name ] ] ] ] ] ]).
124+
baseDependency allTargets allSatisfy: [ :baseTarget |
125+
targetDependency allTargets anySatisfy: [ :targetTarget | baseTarget name = targetTarget name ] ] ] ] ] ]).
123126

124127
intersect addAll: (baseIncomingDependencies select: [ :baseDependency |
125128
targetIncomingDependencies anySatisfy: [ :targetDependency |
126129
targetDependency class = baseDependency class and: [
127130
(baseDependency source isNotNil and: [ targetDependency source isNotNil ]) and: [ "<=== THIS SHOULD NOT BE HERE. Target should never be nil but verveineJ has a bug. Remove this once the bug is fixed."
128131
baseDependency source name = targetDependency source name ] ] ] ]).
129132

130-
intersect size / (baseChildren size + baseOutgoingDependencies size + baseIncomingDependencies size) >= (1 - resolver tolerance) ifFalse: [ ^ false ].
131-
intersect size / (targetChildren size + targetOutgoingDependencies size + targetIncomingDependencies size) >= (1 - resolver tolerance) ifFalse: [ ^ false ].
133+
intersect size / (baseChildren size + baseOutgoingDependencies size + baseIncomingDependencies size)
134+
>= (1 - resolver tolerance) ifFalse: [ ^ false ].
135+
intersect size / (targetChildren size + targetOutgoingDependencies size + targetIncomingDependencies size)
136+
>= (1 - resolver tolerance) ifFalse: [ ^ false ].
132137
^ true
133138
]
134139

0 commit comments

Comments
 (0)