The Trunk: System-mt.1065.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: System-mt.1065.mcz

commits-2
Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1065.mcz

==================== Summary ====================

Name: System-mt.1065
Author: mt
Time: 14 May 2019, 11:14:58.077441 am
UUID: 3ad59119-652a-fa46-8dc5-8b3747993363
Ancestors: System-dtl.1064

Clean up AbstractEvent:
- Make it more clear that "environment" is a dictionary local to system-change events.
- Remove #environment message to avoid mixup with Object >> #environment.
- Reduce the nunmber of inst-var references.
- Fix several message categories.
- Add missing #environmentKind to SystemChangeNotifier. For consistency. I have no clue why those re-directs exist. Maybe because "AbstractEvent classKind" is hard to read but "SystemChangeNotifier classKind" is not.

=============== Diff against System-dtl.1064 ===============

Item was changed:
  ----- Method: AbstractEvent class>>categoryKind (in category 'item kinds') -----
  categoryKind
+ "Also known as 'class categories'."
+
-
  ^#category!

Item was changed:
+ ----- Method: AbstractEvent class>>class: (in category 'instance creation - specific') -----
- ----- Method: AbstractEvent class>>class: (in category 'instance creation') -----
  class: aClass
  ^ self item: aClass kind: AbstractEvent classKind.!

Item was changed:
+ ----- Method: AbstractEvent class>>class:category: (in category 'instance creation - specific') -----
- ----- Method: AbstractEvent class>>class:category: (in category 'instance creation') -----
  class: aClass category: cat
  | instance |
  instance := self class: aClass.
  instance itemCategory: cat.
  ^instance!

Item was changed:
+ ----- Method: AbstractEvent class>>classCategory: (in category 'instance creation - specific') -----
- ----- Method: AbstractEvent class>>classCategory: (in category 'instance creation') -----
  classCategory: aName
  ^ self item: aName kind: AbstractEvent categoryKind.!

Item was removed:
- ----- Method: AbstractEvent class>>comment1 (in category 'temporary') -----
- comment1
-
- "Smalltalk organization removeElement: #ClassForTestingSystemChanges3
- Smalltalk garbageCollect
- Smalltalk organizati
-
- classify:under:
-
-
- SystemChangeNotifier uniqueInstance releaseAll
- SystemChangeNotifier uniqueInstance noMoreNotificationsFor: aDependent.
-
-
- aDependent := SystemChangeNotifierTest new.
- SystemChangeNotifier uniqueInstance
- notifyOfAllSystemChanges: aDependent
- using: #event:
-
- SystemChangeNotifier uniqueInstance classAdded: #Foo inCategory: #FooCat
-
-
-
- | eventSource dependentObject |
- eventSource := EventManager new.
- dependentObject := Object new.
-
- register - dependentObject becomes dependent:
- eventSource
- when: #anEvent send: #error to: dependentObject.
-
- unregister dependentObject:
- eventSource removeDependent: dependentObject.
-
- [eventSource triggerEvent: #anEvent]
- on: Error
- do: [:exc | self halt: 'Should not be!!']."!

Item was removed:
- ----- Method: AbstractEvent class>>comment2 (in category 'temporary') -----
- comment2
-
- "HTTPSocket useProxyServerNamed: 'proxy.telenet.be' port: 8080
- TestRunner open
-
- --------------------
- We propose two orthogonal groups to categorize each event:
- (1) the 'change type':
- added, removed, modified, renamed
- + the composite 'changed' (see below for an explanation)
- (2) the 'item type':
- class, method, instance variable, pool variable, protocol, category
- + the composite 'any' (see below for an explanation).
- The list of supported events is the cross product of these two lists (see below for an explicit enumeration of the events).
-
- Depending on the change type, certain information related to the change is always present (for adding, the new things that was added, for removals, what was removed, for renaming, the old and the new name, etc.).
-
- Depending on the item type, information regarding the item is present (for a method, which class it belongs to).
-
- Certain events 'overlap', for example, a method rename triggers a class change. To capture this I impose a hierarchy on the 'item types' (just put some numbers to clearly show the idea. They don't need numbers, really. Items at a certain categories are included by items one category number higher):
- level 1 category
- level 2 class
- level 3 instance variable, pool variable, protocol, method.
-
- Changes propagate according to this tree: any 'added', 'removed' or 'renamed' change type in level X triggers a 'changed' change type in level X - 1. A 'modified' change type does not trigger anything special.
- For example, a method additions triggers a class modification. This does not trigger a category modification.
-
- Note that we added 'composite events': wildcards for the 'change type' ('any' - any system additions) and for the 'item type' ('Changed' - all changes related to classes), and one for 'any change systemwide' (systemChanged).
-
- This result is this list of Events:
-
- classAdded
- classRemoved
- classModified
- classRenamed (?)
- classChanged (composite)
-
- methodAdded
- methodRemoved
- methodModified
- methodRenamed (?)
- methodChanged (composite)
-
- instanceVariableAdded
- instanceVariableRemoved
- instanceVariableModified
- instanceVariableRenamed (?)
- instanceVariableChanged (composite)
-
- protocolAdded
- protocolRemoved
- protocolModified
- protocolRenamed (?)
- protocolChanged (composite)
-
- poolVariableAdded
- poolVariableRemoved
- poolVariableModified
- poolVariableRenamed (?)
- poolChanged (composite)
-
- categoryAdded
- categoryRemoved
- categoryModified
- categeryRenamed (?)
- categoryChanged (composite)
-
- anyAdded (composite)
- anyRemoved (composite)
- anyModified (composite)
- anyRenamed (composite)
-
- anyChanged (composite)
-
-
-
- To check: can we pass somehow the 'source' of the change (a browser, a file-in, something else) ? Maybe by checking the context, but should not be too expensive either... I found this useful in some of my tools, but it might be too advanced to have in general. Tools that need this can always write code to check it for them.  But is not always simple...
-
-
- Utilities (for the recent methods) and ChangeSet are the two main clients at this moment.
-
- Important: make it very explicit that the event is send synchronously (or asynchronously, would we take that route).
-
-
- category
- class
- comment
- protocol
- method
- OR
- category
- Smalltalk
- class
- comment
- protocol
- method
- ??
-
-
-
- Smalltalk category
- \ /
- class
- /  | \
- comment  | protocol
-  | /
- method
-
- "!

Item was removed:
- ----- Method: AbstractEvent class>>comment3 (in category 'temporary') -----
- comment3
-
- "Things to consider for trapping:
- ClassOrganizer>>#changeFromCategorySpecs:
- Problem: I want to trap this to send the appropriate bunch of ReCategorization events, but ClassOrganizer instances do not know where they belong to (what class, or what system); it just uses symbols. So I cannot trigger the change, because not enough information is available. This is a conceptual problem: the organization is stand-alone implementation-wise, while conceptually it belongs to a class. The clean solution could be to reroute this message to a class, but this does not work for all of the senders (that would work from the browserm but not for the file-in).
-
- Browser>>#categorizeAllUncategorizedMethods
- Problem: should be trapped to send a ReCategorization event. However, this is model code that should not be in the Browser. Clean solution is to move it out of there to the model, and then trap it there (or reroute it to one of the trapped places).
-
- Note: Debugger>>#contents:notifying: recompiles methods when needed, so I trapped it to get updates. However, I need to find a way to write a unit test for this. Haven't gotten around yet for doing this though...
- "!

Item was changed:
+ ----- Method: AbstractEvent class>>method:class: (in category 'instance creation - specific') -----
- ----- Method: AbstractEvent class>>method:class: (in category 'instance creation') -----
  method: aMethod class: aClass
 
  | instance |
  instance := self item: aMethod kind: self methodKind.
  instance itemClass: aClass.
  ^instance!

Item was changed:
+ ----- Method: AbstractEvent class>>method:protocol:class: (in category 'instance creation - specific') -----
- ----- Method: AbstractEvent class>>method:protocol:class: (in category 'instance creation') -----
  method: aMethod protocol: prot class: aClass
 
  | instance |
  instance := self method: aMethod class: aClass.
  instance itemProtocol: prot.
  ^instance!

Item was changed:
+ ----- Method: AbstractEvent class>>method:selector:class: (in category 'instance creation - specific') -----
- ----- Method: AbstractEvent class>>method:selector:class: (in category 'instance creation') -----
  method: aMethod selector: aSymbol class: aClass
 
  | instance |
  instance := self item: aMethod kind: self methodKind.
  instance itemSelector: aSymbol.
  instance itemClass: aClass.
  ^instance!

Item was changed:
+ ----- Method: AbstractEvent class>>method:selector:class:requestor: (in category 'instance creation - specific') -----
- ----- Method: AbstractEvent class>>method:selector:class:requestor: (in category 'instance creation') -----
  method: aMethod selector: aSymbol class: aClass requestor: requestor
 
  | instance |
  instance := self method: aMethod selector: aSymbol class: aClass.
  instance itemRequestor: requestor.
  ^instance!

Item was changed:
+ ----- Method: AbstractEvent class>>method:selector:protocol:class: (in category 'instance creation - specific') -----
- ----- Method: AbstractEvent class>>method:selector:protocol:class: (in category 'instance creation') -----
  method: aMethod selector: aSymbol protocol: prot class: aClass
 
  | instance |
  instance := self method: aMethod selector: aSymbol class: aClass.
  instance itemProtocol: prot.
  ^instance!

Item was changed:
+ ----- Method: AbstractEvent class>>method:selector:protocol:class:requestor: (in category 'instance creation - specific') -----
- ----- Method: AbstractEvent class>>method:selector:protocol:class:requestor: (in category 'instance creation') -----
  method: aMethod selector: aSymbol protocol: prot class: aClass requestor: requestor
 
  | instance |
  instance := self method: aMethod selector: aSymbol protocol: prot class: aClass.
  instance itemRequestor: requestor.
  ^instance!

Item was changed:
+ ----- Method: AbstractEvent class>>protocol:class: (in category 'instance creation - specific') -----
- ----- Method: AbstractEvent class>>protocol:class: (in category 'instance creation') -----
  protocol: aProtocol class: aClass
 
  | instance |
  instance := self item: aProtocol kind: self protocolKind.
  instance itemClass: aClass.
  ^instance!

Item was changed:
  ----- Method: AbstractEvent class>>protocolKind (in category 'item kinds') -----
  protocolKind
+ "Also known as 'message categories'."
+
-
  ^#protocol!

Item was removed:
- ----- Method: AbstractEvent class>>saveChangeNotificationAsSARFileWithNumber: (in category 'temporary') -----
- saveChangeNotificationAsSARFileWithNumber: aNumber
- "Use the SARBuilder package to output the SystemChangeNotification
- stuff as a SAR file. Put this statement here so that I don't forget it
- when moving between images :-)"
- "self saveChangeNotificationAsSARFileWithNumber: 6"
-
- | filename changesText readmeText dumper |
- filename := 'SystemchangeNotification'.
- dumper := self class environment at: #SARChangeSetDumper ifAbsent: [ ^self ].
- changesText :=
- '
- 0.6 Version for Squeak 3.7 (no longer for 3.6!!!!) Changed one hook method to make this version work in Squeak3.7. Download version 5 from http://www.iam.unibe.ch/~wuyts/SystemchangeNotification5.sar if you are working with Squeak 3.6.
-
- 0.5 Updated the safeguard mechanism so that clients with halts and errors do not stop all notifications. Added and updated new tests for this. If this interests you have a look at the class WeakActionSequenceTrappingErrors.
-
- 0.4 Ported to Squeak 3.6.
-
- 0.3 Added the hooks for instance variables (addition, removal and renaming). Refactored the tests.
-
- 0.2 Added hooks and tests for method removal and method recategorization.
-
- 0.1 First release'.
- readmeText :=
- 'Implements (part of) the system change notification mechanism. Clients that want to receive notifications about system changes should look at the category #public of the class SystemChangeNotifier, and the unit tests.
-
- VERY IMPORTANT: This version is for Squeak 3.7 only. It will not work in Squeak version 3.6. Download and install the last version that worked in Squeak 3.6 (version 5) from the following URL: http://www.iam.unibe.ch/~wuyts/SystemchangeNotification5.sar'.
-
- (dumper
- on: Project current changeSet
- including: (ChangeSet allChangeSetNames
- select: [:ea | 'SystemChangeHooks' match: ea])) changesText: changesText;
- readmeText: readmeText;
- fileOutAsZipNamed: filename , aNumber printString , '.sar'!

Item was removed:
- ----- Method: AbstractEvent>>environment (in category 'accessing') -----
- environment
- ^ environment.!

Item was changed:
  ----- Method: AbstractEvent>>environmentAt: (in category 'private-accessing') -----
  environmentAt: anItemKind
 
+ ^ self environmentAt: anItemKind ifAbsent: [nil]!
- (self itemKind = anItemKind) ifTrue: [^self item].
- ^environment at: anItemKind ifAbsent: [nil]!

Item was added:
+ ----- Method: AbstractEvent>>environmentAt:ifAbsent: (in category 'private-accessing') -----
+ environmentAt: anItemKind ifAbsent: aBlock
+
+ ^ self itemKind = anItemKind
+ ifTrue: [self item]
+ ifFalse: [environment at: anItemKind ifAbsent: aBlock]!

Item was added:
+ ----- Method: AbstractEvent>>environmentAt:put: (in category 'private-accessing') -----
+ environmentAt: anItemKind put: anItem
+
+ self itemKind = anItemKind
+ ifTrue: [item := anItem]
+ ifFalse: [environment at: anItemKind put: anItem].!

Item was changed:
  ----- Method: AbstractEvent>>eventSelector (in category 'private-accessing') -----
  eventSelector
 
+ ^self class eventSelectorBlock
+ value: self itemKind
+ value: self changeKind!
- ^self class eventSelectorBlock value: itemKind value: self changeKind!

Item was changed:
+ ----- Method: AbstractEvent>>item:kind: (in category 'initialization') -----
- ----- Method: AbstractEvent>>item:kind: (in category 'private-accessing') -----
  item: anItem kind: anItemKind
 
  item := anItem.
  itemKind := anItemKind.
  environment := Dictionary new!

Item was changed:
+ ----- Method: AbstractEvent>>itemCategory (in category 'accessing - specific') -----
- ----- Method: AbstractEvent>>itemCategory (in category 'accessing') -----
  itemCategory
 
+ ^ self environmentAt: self class categoryKind!
- ^self environmentAt: self class categoryKind!

Item was changed:
  ----- Method: AbstractEvent>>itemCategory: (in category 'private-accessing') -----
  itemCategory: aCategory
 
+ self environmentAt: self class categoryKind put: aCategory.!
- environment at: self class categoryKind put: aCategory!

Item was changed:
+ ----- Method: AbstractEvent>>itemClass (in category 'accessing - specific') -----
- ----- Method: AbstractEvent>>itemClass (in category 'accessing') -----
  itemClass
 
+ ^ self environmentAt: self class classKind!
- ^self environmentAt: self class classKind!

Item was changed:
  ----- Method: AbstractEvent>>itemClass: (in category 'private-accessing') -----
  itemClass: aClass
 
+ self environmentAt: self class classKind put: aClass.!
- environment at: self class classKind put: aClass!

Item was changed:
+ ----- Method: AbstractEvent>>itemEnvironment (in category 'accessing - specific') -----
- ----- Method: AbstractEvent>>itemEnvironment (in category 'accessing') -----
  itemEnvironment
+
+ ^ self
+ environmentAt: self class environmentKind
+ ifAbsent: [Smalltalk globals]!
- ^ environment at: self class environmentKind ifAbsent: [Smalltalk globals].!

Item was changed:
+ ----- Method: AbstractEvent>>itemEnvironment: (in category 'private-accessing') -----
- ----- Method: AbstractEvent>>itemEnvironment: (in category 'accessing') -----
  itemEnvironment: anEnvironment
+
+ self environmentAt: self class environmentKind put: anEnvironment.!
- ^self environmentAt: self class environmentKind put: anEnvironment.!

Item was changed:
+ ----- Method: AbstractEvent>>itemExpression (in category 'accessing - specific') -----
- ----- Method: AbstractEvent>>itemExpression (in category 'accessing') -----
  itemExpression
 
+ ^ self environmentAt: self class expressionKind!
- ^self environmentAt: self class expressionKind!

Item was changed:
  ----- Method: AbstractEvent>>itemExpression: (in category 'private-accessing') -----
  itemExpression: anExpression
 
+ self environmentAt: self class expressionKind put: anExpression.!
- environment at: self class expressionKind put: anExpression!

Item was changed:
+ ----- Method: AbstractEvent>>itemMethod (in category 'accessing - specific') -----
- ----- Method: AbstractEvent>>itemMethod (in category 'accessing') -----
  itemMethod
 
+ ^ self environmentAt: self class methodKind!
- ^self environmentAt: self class methodKind!

Item was changed:
  ----- Method: AbstractEvent>>itemMethod: (in category 'private-accessing') -----
  itemMethod: aMethod
 
+ self environmentAt: self class methodKind put: aMethod.!
- environment at: self class methodKind put: aMethod!

Item was changed:
+ ----- Method: AbstractEvent>>itemProtocol (in category 'accessing - specific') -----
- ----- Method: AbstractEvent>>itemProtocol (in category 'accessing') -----
  itemProtocol
 
+ ^ self environmentAt: self class protocolKind!
- ^self environmentAt: self class protocolKind!

Item was changed:
  ----- Method: AbstractEvent>>itemProtocol: (in category 'private-accessing') -----
  itemProtocol: aProtocol
 
+ self environmentAt: self class protocolKind put: aProtocol.!
- environment at: self class protocolKind put: aProtocol!

Item was changed:
+ ----- Method: AbstractEvent>>itemRequestor (in category 'accessing - specific') -----
- ----- Method: AbstractEvent>>itemRequestor (in category 'accessing') -----
  itemRequestor
 
+ ^ self environmentAt: #requestor!
- ^self environmentAt: #requestor!

Item was changed:
  ----- Method: AbstractEvent>>itemRequestor: (in category 'private-accessing') -----
+ itemRequestor: anObject
- itemRequestor: requestor
 
+ self environmentAt: #requestor put: anObject.!
- environment at: #requestor put: requestor!

Item was changed:
+ ----- Method: AbstractEvent>>itemSelector (in category 'accessing - specific') -----
- ----- Method: AbstractEvent>>itemSelector (in category 'accessing') -----
  itemSelector
 
+ ^ self environmentAt: #selector!
- ^self environmentAt: #selector!

Item was changed:
  ----- Method: AbstractEvent>>itemSelector: (in category 'private-accessing') -----
  itemSelector: aSymbol
 
+ self environmentAt: #selector put: aSymbol.!
- environment at: #selector put: aSymbol!

Item was changed:
  ----- Method: ModifiedClassDefinitionEvent>>classVarNames (in category 'accessing') -----
  classVarNames
+
+ ^ self item classVarNames!
- ^ item classVarNames!

Item was changed:
  ----- Method: ModifiedClassDefinitionEvent>>instVarNames (in category 'accessing') -----
  instVarNames
+
+ ^ self item instVarNames asSet!
- ^ item instVarNames asSet!

Item was changed:
  ----- Method: ModifiedClassDefinitionEvent>>isSuperclassModified (in category 'testing') -----
  isSuperclassModified
+
+ ^ self item superclass ~~ self oldItem superclass!
- ^ item superclass ~~ oldItem superclass!

Item was changed:
  ----- Method: ModifiedClassDefinitionEvent>>sharedPools (in category 'accessing') -----
  sharedPools
+
+ ^ self item sharedPools!
- ^ item sharedPools!

Item was changed:
  ----- Method: ModifiedClassDefinitionEvent>>superclass (in category 'accessing') -----
  superclass
+
+ ^ self item superclass!
- ^ item superclass!

Item was changed:
  ----- Method: ModifiedClassDefinitionEvent>>traitComposition (in category 'trait composition') -----
  traitComposition
+
+ ^ self item traitComposition!
- ^ item traitComposition!

Item was changed:
  ----- Method: ModifiedTraitDefinitionEvent>>traitComposition (in category 'accessing') -----
  traitComposition
+
+ ^ self item traitComposition!
- ^ item traitComposition!

Item was added:
+ ----- Method: SystemChangeNotifier class>>environmentKind (in category 'item kinds') -----
+ environmentKind
+
+ ^ AbstractEvent environmentKind!

Item was changed:
  ----- Method: SystemChangeNotifier class>>expressionKind (in category 'item kinds') -----
  expressionKind
+
  ^ AbstractEvent expressionKind!

Item was changed:
  ----- Method: SystemChangeNotifier class>>protocolKind (in category 'item kinds') -----
  protocolKind
+
  ^ AbstractEvent protocolKind!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-mt.1065.mcz

Levente Uzonyi
On Tue, 14 May 2019, [hidden email] wrote:

> Marcel Taeumel uploaded a new version of System to project The Trunk:
> http://source.squeak.org/trunk/System-mt.1065.mcz
>
> - Reduce the nunmber of inst-var references.

Why?

Levente

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-mt.1065.mcz

marcel.taeumel
Well, it started with cleaning up the mix of direct access to "environment" and sends of #environmentAt:. I discovered an error in #itemEnvironment:, which assumed a non-existent #environmentAt:put:. Then, ModifiedClassDefinitionEvent was the only event class with much access to the "item" inst-var, which I replaced with #item. However, I wasn't sure whether #itemClass would not fit better in tthis case. Yet, the whole "item*" concept in AbstractEvent is kind of tricky for #itemClass. One might wrongly assume the class *of* the item in the event, which would be the meta-class for class-changed events. Sigh. See AbstractEvent >> #environmentAt:.

I did not add accessors #environment and #environment: because of Squeak's class environments and Object >> #environment.

Best,
Marcel

Am 14.05.2019 12:18:37 schrieb Levente Uzonyi <[hidden email]>:

On Tue, 14 May 2019, [hidden email] wrote:

> Marcel Taeumel uploaded a new version of System to project The Trunk:
> http://source.squeak.org/trunk/System-mt.1065.mcz
>
> - Reduce the nunmber of inst-var references.

Why?

Levente