Skip to content

Commit

Permalink
Merge pull request #7 from moosetechnology/adapt-to-Moose-changes-on-…
Browse files Browse the repository at this point in the history
…privateState

adapt-to-Moose-changes-on-privateState
  • Loading branch information
jecisc authored Jul 17, 2020
2 parents 9c1b0ff + 6e96d89 commit 4f7bc12
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ FamixTagTestClass class >> annotation [

{ #category : #ambiguous }
FamixTagTestClass >> numberOfLinesOfCode: aNumber [
self privateState cacheAt: #numberOfLinesOfCode put: aNumber
self cacheAt: #numberOfLinesOfCode put: aNumber
]
16 changes: 8 additions & 8 deletions src/Famix-Tagging-Tests/FamixTagMooseModelTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -96,44 +96,44 @@ FamixTagMooseModelTest >> testAllTagsWithHiddenTags [
FamixTagMooseModelTest >> testClassicCachesAreNotResetWhenAddingATag [
"When using tags we do not want to invalidate model caches all the time. Only the ones relative to tags."

model privateState cacheAt: #fursona put: #jecisc.
model cacheAt: #fursona put: #jecisc.

model createTagNamed: 'NewTag'.

model privateState cacheAt: #fursona ifAbsent: [ self fail ]
model cacheAt: #fursona ifAbsent: [ self fail ]
]

{ #category : #tests }
FamixTagMooseModelTest >> testClassicCachesAreNotResetWhenEntityWasTagged [
"When using tags we do not want to invalidate model caches all the time. Only the ones relative to tags."

model privateState cacheAt: #fursona put: #jecisc.
model cacheAt: #fursona put: #jecisc.

(model entityNamed: 'Package2') tagWithName: 'dead-code'.

model privateState cacheAt: #fursona ifAbsent: [ self fail ]
model cacheAt: #fursona ifAbsent: [ self fail ]
]

{ #category : #tests }
FamixTagMooseModelTest >> testClassicCachesAreNotResetWhenEntityWasUntagged [
"When using tags we do not want to invalidate model caches all the time. Only the ones relative to tags."

model privateState cacheAt: #fursona put: #jecisc.
model cacheAt: #fursona put: #jecisc.

(model entityNamed: 'Package1::Class1') removeTags.

model privateState cacheAt: #fursona ifAbsent: [ self fail ]
model cacheAt: #fursona ifAbsent: [ self fail ]
]

{ #category : #tests }
FamixTagMooseModelTest >> testClassicCachesAreNotResetWhenRemovingATag [
"When using tags we do not want to invalidate model caches all the time. Only the ones relative to tags."

model privateState cacheAt: #fursona put: #jecisc.
model cacheAt: #fursona put: #jecisc.

model tags first remove.

model privateState cacheAt: #fursona ifAbsent: [ self fail ]
model cacheAt: #fursona ifAbsent: [ self fail ]
]

{ #category : #tests }
Expand Down
2 changes: 1 addition & 1 deletion src/Famix-Tagging/FamixTag.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ FamixTag class >> named: tagName [

{ #category : #ston }
FamixTag class >> stonAllInstVarNames [
^ super stonAllInstVarNames reject: [ :instVar | #(#mooseName #mooseID #state #mooseModel #subTags) includes: instVar ]
^ super stonAllInstVarNames reject: [ :instVar | #(#mooseName #mooseID #cache #entityAttributes #mooseModel #subTags) includes: instVar ]
]

{ #category : #accessing }
Expand Down
2 changes: 1 addition & 1 deletion src/Famix-Tagging/FamixTagCategory.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ FamixTagCategory class >> named: aString [

{ #category : #ston }
FamixTagCategory class >> stonAllInstVarNames [
^ super stonAllInstVarNames \ #(#mooseID #state #mooseModel #markedTags)
^ super stonAllInstVarNames \ #(#mooseName #mooseID #cache #entityAttributes #mooseModel #markedTags)
]

{ #category : #adding }
Expand Down
8 changes: 0 additions & 8 deletions src/Famix-Tagging/MooseEntityState.extension.st

This file was deleted.

11 changes: 9 additions & 2 deletions src/Famix-Tagging/MooseModel.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,26 @@ MooseModel >> addTaggingEntityFirst: anElement [
"Since we can add and remove tags a lot, we prefer to have it at the start of the entity storage. Also, we do not want to flush all caches but only the ones related to tags."

self entityStorage addTaggingEntityFirst: anElement.
self privateState removeTagProperties.
self removeTagProperties.
anElement privateSetMooseModel: self.
self announcer announce: (MooseEntityAdded new entity: anElement).
^ anElement
]

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

cache keysAndValuesRemove: [ :key :value | key asString includesSubstring: 'FamixTag' ]
]

{ #category : #'*Famix-Tagging' }
MooseModel >> removeTaggingEntity: anElement [
"Do not flush all caches because we detag something."

self entityStorage remove: anElement.
anElement privateSetMooseModel: nil.
self privateState removeTagProperties.
self removeTagProperties.
self announcer announce: (MooseEntityRemoved new entity: anElement).
^ anElement
]

0 comments on commit 4f7bc12

Please sign in to comment.