Skip to content

Commit

Permalink
Adds prerequistesFilter to fix #81
Browse files Browse the repository at this point in the history
  • Loading branch information
eMaringolo committed Jun 25, 2021
1 parent a2b554a commit 203e4b8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 16 deletions.
4 changes: 2 additions & 2 deletions source/.configmaps
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
},
{
#name : 'TonelLoaderModel',
#versionName : 'strategies-5',
#ts : 3802083798
#versionName : 'strategies-6',
#ts : 3802087286
},
{
#name : 'TonelReaderModel',
Expand Down
40 changes: 34 additions & 6 deletions source/TonelLoaderModel/TonelLoader.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Class {
'configurationMaps',
'loadedApplications',
'loadedConfigurationMaps',
'createsHookMethods'
'createsHookMethods',
'prerequisitesFilter'
],
#classVars : [
'DefaultAppNameSuffix',
Expand Down Expand Up @@ -207,6 +208,16 @@ TonelLoader >> doNotCreateVersions [
self versionStrategy: (TonelLoaderNoVersionStrategy for: self)
]

{ #category : 'accessing' }
TonelLoader >> filteredPrerequisitesApplications [
"Answer a collection of TonelApplications given that they fullfill the prerequisites filter
or all applications if no filter was defined."

^self prerequisitesFilter
ifNil: [self applications]
ifNotNil: [:filter | self applications select: [:each | filter value: each]]
]

{ #category : 'strategies-convenience' }
TonelLoader >> forceCreationOfEditions [

Expand Down Expand Up @@ -410,6 +421,19 @@ TonelLoader >> postLoadActions [
ifNotNil: [:class | class perform: #primRefreshMethodSelectors]
]

{ #category : 'accessing' }
TonelLoader >> prerequisitesFilter [

^prerequisitesFilter
]

{ #category : 'accessing' }
TonelLoader >> prerequisitesFilter: monadicBlock [
"Sets valuable to be the receiver prerequisitesFilter."

prerequisitesFilter := monadicBlock
]

{ #category : 'resolving' }
TonelLoader >> prerequisitesFor: aTonelLoaderApplication current: anOrderedCollection [

Expand Down Expand Up @@ -456,11 +480,15 @@ TonelLoader >> reset [
{ #category : 'accessing' }
TonelLoader >> rootApplicationOfClass: aTonelReaderClassDefinition [

self applications do: [:tonelApp |
(tonelApp allDefinedClasses
anySatisfy: [:tonelClass | tonelClass = aTonelReaderClassDefinition])
ifTrue: [^tonelApp rootTonelApplication]].
^nil
| candidateApps |
candidateApps :=
(self filteredPrerequisitesApplications select: [:tonelApp |
(tonelApp allDefinedClasses anySatisfy: [:tonelClass |
tonelClass = aTonelReaderClassDefinition
or: [tonelClass name = aTonelReaderClassDefinition name]])])
flattened
collect: [:tonelApp | tonelApp rootTonelApplication].
^candidateApps isEmpty ifTrue: [nil] ifFalse: [candidateApps first]
]

{ #category : 'accessing' }
Expand Down
15 changes: 7 additions & 8 deletions source/TonelLoaderModel/TonelLoaderApplication.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,22 @@ TonelLoaderApplication >> asSymbol [
#vaVisibility : 'private' }
TonelLoaderApplication >> computeImplicitPrerequisites [

| needed |
| needed |

needed := Set new.
self withAllSubApplications do: [:app |
app tonelDefinedClasses do: [:cl |
((cl tonelSuperclassIn: self loader)) ifNotNil: [:itsSuper |
needed add: (itsSuper rootTonelApplicationIn: self loader)]].
((cl tonelSuperclassIn: self loader))
ifNotNil: [:itsSuper | needed add: (itsSuper rootTonelApplicationIn: self loader)]].
app tonelExtendedClasses do: [:cl |
(cl rootTonelApplicationIn: self loader) ifNotNil: [:itsSuper | needed add: itsSuper ]].
(app tonelDefinedClasses, app tonelExtendedClasses) asArray do: [:cl |
(cl rootTonelApplicationIn: self loader) ifNotNil: [:itsSuper | needed add: itsSuper]].
(app tonelDefinedClasses , app tonelExtendedClasses) asArray do: [:cl |
(cl tonelMethods) do: [:cm |
(cm referencedTonelClasses: self loader) do: [:referencedClass |
needed add: (referencedClass rootTonelApplicationIn: self loader)]]]].

needed remove: self ifAbsent: [].
needed copy do: [:app |
app allPrerequisites do: [:prereq |
needed remove: prereq ifAbsent: []]].
needed copy do: [:app | app allPrerequisites do: [:prereq | needed remove: prereq ifAbsent: []]].
^needed
]

Expand Down

0 comments on commit 203e4b8

Please sign in to comment.