Skip to content

Commit

Permalink
Merge pull request #37 from moosetechnology/36-Retrieving-All-tagged-…
Browse files Browse the repository at this point in the history
…entities-in-a-model-is-not-easy

Adding a method to directly get all the tagged entities in a model.
  • Loading branch information
ClotildeToullec authored Aug 26, 2024
2 parents ebac06f + b020ee3 commit 5091447
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Famix-Tagging-Tests/FamixTagMooseModelTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ FamixTagMooseModelTest >> testAllTagAssociations [
self assert: model allTagAssociations size equals: 2
]

{ #category : #tests }
FamixTagMooseModelTest >> testAllTaggedEntities [
self assert: (model allTaggedEntities size) equals: 1.
self assertCollection: (model allTaggedEntities ) hasSameElements: {model entityNamed: 'Package1::Class1'}
]

{ #category : #tests }
FamixTagMooseModelTest >> testAllTags [
| tag1 tag2 tag3 |
Expand Down
17 changes: 17 additions & 0 deletions src/Famix-Tagging/MooseEntity.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ MooseEntity >> allTagAssociations: aCollection [
self allTagAssociations value: aCollection
]

{ #category : #'*Famix-Tagging' }
MooseEntity >> allTaggedEntities [
| taggedEntities |

taggedEntities := OrderedCollection new.
self allTaggedEntitiesIn: taggedEntities .
^ taggedEntities .

]

{ #category : #'*Famix-Tagging' }
MooseEntity >> allTaggedEntitiesIn: anOrderedCollection [
self isTagged ifTrue: [ anOrderedCollection add: self ].
self children do: [ :c | c allTaggedEntitiesIn: anOrderedCollection ].
^anOrderedCollection
]

{ #category : #'*Famix-Tagging' }
MooseEntity >> allTags [
"all tags on me"
Expand Down
7 changes: 7 additions & 0 deletions src/Famix-Tagging/MooseModel.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ MooseModel >> addTaggingEntityFirst: anElement [
^ anElement
]

{ #category : #'*Famix-Tagging' }
MooseModel >> allTaggedEntities [

^ self allTags flatCollectAsSet: [ :tag |
tag taggedEntitiesInModel: self ]
]

{ #category : #'*Famix-Tagging' }
MooseModel >> removeTagProperties [
"I am used when we remove tags to update the caches"
Expand Down

0 comments on commit 5091447

Please sign in to comment.