Marcel Taeumel uploaded a new version of System to project The Trunk: http://source.squeak.org/trunk/System-mt.1246.mcz
==================== Summary ====================
Name: System-mt.1246 Author: mt Time: 18 November 2021, 4:58:20.988305 pm UUID: 836f218d-5bda-5146-a978-5f6072893f80 Ancestors: System-eem.1245, System-ct.1221
Merges System-ct.1221.
Extracts confirm-and-remove actions from Tools (e.g., Browser, Debugger, MessageSet) to SystemNavigation to - remove code duplication - reduce concept scattering - clarify the variations in tools themselves.
See Browser >> #removeClass as an example.
=============== Diff against System-eem.1245 ===============
Item was added: + ----- Method: SystemNavigation>>confirmAndRemoveClass: (in category 'ui') ----- + confirmAndRemoveClass: aClass + + | allCalls subclasses hasForeignCalls className numberOfMethods allChoices yourChoice remove browse| + allCalls := self allCallsOnClass: aClass. + subclasses := aClass subclasses. + hasForeignCalls := allCalls anySatisfy: [:ea | ea actualClass ~= aClass]. + + className := aClass name. + numberOfMethods := aClass methodDict size + aClass class methodDict size. + + allChoices := OrderedDictionary new. + allChoices at: 'Yes, remove it' translated put: [remove := true. browse := false]. + (allCalls notEmpty or: [subclasses notEmpty]) ifTrue: [ + allChoices at: 'Yes, remove it, then browse references' translated put: [remove := true. browse := true]. + allChoices at: 'No, don''t remove it, but browse references' translated put: [remove := false. browse := true]]. + allChoices at: 'No, don''t remove it' translated put: [remove := false. browse := false]. + + yourChoice := Project uiManager + chooseFromLabeledValues: allChoices + title: ('Are you sure that you want to remove\the class\ {1}\and all its {2} methods? Maybe save\your image before doing this.{3}{4}' translated withCRs asText format: { + className asText allBold. + numberOfMethods asString asText allBold. + hasForeignCalls ifFalse: [''] ifTrue: [ + '\(There are {1} references to this class.)' translated withCRs asText + format: { allCalls size asString asText allBold }]. + subclasses ifEmpty: [''] ifNotEmpty: [ + '\(There are {1} subclasses, whose superclass\must be updated manually after this.)' translated withCRs asText + format: { subclasses size asString asText allBold }] }). + + remove := browse := false. "Defaults" + yourChoice value. "Supports nil because of defaults above." + + remove ifTrue: [ + aClass removeFromSystem]. + browse ifTrue: [ + hasForeignCalls ifTrue: [ + self browseAllCallsOnClass: aClass]. + subclasses ifNotEmpty: [ + self + browseMessageList: (subclasses collect: [:subclass | MethodReference class: subclass selector: #Definition environment: self environment]) + name: ('Subclasses of {1}' translated format: {className}) + autoSelect: className]]. + + ^ remove!
Item was added: + ----- Method: SystemNavigation>>confirmAndRemoveMessageCategory:class: (in category 'ui') ----- + confirmAndRemoveMessageCategory: aCategory class: aClass + + | categoryList | + categoryList := aClass organization listAtCategoryNamed: aCategory. + + (categoryList isEmpty + or: [Project uiManager confirm: ('Are you sure you want to remove\the message category\ {1}\ from {2}\and all its {3} methods? Maybe save\your image before doing this.' translated withCRs asText format: { + aCategory asText allBold. + aClass name. + categoryList size asString asText allBold + + }) title: 'Remove Message Category' translated]) + ifFalse: [^ false]. + + aClass removeCategory: aCategory. + ^ true!
Item was added: + ----- Method: SystemNavigation>>confirmAndRemoveSelector:class: (in category 'ui') ----- + confirmAndRemoveSelector: selector class: aClass + + | method allCalls remove browse | + method := MethodReference class: aClass selector: selector environment: self environment. + allCalls := self allCallsOn: selector. + + (allCalls anySatisfy: [:ea | ea ~= method]) + ifFalse: [remove := true. browse := false] + ifTrue: [ | allChoices yourChoice | + + allChoices := OrderedDictionary new. + allChoices at: 'Yes, remove it' translated put: [remove := true. browse := false]. + allChoices at: 'Yes, remove it, then browse senders' translated put: [remove := true. browse := true]. + allChoices at: 'No, don''t remove it, but browse senders' translated put: [remove := false. browse := true]. + allChoices at: 'No, don''t remove it' translated put: [remove := false. browse := false]. + + yourChoice := Project uiManager + chooseFromLabeledValues: allChoices + title: ('Are you sure that you want to remove the message{1} from {2}?\The message has {3} senders.' withCRs translated asText format: { + selector asText allBold. + aClass name asText allBold. + allCalls size asString asText allBold }). + + remove := browse := false. "Defaults" + yourChoice value. "Supports nil because of defaults above."]. + + remove ifTrue: [ + aClass removeSelector: selector]. + browse ifTrue: [ + self headingAndAutoselectForLiteral: selector do: [ :label :autoSelect | + self + browseMessageList: allCalls + name: label + autoSelect: autoSelect]]. + + ^ remove!
Item was added: + ----- Method: SystemNavigation>>confirmAndRemoveSystemCategory: (in category 'ui') ----- + confirmAndRemoveSystemCategory: aCategory + + | systemOrganizer categoryList | + systemOrganizer := self environment organization. + categoryList := systemOrganizer listAtCategoryNamed: aCategory. + + (categoryList isEmpty + or: [Project uiManager + confirm: ('Are you sure you want to remove\the system category\ {1}\and all its {2} classes? Maybe save\your image before doing this.' translated withCRs asText + format: { + aCategory asText allBold. + categoryList size asString asText allBold}) + title: 'Remove System Category' translated]) + ifFalse: [^ false]. + systemOrganizer removeSystemCategory: aCategory. + ^ true!
Item was removed: - ----- Method: SystemNavigation>>confirmRemovalOf:on: (in category 'ui') ----- - confirmRemovalOf: aSelector on: aClass - "Determine if it is okay to remove the given selector. Answer 1 if it - should be removed, 2 if it should be removed followed by a senders - browse, and 3 if it should not be removed." - | count answer caption allCalls | - allCalls := self allCallsOn: aSelector. - (count := allCalls size) = 0 - ifTrue: [^ 1]. - "no senders -- let the removal happen without warning" - count = 1 - ifTrue: [(allCalls first actualClass == aClass - and: [allCalls first methodSymbol == aSelector]) - ifTrue: [^ 1]]. - "only sender is itself" - caption := 'The message "{1}" has {2} sender{3}.' translated format: {aSelector. count. count > 1 ifTrue: ['s'] ifFalse: ['']}. - - answer := UIManager default - chooseFrom: #('Remove it' - 'Remove, then browse senders' - 'Don''t remove, but show me those senders' - 'Forget it -- do nothing -- sorry I asked') title: caption. - answer = 3 - ifTrue: [self - browseMessageList: allCalls - name: 'Senders of ' , aSelector - autoSelect: aSelector keywords first]. - answer = 0 - ifTrue: [answer := 3]. - "If user didn't answer, treat it as cancel" - ^ answer min: 3!
packages@lists.squeakfoundation.org