[Pkg] SystemEditor: SystemEditor-mtf.126.mcz

squeak-dev-noreply at lists.squeakfoundation.org squeak-dev-noreply at lists.squeakfoundation.org
Wed Oct 8 00:00:46 UTC 2008


A new version of SystemEditor was added to project SystemEditor:
http://www.squeaksource.com/SystemEditor/SystemEditor-mtf.126.mcz

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

Name: SystemEditor-mtf.126
Author: mtf
Time: 7 October 2008, 10:31:05 am
UUID: db503ac4-772b-4fb9-af1f-57b2a3d40658
Ancestors: SystemEditor-mtf.125

Refactor of CategorizerEditor:
- reorganized the methods in Categorizer
- now remember the order of categories
- moved the responsibility of building down from OrganizationEditor to CategorizerEditor

=============== Diff against SystemEditor-mtf.125 ===============

Item was changed:
+ ----- Method: CategorizerEditor>>listAtCategoryNamed: (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>listAtCategoryNamed: (in category 'accessing') -----
  listAtCategoryNamed: catName
  
+ 	| category list |
- 	| oldList newList category |
  	category := catName asSymbol.
  	(self categories includes: category) ifFalse: [^ nil].
+ 	list := self subject ifNotNil: [self subject listAtCategoryNamed: category].
+ 	list ifNil: [list := OrderedCollection new].
+ 	list := list asOrderedCollection.
+ 	self removedElements do: [:ea | list removeAll: ea].
+ 	self changedElementsAndCategoriesDo: [:ea :cat |
+ 		list removeAll: ea. cat = category ifTrue: [list add: ea]].
+ 	^ list
- 	newList := (self changesInCategory: category) ifNil: [#()].
- 	oldList := (self subjectListAtCategoryNamed: category) ifNil: [#()].
- 	^ oldList, newList
  !

Item was changed:
+ ----- Method: CategorizerEditor>>removeElement: (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>removeElement: (in category 'accessing') -----
  removeElement: element
+ 	self subclassResponsibility!
- 	(self removedElements includes: element) ifTrue: [^ self].
- 	self changesRemoveElement: element.
- 	self subject ifNotNil: [(self subject elementArray includes: element)
- 		ifTrue: [self removedElements add: element]]!

Item was changed:
+ ----- Method: CategorizerEditor>>changedCategories (in category 'accessing changed elements') -----
- ----- Method: CategorizerEditor>>changedCategories (in category 'private') -----
  changedCategories
+ "Answer the set of categories whose elements have changed"
- 	"Answer the categories of all the elements that have changed"
  
  	^ (self changedElementsAndCategoriesCollect:
  		[:anElement :aCategory | aCategory]) asSet
  !

Item was changed:
+ ----- Method: CategorizerEditor>>renameCategory:toBe: (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>renameCategory:toBe: (in category 'accessing') -----
  renameCategory: oldCatString toBe: newCatString
  	| oldCategory newCategory originalCategory |
  	newCategory := newCatString asSymbol.
  	oldCategory := oldCatString asSymbol.
  	originalCategory := self oldCategoryFor: oldCategory.
  	(self categories includes: newCategory) ifTrue: [^ self].
  	(self categories includes: oldCategory) ifFalse: [^ self].
+ 	categories replaceAll: oldCategory with: newCategory.
+ 	renamedCategories at: originalCategory put: newCategory.!
- 	self changesRenameCategory: oldCategory toBe: newCategory.
- 	(addedCategories includes: oldCategory)
- 		ifTrue: [addedCategories replaceAll: oldCategory with: newCategory]
- 		ifFalse: [renamedCategories at: originalCategory put: newCategory]!

Item was changed:
+ ----- Method: CategorizerEditor>>classify:under: (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>classify:under: (in category 'accessing') -----
  classify: element under: heading 
  	self classify: element under: heading suppressIfDefault: true!

Item was changed:
+ ----- Method: CategorizerEditor>>oldCategoryFor: (in category 'as yet unclassified') -----
- ----- Method: CategorizerEditor>>oldCategoryFor: (in category 'private') -----
  oldCategoryFor: newCategory
  	^ renamedCategories keyAtValue: newCategory ifAbsent: [newCategory]!

Item was changed:
+ ----- Method: CategorizerEditor>>addCategory:before: (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>addCategory:before: (in category 'accessing') -----
  addCategory: catString before: nextCategory
  	"I don't support ordering"
  	| newCategory |
  	newCategory := catString asSymbol.
  	(self categories includes: newCategory) ifTrue: [^ self].
+ 	categories add: newCategory before: nextCategory!
- 	self changesAddCategory: newCategory before: nextCategory.
- 	(removedCategories includes: newCategory)
- 		ifTrue: [removedCategories remove: newCategory]
- 		ifFalse: [addedCategories add: newCategory]!

Item was added:
+ ----- Method: AbstractEditor>>productClass (in category 'accessing') -----
+ productClass
+ "Answers the class of the object that is the result of applying my edits to my subject"
+ 
+ 	^ self subject class!

Item was added:
+ ----- Method: CategorizerEditor>>edPrepareMigration: (in category 'building') -----
+ edPrepareMigration: txn
+ 	self edRequiresBuild
+ 		ifTrue: [txn addMigrator: (ObjectMigrator 
+ 									origin: self subject 
+ 									destination: self edBuild)]!

Item was added:
+ ----- Method: OrganizationEditor>>edBuild (in category 'building') -----
+ edBuild
+ 	| result |
+ 	result := super edBuild.
+ 	result
+ 		edClassComment: self commentRemoteStr
+ 		stamp: self commentStamp.
+ 	^ result!

Item was added:
+ ----- Method: CategorizerEditor>>edBuild (in category 'building') -----
+ edBuild
+ 	| result processed newCat |
+ 	result := self productClass new.
+ 	result categories: categories.
+ 	self changedElementsAndCategoriesDo: [:ea :cat |
+ 		result classify: ea under: cat].
+ 	processed := (result elementArray, self removedElements) asSet.
+ 	self subject categories do: [:oldCat |
+ 		newCat := self newCategoryFor: oldCat.
+ 		(subject listAtCategoryNamed: oldCat) do: [:ea |
+ 			(processed includes: ea) ifFalse: [
+ 				result classify: ea under: newCat]]].
+ 	^ result!

Item was added:
+ ----- Method: CategorizerEditor>>hasChangedElements (in category 'accessing changed elements') -----
+ hasChangedElements
+ 	self changedElementsAndCategoriesDo: [:element :category | ^ true].
+ 	^ false!

Item was changed:
  ----- Method: OrganizationEditor>>edRequiresBuild (in category 'building') -----
  edRequiresBuild
+ 	^ isDirty or: [super edRequiresBuild]!
- 	^ isDirty or: [classEditor isMethodsChanged]!

Item was added:
+ ----- Method: CategorizerEditor>>edRequiresBuild (in category 'building') -----
+ edRequiresBuild
+ 	^ self hasChangedElements or: [self removedElements notEmpty]!

Item was changed:
+ ----- Method: CategorizerEditor>>changesInCategory: (in category 'accessing changed elements') -----
- ----- Method: CategorizerEditor>>changesInCategory: (in category 'private') -----
  changesInCategory: category
+ "Answers a list of new or recategorized elements in category"
+ 
  	^ self changedElementsAndCategoriesSelect:
  			[:anElement :aCategory | category = aCategory]
  		thenCollect: [:anElement :aCategory | anElement]!

Item was changed:
+ ----- Method: CategorizerEditor>>changedElementsAndCategoriesDo: (in category 'accessing changed elements') -----
- ----- Method: CategorizerEditor>>changedElementsAndCategoriesDo: (in category 'subclass responsibility') -----
  changedElementsAndCategoriesDo: aBlock
+ "Evaluates aBlock for each added or recategorized elements, and its category"
+ 
- 	"Enumerate all changed elements and its associated category via the two-argument block"
  	self subclassResponsibility!

Item was changed:
  AbstractEditor subclass: #CategorizerEditor
+ 	instanceVariableNames: 'subject renamedCategories categories'
- 	instanceVariableNames: 'subject addedCategories renamedCategories removedCategories'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'SystemEditor-Editors'!
  
  !CategorizerEditor commentStamp: '<historical>' prior: 0!
+ An abstract superclass for editors of Categorizers. Implements the public interface of a Categorizer. I maintain the list of added, removed, or reordered categories, but it is up to subclasses to remember which elements were added, removed, or recategorized.
+ 
+ subject (Categorizer) - The Categorizer I am editing
+ categories (OrderedCollection) - The ordered list of categories
+ renamedCategories (Dictionary) - A dictionary mapping old category names to new names!
- An abstract superclass for editors of Categorizers. Takes care of most of the hassle of implementing the public interface of a Categorizer!

Item was changed:
+ ----- Method: CategorizerEditor>>classifyAll:under: (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>classifyAll:under: (in category 'accessing') -----
  classifyAll: aCollection under: heading
  
  	aCollection do:
  		[:element | self classify: element under: heading]!

Item was changed:
+ ----- Method: CategorizerEditor>>removeCategory: (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>removeCategory: (in category 'accessing') -----
  removeCategory: catString
  	| category |
  	category := catString asSymbol.
  	(self categories includes: category) ifFalse: [^ self].
  	(self listAtCategoryNamed: category)
  		ifNotEmpty: [^self error: 'cannot remove non-empty category'].
+ 	categories remove: category ifAbsent: [].
- 	self changesRemoveCategory: category.
- 	addedCategories remove: category ifAbsent: [].
  	renamedCategories keysAndValuesRemove: [:key :value | value == category].
+ !
- 	(self subjectCategories includes: category)
- 		ifTrue: [removedCategories add: category]!

Item was changed:
+ ----- Method: CategorizerEditor>>setSubject: (in category 'initialize-release') -----
- ----- Method: CategorizerEditor>>setSubject: (in category 'private') -----
  setSubject: aCategorizer
  	subject := aCategorizer.
+ 	renamedCategories := Dictionary new.
+ 	categories := OrderedCollection new.!
- 	removedCategories := Set new.
- 	addedCategories := OrderedCollection new.
- 	renamedCategories := Dictionary new!

Item was changed:
+ ----- Method: CategorizerEditor>>classify:under:suppressIfDefault: (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>classify:under:suppressIfDefault: (in category 'accessing') -----
  classify: element under: heading suppressIfDefault: aBoolean
  	| category |
  	((heading = Categorizer nullCategory) or: [heading == nil])
  		ifTrue: [category := Categorizer default]
  		ifFalse: [category := heading asSymbol].
  	self addCategory: category.
- 	self classifyChange: element under: category suppressIfDefault: aBoolean.
  	((self categories includes: Categorizer default)
  		and: [(self listAtCategoryNamed: Categorizer default) size = 0])
  			ifTrue: [self removeCategory: Categorizer default].
  !

Item was changed:
+ ----- Method: CategorizerEditor>>elementArray (in category 'reflecting - private') -----
- ----- Method: CategorizerEditor>>elementArray (in category 'private') -----
  elementArray
  	^ self categories gather: [:category | self listAtCategoryNamed: category]!

Item was changed:
+ ----- Method: CategorizerEditor>>listAtCategoryNumber: (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>listAtCategoryNumber: (in category 'accessing') -----
  listAtCategoryNumber: anInteger
  	^ self listAtCategoryNamed: (self categories at: anInteger)!

Item was changed:
+ ----- Method: CategorizerEditor>>changedElementsAndCategoriesCollect: (in category 'accessing changed elements') -----
- ----- Method: CategorizerEditor>>changedElementsAndCategoriesCollect: (in category 'private') -----
  changedElementsAndCategoriesCollect: aBlock
+ "Evaluates aBlock for each added or recategorized elements, and its category. Answers an OrderedCollection of the results"
+ 
  	| newCollection |
  	newCollection := OrderedCollection new.
  	self changedElementsAndCategoriesDo: [:anElement :aCategory |
  		newCollection add: (aBlock value: anElement value: aCategory)].
  	^ newCollection!

Item was changed:
+ ----- Method: CategorizerEditor>>subject (in category 'accessing') -----
- ----- Method: CategorizerEditor>>subject (in category 'private') -----
  subject
  	^ subject!

Item was changed:
+ ----- Method: CategorizerEditor>>categories: (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>categories: (in category 'accessing') -----
  categories: anArray
+ 
+ 	categories := anArray!
- 	"I don't support ordering"
- 	^ self!

Item was changed:
+ ----- Method: CategorizerEditor>>removedElements (in category 'accessing changed elements') -----
- ----- Method: CategorizerEditor>>removedElements (in category 'subclass responsibility') -----
  removedElements
+ "Answers a list of elements that have been removed"
+ 
  	^ Array new!

Item was changed:
+ ----- Method: CategorizerEditor>>addCategory: (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>addCategory: (in category 'accessing') -----
  addCategory: newCategory
  	^ self addCategory: newCategory before: nil!

Item was changed:
+ ----- Method: CategorizerEditor>>categories (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>categories (in category 'accessing') -----
  categories
  
+ 	^ categories!
- 	^ self subjectCategories, addedCategories!

Item was changed:
+ ----- Method: CategorizerEditor>>newCategoryFor: (in category 'as yet unclassified') -----
- ----- Method: CategorizerEditor>>newCategoryFor: (in category 'private') -----
  newCategoryFor: oldCategory
  	^ renamedCategories at: oldCategory ifAbsent: [oldCategory]!

Item was added:
+ ----- Method: AbstractEditor>>subject (in category 'accessing') -----
+ subject
+ "Answers the object I am editing"
+ 
+ 	self subclassResponsibility!

Item was changed:
+ ----- Method: CategorizerEditor>>categoryOfChange: (in category 'accessing changed elements') -----
- ----- Method: CategorizerEditor>>categoryOfChange: (in category 'private') -----
  categoryOfChange: element
+ "Answers the category of a new or recategorized element"
+ 
  	self changedElementsAndCategoriesDo: [:anElement :aCategory |
  		element = anElement ifTrue: [^ aCategory]].
  	^ nil!

Item was changed:
+ ----- Method: CategorizerEditor>>printOn: (in category 'reflecting - printing') -----
- ----- Method: CategorizerEditor>>printOn: (in category 'printing') -----
  printOn: aStream
  	self categories do: [:category |
  		aStream nextPutAll: '('''; nextPutAll: category; nextPut: $'.
  		(self listAtCategoryNamed: category) do: [:element |
  			aStream space; nextPutAll: element].
  		aStream nextPut: $); cr]!

Item was changed:
+ ----- Method: CategorizerEditor>>categoryOfElement: (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>categoryOfElement: (in category 'accessing') -----
  categoryOfElement: element
  	(self removedElements includes: element) ifTrue: [^ nil].
  	(self categoryOfChange: element) ifNotNilDo: [:cat | ^ cat].
  	self subject ifNil: [^ nil].
  	^ self newCategoryFor: (self subject categoryOfElement: element)
  !

Item was changed:
+ ----- Method: CategorizerEditor>>changedElementsAndCategoriesSelect:thenCollect: (in category 'accessing changed elements') -----
- ----- Method: CategorizerEditor>>changedElementsAndCategoriesSelect:thenCollect: (in category 'private') -----
  changedElementsAndCategoriesSelect: selectBlock thenCollect: collectBlock
+ "Evaluates collectBlock for each added or recategorized element and its category for which selectBlock answers true. Answers an OrderedCollection of the results"
+ 
  	| newCollection |
  	newCollection := OrderedCollection new.
  	self changedElementsAndCategoriesDo: [:anElement :aCategory |
  		(selectBlock value: anElement value: aCategory) ifTrue: [newCollection
  			add: (collectBlock value: anElement value: aCategory)]].
  	^ newCollection!

Item was changed:
  ----- Method: MethodDictionaryEditor>>buildFor: (in category 'editing') -----
  buildFor: aClassEditor
  	| result old |
+ self halt.
  	result := MethodDictionary new.
  	self subject keysAndValuesDo:
  		[:selector :cm |
  		(self selectorIsModified: selector)
  			ifFalse: [result at: selector put: (self recompile: selector from: cm for: aClassEditor)]].
  	additions keysAndValuesDo: 
  		[:selector :mm | 
  		old := self subject at: selector ifAbsent: [nil]. 
  		result at: selector put: (mm compileFrom: old for: aClassEditor)].
  	^ result
  !

Item was changed:
+ ----- Method: CategorizerEditor>>allMethodSelectors (in category 'reflecting - accessing') -----
- ----- Method: CategorizerEditor>>allMethodSelectors (in category 'accessing') -----
  allMethodSelectors
  	"give a list of all method selectors."
  
  	^ self elementArray copy sort!

Item was changed:
+ ----- Method: CategorizerEditor>>changedElements (in category 'accessing changed elements') -----
- ----- Method: CategorizerEditor>>changedElements (in category 'private') -----
  changedElements
+ "Answers the list of elements that have been added or recategorized"
+ 
  	^ self changedElementsAndCategoriesCollect: [:anElement :aCategory | anElement]!

Item was removed:
- ----- Method: CategorizerEditor>>subjectListAtCategoryNamed: (in category 'private') -----
- subjectListAtCategoryNamed: catName
- 	| category subjectCategory elements |
- 	self subject ifNil: [^ Array new].
- 	category := catName asSymbol.
- 	(self subjectCategories includes: category) ifFalse: [^ nil].
- 	subjectCategory := self oldCategoryFor: category.
- 	elements := (subject listAtCategoryNamed: subjectCategory) ifNil: [^ nil].
- 	^ elements difference: self removedElements, self changedElements!

Item was removed:
- ----- Method: CategorizerEditor>>changesRemoveCategory: (in category 'subclass responsibility') -----
- changesRemoveCategory: category!

Item was removed:
- ----- Method: OrganizationEditor>>edPrepareMigration: (in category 'building') -----
- edPrepareMigration: txn
- 	self edRequiresBuild
- 		ifTrue: [txn addMigrator: (ObjectMigrator 
- 									origin: self subject 
- 									destination: self build)]!

Item was removed:
- ----- Method: CategorizerEditor>>classifyChange:under:suppressIfDefault: (in category 'subclass responsibility') -----
- classifyChange: element under: category suppressIfDefault: aBoolean!

Item was removed:
- ----- Method: OrganizationEditor>>build (in category 'building') -----
- build
- 	| result |
- 	self subject.
- 	subject ifNil: [
- 			result := ClassOrganizer defaultList: #()]
- 		ifNotNil: [
- 			result := ClassOrganizer defaultList: self subject elementArray.
- 			self subject categories ifNotNilDo:
- 				[:categories | categories do: [:ea |
- 					result classifyAll: (subject listAtCategoryNamed: ea) under: ea]]].
- 	classEditor edMethodsDo: [:ea |
- 		result classify: ea selector under: (self categoryOfElement: ea selector)].
- 	result
- 		edClassComment: self commentRemoteStr
- 		stamp: self commentStamp.
- 	^ result!

Item was removed:
- ----- Method: CategorizerEditor>>changesAddCategory:before: (in category 'subclass responsibility') -----
- changesAddCategory: newCategory before: nextCategory
- !

Item was removed:
- ----- Method: CategorizerEditor>>changesRemoveElement: (in category 'subclass responsibility') -----
- changesRemoveElement: element!

Item was removed:
- ----- Method: CategorizerEditor>>subjectCategories (in category 'private') -----
- subjectCategories
- 	self subject ifNil: [^ Array new].
- 	^ (self subject categories difference: removedCategories)
- 		collect: [:cat | self newCategoryFor: cat]!

Item was removed:
- ----- Method: CategorizerEditor>>changesRenameCategory:toBe: (in category 'subclass responsibility') -----
- changesRenameCategory: oldCategory toBe: newCategory!



More information about the Packages mailing list