Skip to content

Commit

Permalink
Add #withRootAdditionsAndRemovals
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Jun 16, 2024
1 parent 0cb04bb commit f7cc9fe
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Famix-Diff-Core-Tests/FamixDiffResultTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ FamixDiffResultTest >> testRenames [
self assert: moves class equals: result class
]

{ #category : #tests }
FamixDiffResultTest >> testWithRootAdditionsAndRemovals [

| subResult |
subResult := result withRootAdditionsAndRemovals.
self assert: subResult additions size equals: 1.
self assert: subResult additions anyOne entity mooseName equals: #'Famix-Diff-TestResource-P1'.
self assert: subResult removals size equals: 3 "1 package and a pragma with its type"
]

{ #category : #tests }
FamixDiffResultTest >> testWithoutStubs [

Expand Down
10 changes: 10 additions & 0 deletions src/Famix-Diff-Core/FamixDiffResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ FamixDiffResult >> species [
^ self class
]

{ #category : #accessing }
FamixDiffResult >> withRootAdditionsAndRemovals [
"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."

^ self select: [ :change |
change entity isAssociation not and: [
(change isAddition and: [ change entity parents noneSatisfy: [ :parent | self additions anySatisfy: [ :change2 | change2 entity = parent ] ] ]) or: [
change isRemoval and: [ change entity parents noneSatisfy: [ :parent | self removals anySatisfy: [ :change2 | change2 entity = parent ] ] ] ] ] ]
]

{ #category : #accessing }
FamixDiffResult >> withoutStubs [
"Returns all the results without the stubs"
Expand Down

0 comments on commit f7cc9fe

Please sign in to comment.