The Inbox: Kernel-ct.1287.mcz

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

The Inbox: Kernel-ct.1287.mcz

commits-2
A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-ct.1287.mcz

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

Name: Kernel-ct.1287
Author: ct
Time: 13 December 2019, 7:01:04.635029 pm
UUID: b748ffbb-527a-3c42-8669-654a28068319
Ancestors: Kernel-mt.1286

Fixes selector classification with special category names, such as the all category or the null category.

Reproduce this issue by moving a method from one class into another and dropping it over the all category.

This bug might probably be the reason why we Utilities >> #fixUpProblemsWithAllCategory was introduced.

=============== Diff against Kernel-mt.1286 ===============

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 := 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 isNil or: [self isSpecialCategoryName: heading])
+ ifTrue: [Default]
+ ifFalse: [heading asSymbol].
- ((heading = NullCategory) or: [heading == nil])
- ifTrue: [realHeading := Default]
- ifFalse: [realHeading := heading asSymbol].
  (catName := self categoryOfElement: element) = realHeading
  ifTrue: [^ self].  "done if already under that category"
 
+ catName ifNotNil: [
+ (aBoolean and: [realHeading = Default])
- catName ~~ nil ifTrue:
- [(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 added:
+ ----- Method: Categorizer>>isSpecialCategoryName: (in category 'testing') -----
+ isSpecialCategoryName: aName
+
+ ^ {self class nullCategory. self class allCategory}
+ includes: aName asSymbol!