diff --git a/source/.configmaps b/source/.configmaps index e59017d..e011e6b 100644 --- a/source/.configmaps +++ b/source/.configmaps @@ -22,8 +22,8 @@ }, { #name : 'TonelLoaderModel', - #versionName : 'strategies-5', - #ts : 3802083798 + #versionName : 'strategies-6', + #ts : 3802087286 }, { #name : 'TonelReaderModel', diff --git a/source/TonelLoaderModel/TonelLoader.class.st b/source/TonelLoaderModel/TonelLoader.class.st index 3154318..873aa51 100644 --- a/source/TonelLoaderModel/TonelLoader.class.st +++ b/source/TonelLoaderModel/TonelLoader.class.st @@ -9,7 +9,8 @@ Class { 'configurationMaps', 'loadedApplications', 'loadedConfigurationMaps', - 'createsHookMethods' + 'createsHookMethods', + 'prerequisitesFilter' ], #classVars : [ 'DefaultAppNameSuffix', @@ -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 [ @@ -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 [ @@ -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' } diff --git a/source/TonelLoaderModel/TonelLoaderApplication.class.st b/source/TonelLoaderModel/TonelLoaderApplication.class.st index a656724..1125501 100644 --- a/source/TonelLoaderModel/TonelLoaderApplication.class.st +++ b/source/TonelLoaderModel/TonelLoaderApplication.class.st @@ -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 ]