pharo-project / pharo

Pharo is a dynamic reflective pure object-oriented language supporting live programming inspired by Smalltalk.
http://pharo.org
Other
1.21k stars 356 forks source link

MCVersionLoaderStarted and MCVersionLoaderStopped announcers removed in P12 #15906

Open labordep opened 10 months ago

labordep commented 10 months ago

On Pharo 11, I use the MCVersionLoaderStarted and MCVersionLoaderStopped announcers to trigger code generation in my project (https://github.com/OpenSmock/Molecule). I'm searching for equivalents of these announcers for source-code package modifications (addition, removal), and I've created MCVPackageLoaderStarted and MCPackageLoaderStopped following the same pattern as "MCVersion...".

Now, I'm trying to reverse these changes on Pharo 11. However, when looking for them in Pharo 12 to anticipate any updates from Pharo 11, I only find the MCVersionLoaderStopped announcer ☹️

Is there a new event handling mechanism for source code modifications in Pharo 12? Essentially, I need to receive events when the source code is edited (adding, updating, and removing packages).

This issue refer to this merge request: https://github.com/pharo-project/pharo/pull/15082

I'm using these annoncements by this way:

MolComponentFactory>>initializeSystemAnnouncements

    "Component Implementation Observer"
    announcer when: ClassAdded send: #componentAddedAnnouncement: to: self.
    announcer when: ClassModificationApplied send: #componentChangedAnnouncement: to: self.

    "Monticello events"
    announcer when: #MCVersionLoaderStarted send: #deactivateDynamicContractUpdate: to: self with: false.
    announcer when: #MCVersionLoaderStopped send: #activateDynamicContractUpdate: to: self with: false.

Basicaly, these events enable the activation/deactivation of an automatic source-code generation system. If we keep this function active during project loading (i.e., from Github), package removing, package adding, etc. this system doesn't work properly because classes definition become unstable during the loading process. So the system waiting for an event to be reactive and apply generation at the end of modifications of the source-code.

Thanks for your assistance 🙂

Ducasse commented 10 months ago

Hi cyril when you are back can you have a look at this issue?

labordep commented 10 months ago

Thanks :) I understand that MCFooEvents need to be removed for clean, but I think that having standard events for start/stop loading & start/stop unloading packages should be usefull (as ClassAdded etc.).