In defineComponent: there are several cycling modifications, sometimes need to "fork" them because of the system doesn't finish to install all modifications than we started another one, etc. etc.
I think this is problem and this is not very efficient!
Some examples:
MolComponentFactory>>rebuildComponent: aComponentClass traitsRemoving: aTraitsList
aTraitsList do: [ :trait |
( trait notNil and:[ trait isTrait and:[ trait isObsolete not ] ] ) ifTrue:[
"Check if the trait is present on class hierarchy"
( aComponentClass isComposedBy: trait ) ifTrue:[
[ aComponentClass removeFromComposition: trait ] on: KeyNotFound do:[ :e |
"When an originaly method injected by a Trait is remove, there is a KeyNotFound exception - catch it because finally we need to remove"
"Need to do another try in a fork with a delay to considere system installation"
self flag:'laborde: write a Pharo issue? Usecase: remove an overridden method of a Traits then remove the trait from composition'.
MolUtils log: e printString.
[ 10 milliSeconds wait. (aComponentClass isComposedBy: trait) ifTrue:[ aComponentClass removeFromComposition: trait ] ] fork.
].
].
].
].
MolComponentFactory>>rebuildComponent: aComponentClass traitsAdding: aTraitsList
| classes |
"Get class hierarchy of the component class and clean classes not concerned by Component Contract Traits"
classes := aComponentClass allSuperclasses reverse.
classes remove: Object; remove: ProtoObject; remove: MolAbstractComponentImpl ifAbsent:[nil].
classes add: aComponentClass.
aTraitsList do: [:trait | | toBeAddedTrait |
(trait notNil and:[trait isTrait and:[trait isObsolete not]]) ifTrue:[
toBeAddedTrait := trait.
"Cannot add the traits if already present in superclasses"
classes do: [ :c | toBeAddedTrait ifNotNil:[ (c allTraits includes: trait) ifTrue:[toBeAddedTrait := nil] ]].
toBeAddedTrait ifNotNil:[
aComponentClass traitComposition isEmpty
ifTrue:[aComponentClass setTraitComposition: toBeAddedTrait]
ifFalse:[ aComponentClass addToComposition: toBeAddedTrait].
].
].
].
Several of theses methods recompile things on Components classes, this is reload a new defineComponent: etc.
Probably to stack all component contract edition (adding, removing traits) in a list and process only the last one will be better to regenerate all required methods in a dedicated thread (and decrease used energy and times). May be this fix Icerberg and package removing too!
@ELePors what is your opinion?
In defineComponent: there are several cycling modifications, sometimes need to "fork" them because of the system doesn't finish to install all modifications than we started another one, etc. etc.
I think this is problem and this is not very efficient!
Some examples:
Several of theses methods recompile things on Components classes, this is reload a new defineComponent: etc.
Probably to stack all component contract edition (adding, removing traits) in a list and process only the last one will be better to regenerate all required methods in a dedicated thread (and decrease used energy and times). May be this fix Icerberg and package removing too!
@ELePors what is your opinion?