diff --git a/src/Famix-Tagging-Tests/FamixTagMooseModelTest.class.st b/src/Famix-Tagging-Tests/FamixTagMooseModelTest.class.st index 4bf2375..dca8237 100644 --- a/src/Famix-Tagging-Tests/FamixTagMooseModelTest.class.st +++ b/src/Famix-Tagging-Tests/FamixTagMooseModelTest.class.st @@ -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 | diff --git a/src/Famix-Tagging/MooseEntity.extension.st b/src/Famix-Tagging/MooseEntity.extension.st index 70892b2..31f14b5 100644 --- a/src/Famix-Tagging/MooseEntity.extension.st +++ b/src/Famix-Tagging/MooseEntity.extension.st @@ -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" diff --git a/src/Famix-Tagging/MooseModel.extension.st b/src/Famix-Tagging/MooseModel.extension.st index 97bc491..d36810f 100644 --- a/src/Famix-Tagging/MooseModel.extension.st +++ b/src/Famix-Tagging/MooseModel.extension.st @@ -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"