diff --git a/src/Famix-Tagging-Code/MooseAbstractGroup.extension.st b/src/Famix-Tagging-Code/MooseAbstractGroup.extension.st index 0a19a40..15f1514 100644 --- a/src/Famix-Tagging-Code/MooseAbstractGroup.extension.st +++ b/src/Famix-Tagging-Code/MooseAbstractGroup.extension.st @@ -1,8 +1,15 @@ Extension { #name : #MooseAbstractGroup } { #category : #'*Famix-Tagging-Code' } -MooseAbstractGroup >> codeTagAssociations [ +MooseAbstractGroup >> allCodeTagAssociations [ "All entity tags placed on this entity" ^ self allWithType: FamixTagCodeAssociation ] + +{ #category : #'*Famix-Tagging-Code' } +MooseAbstractGroup >> codeTagAssociations [ + "All entity tags placed on this entity" + + ^ self allCodeTagAssociations reject: #isHidden +] diff --git a/src/Famix-Tagging-Tests/FamixTagMooseModelTest.class.st b/src/Famix-Tagging-Tests/FamixTagMooseModelTest.class.st index 0bed890..0e9b3d4 100644 --- a/src/Famix-Tagging-Tests/FamixTagMooseModelTest.class.st +++ b/src/Famix-Tagging-Tests/FamixTagMooseModelTest.class.st @@ -25,13 +25,71 @@ FamixTagMooseModelTest >> testAddANewTagWithCategory [ ] { #category : #tests } -FamixTagMooseModelTest >> testAllModelTaggedAssociations [ +FamixTagMooseModelTest >> testAllModelTags [ + self assert: model tags size equals: 2 +] + +{ #category : #tests } +FamixTagMooseModelTest >> testAllRootTags [ + | tag1 tag2 tag3 | + model := FamixTagModel new. + tag1 := model createTagNamed: 'Furry'. + tag2 := model createTagNamed: 'Bronie'. + tag3 := model createTagNamed: 'Scalie'. + + tag2 parentTag: tag1. + + self assertCollection: model allRootTags hasSameElements: {tag1 . tag3} +] + +{ #category : #tests } +FamixTagMooseModelTest >> testAllRootTagsWithHiddenTags [ + | tag1 tag2 tag3 | + model := FamixTagModel new. + tag1 := model createTagNamed: 'Furry'. + tag2 := model createTagNamed: 'Bronie'. + tag3 := model createTagNamed: 'Scalie'. + + tag2 parentTag: tag1. + tag3 hide. + + self assertCollection: model allRootTags hasSameElements: {tag1 . tag3} +] + +{ #category : #tests } +FamixTagMooseModelTest >> testAllTagAssociations [ + self assert: model allTagAssociations size equals: 2. + + model tags first hide. + self assert: model allTagAssociations size equals: 2 ] { #category : #tests } -FamixTagMooseModelTest >> testAllModelTags [ - self assert: model tags size equals: 2 +FamixTagMooseModelTest >> testAllTags [ + | tag1 tag2 tag3 | + model := FamixTagModel new. + tag1 := model createTagNamed: 'Furry'. + tag2 := model createTagNamed: 'Bronie'. + tag3 := model createTagNamed: 'Scalie'. + + tag2 parentTag: tag1. + + self assertCollection: model allTags hasSameElements: {tag1 . tag2. tag3} +] + +{ #category : #tests } +FamixTagMooseModelTest >> testAllTagsWithHiddenTags [ + | tag1 tag2 tag3 | + model := FamixTagModel new. + tag1 := model createTagNamed: 'Furry'. + tag2 := model createTagNamed: 'Bronie'. + tag3 := model createTagNamed: 'Scalie'. + + tag2 parentTag: tag1. + tag3 hide. + + self assertCollection: model allTags hasSameElements: {tag1 . tag2 . tag3} ] { #category : #tests } @@ -158,6 +216,29 @@ FamixTagMooseModelTest >> testRetrievalFromModelWithCategories [ self assertEmpty: (model tagCategoryNamed: 'default') markedTags ] +{ #category : #tests } +FamixTagMooseModelTest >> testRootTags [ + | tag1 tag2 tag3 | + model := FamixTagModel new. + tag1 := model createTagNamed: 'Furry'. + tag2 := model createTagNamed: 'Bronie'. + tag3 := model createTagNamed: 'Scalie'. + + tag2 parentTag: tag1. + tag3 hide. + + self assertCollection: model rootTags hasSameElements: {tag1} +] + +{ #category : #tests } +FamixTagMooseModelTest >> testTagAssociations [ + self assert: model tagAssociations size equals: 2. + + model tags first hide. + + self assert: model tagAssociations size equals: 1 +] + { #category : #tests } FamixTagMooseModelTest >> testTagCachesAreResetWhenAddingATag [ self assert: model tags size equals: 2. @@ -256,6 +337,20 @@ FamixTagMooseModelTest >> testTagsExportAndImportMSE [ self assert: (importedModel entityNamed: 'Package1::Class1') entityTagAssociations size equals: 1 ] +{ #category : #tests } +FamixTagMooseModelTest >> testTagsWithHidden [ + | tag1 tag2 tag3 | + model := FamixTagModel new. + tag1 := model createTagNamed: 'Furry'. + tag2 := model createTagNamed: 'Bronie'. + tag3 := model createTagNamed: 'Scalie'. + + tag2 parentTag: tag1. + tag3 hide. + + self assertCollection: model tags hasSameElements: {tag1 . tag2} +] + { #category : #tests } FamixTagMooseModelTest >> testToggleTag [ | entity tag numberOfTag | diff --git a/src/Famix-Tagging-Tests/FamixTagTest.class.st b/src/Famix-Tagging-Tests/FamixTagTest.class.st index 2c533e9..9e3f9b5 100644 --- a/src/Famix-Tagging-Tests/FamixTagTest.class.st +++ b/src/Famix-Tagging-Tests/FamixTagTest.class.st @@ -124,6 +124,11 @@ FamixTagTest >> testIsRoot [ self deny: compositeTag isRoot ] +{ #category : #tests } +FamixTagTest >> testIsVisibleByDefault [ + self deny: FamixTag new isHidden +] + { #category : #tests } FamixTagTest >> testMooseName [ self assert: compositeTag mooseName equals: #parent. diff --git a/src/Famix-Tagging/FamixTag.class.st b/src/Famix-Tagging/FamixTag.class.st index d990a55..fbc2ede 100644 --- a/src/Famix-Tagging/FamixTag.class.st +++ b/src/Famix-Tagging/FamixTag.class.st @@ -42,7 +42,8 @@ Class { 'serializedColor', 'parentTag', 'categories', - 'subTags' + 'subTags', + 'isHidden' ], #category : #'Famix-Tagging-Model' } @@ -299,6 +300,11 @@ FamixTag >> hasUniqueMooseNameInModel [ ^ true ] +{ #category : #accessing } +FamixTag >> hide [ + isHidden := true +] + { #category : #accessing } FamixTag >> id [ @@ -314,11 +320,12 @@ FamixTag >> id: anObject [ { #category : #initialization } FamixTag >> initialize [ super initialize. - subTags := FMNullMultivalueLink on: self opposite: #parentTag: selector: #subTags. + subTags := FMMultivalueLink on: self opposite: #parentTag:. categories := FMMultiMultivalueLink on: self opposite: #markedTags. - self id: UUIDGenerator default nextRandom16. - self color: MDLColor randomColorAndTint + id := UUIDGenerator default nextRandom16. + self color: MDLColor randomColorAndTint. + isHidden := false ] { #category : #accessing } @@ -335,6 +342,18 @@ FamixTag >> isComposite [ ^ self subTags isNotEmpty ] +{ #category : #accessing } +FamixTag >> isHidden [ + + + ^ isHidden +] + +{ #category : #accessing } +FamixTag >> isHidden: anObject [ + isHidden := anObject +] + { #category : #dependencies } FamixTag >> isInListOfPossibleLinks: aCollection forModel: aMooseModel [ ^ aCollection includesAny: (self allTaggedEntitiesInModel: aMooseModel) @@ -432,6 +451,7 @@ FamixTag >> parentSeparator [ FamixTag >> parentTag [ + ^ parentTag ] @@ -554,8 +574,10 @@ FamixTag >> subTagNamed: aString [ { #category : #accessing } FamixTag >> subTags [ - + + + ^ subTags ] @@ -585,3 +607,8 @@ FamixTag >> taggedEntities [ FamixTag >> taggedEntitiesInModel: aModel [ ^ aModel entitiesTaggedWith: self ] + +{ #category : #actions } +FamixTag >> toggleVisibility [ + isHidden := isHidden not +] diff --git a/src/Famix-Tagging/FamixTagAssociation.class.st b/src/Famix-Tagging/FamixTagAssociation.class.st index 6f12c9c..60f4e7a 100644 --- a/src/Famix-Tagging/FamixTagAssociation.class.st +++ b/src/Famix-Tagging/FamixTagAssociation.class.st @@ -59,7 +59,7 @@ FamixTagAssociation >> checkingDoubleTagging [ { #category : #accessing } FamixTagAssociation >> entity [ - + ^ entity ] @@ -121,6 +121,11 @@ FamixTagAssociation >> isEntityTagAssociation [ ^ false ] +{ #category : #testing } +FamixTagAssociation >> isHidden [ + ^ self tag isHidden +] + { #category : #accessing } FamixTagAssociation >> mooseModel: aMooseModel [ "We add the association at the beginning of the model entity storage because the user can delete associations but not entities. It is much faster to delete entities at the beginning of the collection. On a big model it can take several second to delete some tags." @@ -155,7 +160,7 @@ FamixTagAssociation >> setEntityTo: anEntity [ anEntity ifNotNil: [ anEntity mooseModel ifNotNil: [ :model | self mooseModel: model ] ]. entity := FMMultivalueLink on: self - update: #tagAssociations + update: #allTagAssociations from: self entity to: anEntity ] diff --git a/src/Famix-Tagging/FamixTagSTONWriter.class.st b/src/Famix-Tagging/FamixTagSTONWriter.class.st index f2fb906..ec491b9 100644 --- a/src/Famix-Tagging/FamixTagSTONWriter.class.st +++ b/src/Famix-Tagging/FamixTagSTONWriter.class.st @@ -31,7 +31,7 @@ Class { FamixTagSTONWriter class >> export: aMooseModel with: aTagModel on: aStream [ (self on: aStream) tagModel: aTagModel; - writeObject: (FamixTagSTONExport tags: aTagModel tags categories: aTagModel allTagCategories associations: aMooseModel allTagAssociations) + writeObject: (FamixTagSTONExport tags: aTagModel allTags categories: aTagModel allTagCategories associations: aMooseModel allTagAssociations) ] { #category : #accessing } diff --git a/src/Famix-Tagging/MooseAbstractGroup.extension.st b/src/Famix-Tagging/MooseAbstractGroup.extension.st index 629e27c..7d82cc5 100644 --- a/src/Famix-Tagging/MooseAbstractGroup.extension.st +++ b/src/Famix-Tagging/MooseAbstractGroup.extension.st @@ -1,8 +1,15 @@ Extension { #name : #MooseAbstractGroup } +{ #category : #'*Famix-Tagging' } +MooseAbstractGroup >> allEntityTagAssociations [ + "All entity tags placed on this entity" + + ^ self allWithType: FamixTagEntityAssociation +] + { #category : #'*Famix-Tagging' } MooseAbstractGroup >> allRootTags [ - ^ self tags select: #isRoot + ^ self allTags select: #isRoot ] { #category : #'*Famix-Tagging' } @@ -17,6 +24,12 @@ MooseAbstractGroup >> allTagCategories [ ^ self allWithSubTypesOf: FamixTagCategory ] +{ #category : #'*Famix-Tagging' } +MooseAbstractGroup >> allTags [ + + ^ self allWithType: FamixTag +] + { #category : #'*Famix-Tagging' } MooseAbstractGroup >> associationsForTag: aTag [ | mn | @@ -51,7 +64,7 @@ MooseAbstractGroup >> entitiesTaggedWith: aTag [ MooseAbstractGroup >> entityTagAssociations [ "All entity tags placed on this entity" - ^ self allWithType: FamixTagEntityAssociation + ^ self allEntityTagAssociations reject: #isHidden ] { #category : #'*Famix-Tagging' } @@ -61,7 +74,7 @@ MooseAbstractGroup >> exportTagsOn: aStream tagModel: aTagModel [ { #category : #'*Famix-Tagging' } MooseAbstractGroup >> findEquivalentTagTo: aFamixTag [ - ^ self tags detect: [ :aTag | aTag equivalentTo: aFamixTag ] + ^ self allTags detect: [ :aTag | aTag equivalentTo: aFamixTag ] ] { #category : #'*Famix-Tagging' } @@ -78,7 +91,7 @@ MooseAbstractGroup >> findTagNamed: aTagMooseName [ { #category : #'*Famix-Tagging' } MooseAbstractGroup >> findTagWithId: aTagId [ - ^ self tags detect: [ :aTag | aTag id = aTagId ] + ^ self allTags detect: [ :aTag | aTag id = aTagId ] ] { #category : #'*Famix-Tagging' } @@ -90,6 +103,17 @@ MooseAbstractGroup >> importTagsFrom: aStream tagModel: aTagModel [ report ] +{ #category : #'*Famix-Tagging' } +MooseAbstractGroup >> rootTags [ + ^ self allRootTags reject: #isHidden +] + +{ #category : #'*Famix-Tagging' } +MooseAbstractGroup >> tagAssociations [ + + ^ self allTagAssociations reject: #isHidden +] + { #category : #'*Famix-Tagging' } MooseAbstractGroup >> tagCategoryNamed: aCategoryMooseName [ ^ [ self findTagCategoryNamed: aCategoryMooseName ] @@ -106,8 +130,6 @@ MooseAbstractGroup >> tagNamed: aTagMooseName [ { #category : #'*Famix-Tagging' } MooseAbstractGroup >> tags [ - "to allow tag queries on groups of entities" - - - ^ self allWithType: FamixTag + + ^ self allTags reject: #isHidden ] diff --git a/src/Famix-Tagging/MooseEntity.extension.st b/src/Famix-Tagging/MooseEntity.extension.st index b3bc8d7..9455b4f 100644 --- a/src/Famix-Tagging/MooseEntity.extension.st +++ b/src/Famix-Tagging/MooseEntity.extension.st @@ -1,12 +1,45 @@ Extension { #name : #MooseEntity } { #category : #'*Famix-Tagging' } -MooseEntity >> entityTagAssociations [ +MooseEntity >> allEntityTagAssociations [ "All entity tag associations placed on this entity" ^ self tagAssociations select: #isEntityTagAssociation ] +{ #category : #'*Famix-Tagging' } +MooseEntity >> allTagAssociations [ + + + + ^ self propertyNamed: #allTagAssociations ifAbsentPut: [ FMMultivalueLink on: self opposite: #entity: ] +] + +{ #category : #'*Famix-Tagging' } +MooseEntity >> allTagAssociations: aCollection [ + self allTagAssociations value: aCollection +] + +{ #category : #'*Famix-Tagging' } +MooseEntity >> allTags [ + "all tags on me" + + " + + self removeTags + + " + + ^ (self allTagAssociations collectAsSet: #tag) asArray +] + +{ #category : #'*Famix-Tagging' } +MooseEntity >> entityTagAssociations [ + "All entity tag associations placed on this entity" + + ^ self allEntityTagAssociations reject: #isHidden +] + { #category : #'*Famix-Tagging' } MooseEntity >> isTagged [ @@ -34,25 +67,17 @@ MooseEntity >> numberOfTags [ MooseEntity >> removeTag: aTag [ "remove a tag from this moose entity" - self tagAssociations detect: [ :assoc | assoc tag = aTag ] ifFound: #remove + self allTagAssociations detect: [ :assoc | assoc tag = aTag ] ifFound: #remove ] { #category : #'*Famix-Tagging' } MooseEntity >> removeTags [ - self tagAssociations asOrderedCollection do: #remove + self allTagAssociations asOrderedCollection do: #remove ] { #category : #'*Famix-Tagging' } MooseEntity >> tagAssociations [ - - - - ^ self propertyNamed: #tagAssociations ifAbsentPut: [ FMMultivalueLink on: self opposite: #entity: ] -] - -{ #category : #'*Famix-Tagging' } -MooseEntity >> tagAssociations: aCollection [ - self tagAssociations value: aCollection + ^ self allTagAssociations reject: #isHidden ] { #category : #'*Famix-Tagging' } @@ -74,13 +99,7 @@ MooseEntity >> tagWithName: aTagName tagModel: aTagModel [ { #category : #'*Famix-Tagging' } MooseEntity >> tags [ - "all tags on me" - " - - self removeTags - - " - ^ (self tagAssociations collectAsSet: #tag) asArray + ^ self allTags reject: #isHidden ] { #category : #'*Famix-Tagging' } @@ -92,7 +111,7 @@ MooseEntity >> tagsInModel: aTagModel [ MooseEntity >> toggleTag: aTag [ "If the entity as already tagged with this tag, remove it. Else, tag the entity." - self tags + self allTags detect: [ :tag | tag = aTag ] ifFound: [ :tag | self removeTag: tag ] ifNone: [ aTag tagEntity: self ]