Christoph Thiede uploaded a new version of Kernel to project The Trunk: http://source.squeak.org/trunk/Kernel-ct.1522.mcz
==================== Summary ====================
Name: Kernel-ct.1522 Author: ct Time: 17 August 2023, 1:50:03.497905 pm UUID: abf58cc7-53ac-5042-9c7e-861cbfb5e6dd Ancestors: Kernel-ct.1521
Merges sanitize-cat-names.1.cs (step 2/2): Sanitizes names of categories and packages by removing leading/trailing blanks before construction/lookup. This fixes a bug with invisible categories in the tree browser. Answer new package from PackageOrganizer>>#registerPackage*. Recategorize PackageServices.
Must be loaded after Kernel-ct.1521 (step 1/2).
=============== Diff against Kernel-ct.1521 ===============
Item was changed: ----- Method: Categorizer>>addCategory:before: (in category 'accessing') ----- addCategory: catString before: nextCategory "Add a new category named heading. If default category exists and is empty, remove it. If nextCategory is nil, then add the new one at the end, otherwise, insert it before nextCategory." | index newCategory | + newCategory := (self sanitizeName: catString) asSymbol. - newCategory := catString asSymbol. (categoryArray indexOf: newCategory) > 0 ifTrue: [^self]. "heading already exists, so done" (self isSpecialCategoryName: newCategory) ifTrue: [^self inform: 'This category name is system reserved' translated]. index := categoryArray indexOf: nextCategory ifAbsent: [categoryArray size + 1]. categoryArray := categoryArray copyReplaceFrom: index to: index-1 with: (Array with: newCategory). categoryStops := categoryStops copyReplaceFrom: index to: index-1 with: (Array with: (index = 1 ifTrue: [0] ifFalse: [categoryStops at: index-1])). "remove empty default category" (newCategory ~= Default and: [(self listAtCategoryNamed: Default) isEmpty]) ifTrue: [self removeCategory: Default]!
Item was changed: ----- Method: Categorizer>>classify:under:suppressIfDefault: (in category 'classifying') ----- classify: element under: heading suppressIfDefault: aBoolean "Store the argument, element, in the category named heading. If aBoolean is true, then invoke special logic such that the classification is NOT done if the new heading is the Default and the element already had a non-Default classification -- useful for filein"
| catName catIndex elemIndex realHeading | realHeading := (heading isEmptyOrNil or: [self isSpecialCategoryName: heading]) ifTrue: [Default] + ifFalse: [(self sanitizeName: heading) asSymbol]. - ifFalse: [heading asSymbol]. (catName := self categoryOfElement: element) = realHeading ifTrue: [^ self]. "done if already under that category"
catName ifNotNil: [ (aBoolean and: [realHeading = Default]) ifTrue: [^ self]. "return if non-Default category already assigned in memory" self basicRemoveElement: element]. "remove if in another category"
(categoryArray indexOf: realHeading) = 0 ifTrue: [self addCategory: realHeading].
catIndex := categoryArray indexOf: realHeading. elemIndex := catIndex > 1 ifTrue: [categoryStops at: catIndex - 1] ifFalse: [0]. [(elemIndex := elemIndex + 1) <= (categoryStops at: catIndex) and: [element >= (elementArray at: elemIndex)]] whileTrue.
"elemIndex is now the index for inserting the element. Do the insertion before it." elementArray := elementArray copyReplaceFrom: elemIndex to: elemIndex-1 with: (Array with: element).
"add one to stops for this and later categories" catIndex to: categoryArray size do: [:i | categoryStops at: i put: (categoryStops at: i) + 1].
((categoryArray includes: Default) and: [(self listAtCategoryNamed: Default) size = 0]) ifTrue: [self removeCategory: Default]. self assertInvariant.!
Item was changed: ----- Method: Categorizer>>listAtCategoryNamed: (in category 'accessing') ----- listAtCategoryNamed: categoryName "Answer the array of elements associated with the name, categoryName."
| i | + i := categoryArray indexOf: (self sanitizeName: categoryName) ifAbsent: [^Array new]. - i := categoryArray indexOf: categoryName ifAbsent: [^Array new]. ^self listAtCategoryNumber: i!
Item was changed: ----- Method: Categorizer>>removeCategory: (in category 'accessing') ----- removeCategory: cat "Remove the category named, cat. Create an error notificiation if the category has any elements in it."
| index lastStop | + index := categoryArray indexOf: (self sanitizeName: cat) ifAbsent: [^self]. - index := categoryArray indexOf: cat ifAbsent: [^self]. lastStop := index = 1 ifTrue: [0] ifFalse: [categoryStops at: index - 1]. (categoryStops at: index) - lastStop > 0 ifTrue: [^self error: 'cannot remove non-empty category']. categoryArray := categoryArray copyReplaceFrom: index to: index with: Array new. categoryStops := categoryStops copyReplaceFrom: index to: index with: Array new. categoryArray size = 0 ifTrue: [categoryArray := Array with: Default. categoryStops := Array with: 0] !
Item was changed: ----- Method: Categorizer>>renameCategory:toBe: (in category 'accessing') ----- renameCategory: oldCatString toBe: newCatString "Rename a category. No action if new name already exists, or if old name does not exist." | index oldCategory newCategory | + oldCategory := (self sanitizeName: oldCatString) asSymbol. + newCategory := (self sanitizeName: newCatString) asSymbol. - oldCategory := oldCatString asSymbol. - newCategory := newCatString asSymbol. (categoryArray indexOf: newCategory) > 0 ifTrue: [^ self]. "new name exists, so no action" (index := categoryArray indexOf: oldCategory) = 0 ifTrue: [^ self]. "old name not found, so no action" categoryArray := categoryArray copy. "need to change identity so smart list update will notice the change" categoryArray at: index put: newCategory!
Item was changed: ----- Method: ClassOrganizer>>addCategory:before: (in category 'accessing') ----- addCategory: catString before: nextCategory SystemChangeNotifier uniqueInstance doSilently: [super addCategory: catString before: nextCategory]; + protocolAdded: (self sanitizeName: catString) inClass: self subject! - protocolAdded: catString inClass: self subject!
Item was changed: ----- Method: ClassOrganizer>>removeCategory: (in category 'accessing') ----- removeCategory: cat SystemChangeNotifier uniqueInstance doSilently: [super removeCategory: cat]; + protocolRemoved: (self sanitizeName: cat) inClass: self subject! - protocolRemoved: cat inClass: self subject!
Item was changed: ----- Method: ClassOrganizer>>renameCategory:toBe: (in category 'accessing') ----- renameCategory: oldCatString toBe: newCatString SystemChangeNotifier uniqueInstance doSilently: [super renameCategory: oldCatString toBe: newCatString]; + protocolRenamedFrom: (self sanitizeName: oldCatString) asSymbol to: (self sanitizeName: newCatString) asSymbol inClass: self subject. + self logSelectorsInChangedCategory: (self sanitizeName: newCatString). - protocolRenamedFrom: oldCatString asSymbol to: newCatString asSymbol inClass: self subject. - self logSelectorsInChangedCategory: newCatString. !
packages@lists.squeakfoundation.org