Christoph Thiede uploaded a new version of Tools to project The Inbox:
http://source.squeak.org/inbox/Tools-ct.932.mcz ==================== Summary ==================== Name: Tools-ct.932 Author: ct Time: 19 January 2020, 9:56:38.355545 pm UUID: cfb85c45-de2c-e641-af0f-2cec865baf48 Ancestors: Tools-mt.929 Minor improvements to debugger's notifier support: - Allow to cancel method creation when asked for category - Always offer defaultCategory as first choice - Fix a bug in #askForSuperclassOf:upTo:toImplement:ifCancel: (superclass was not respected*) - Improve multilingual support - Select message to implement after implementing the method (see #removeNotifierContext:) - Refactoring, deduplication *Snippet to reproduce: c1 := Object newSubclass. c1 compile: 'foo'. c2 := c1 newSubclass. c2 compile: 'foo ^ self subclassResponsibility'. c3 := c2 newSubclass. c3 new foo. =============== Diff against Tools-mt.929 =============== Item was removed: - ----- Method: Debugger>>askForCategoryIn:default: (in category 'notifier support') ----- - askForCategoryIn: aClass default: aString - - ^ (Project uiManager - chooseFromOrAddTo: (aClass allMethodCategoriesIntegratedThrough: Object) - lines: #() - title: 'Please provide a good category for the new method' translated) - ifNil: [aString] - ifNotNil: [:newCategory | newCategory ifEmpty: [aString]]! Item was added: + ----- Method: Debugger>>askForCategoryIn:default:ifCancel: (in category 'notifier support') ----- + askForCategoryIn: aClass default: defaultCategory ifCancel: aBlock + + | categories category | + categories := (aClass allMethodCategoriesIntegratedThrough: Object) asOrderedCollection. + categories + remove: defaultCategory ifAbsent: []; + addFirst: defaultCategory. + category := Project uiManager + chooseFromOrAddTo: categories + lines: #(2) + title: 'Please provide a good category for the new method' translated. + category ifNil: [^ aBlock value]. + ^ category ifEmpty: [defaultCategory]! Item was changed: ----- Method: Debugger>>askForSuperclassOf:toImplement:ifCancel: (in category 'notifier support') ----- askForSuperclassOf: aClass toImplement: aSelector ifCancel: cancelBlock + + ^ self + askForSuperclassOf: aClass + upTo: nil + toImplement: aSelector + ifCancel: cancelBlock! - | classes chosenClassIndex | - classes := aClass withAllSuperclasses. - chosenClassIndex := UIManager default - chooseFrom: (classes collect: [:c | c name]) - title: 'Define #', aSelector, ' in which class?'. - chosenClassIndex = 0 ifTrue: [^ cancelBlock value]. - ^ classes at: chosenClassIndex! Item was changed: ----- Method: Debugger>>askForSuperclassOf:upTo:toImplement:ifCancel: (in category 'notifier support') ----- askForSuperclassOf: aClass upTo: superclass toImplement: aSelector ifCancel: cancelBlock + | classes chosenClassIndex | + classes := aClass withAllSuperclasses readStream upTo: superclass. - classes := aClass withAllSuperclasses reject: [:cls | aClass isKindOf: cls]. chosenClassIndex := UIManager default chooseFrom: (classes collect: [:c | c name]) + title: ('Define {1} in which class?' translated + format: {aSelector asSymbol printString}). - title: 'Define #', aSelector, ' in which class?'. chosenClassIndex = 0 ifTrue: [^ cancelBlock value]. ^ classes at: chosenClassIndex! Item was changed: ----- Method: Debugger>>createMethod (in category 'notifier buttons') ----- createMethod + "Should only be called when this Debugger was created in response to a MessageNotUnderstood exception. Create a stub for the method that was missing and proceed into it." - "Should only be called when this Debugger was created in response to a - MessageNotUnderstood exception. Create a stub for the method that was - missing and proceed into it." | msg chosenClass | self initializeFull. msg := self contextStackTop exceptionMessage. chosenClass := self askForSuperclassOf: self contextStackTop receiver class toImplement: msg selector ifCancel: [^self]. + self + implementMissingMethod: msg + inClass: chosenClass + ifCancel: [^self].! - self implementMissingMethod: msg inClass: chosenClass.! Item was removed: - ----- Method: Debugger>>implementMissingMethod:inClass: (in category 'notifier support') ----- - implementMissingMethod: aMessage inClass: aClass - ^ self - implementMissingMethod: aMessage - inClass: aClass - inCategory: (self askForCategoryIn: aClass default: 'as yet unclassified').! Item was added: + ----- Method: Debugger>>implementMissingMethod:inClass:ifCancel: (in category 'notifier support') ----- + implementMissingMethod: aMessage inClass: aClass ifCancel: aBlock + + | category | + category := self + askForCategoryIn: aClass + default: ClassOrganizer default + ifCancel: [^ aBlock value]. + ^ self + implementMissingMethod: aMessage + inClass: aClass + inCategory: category! Item was changed: ----- Method: Debugger>>implementMissingMethod:inClass:inCategory: (in category 'notifier support') ----- implementMissingMethod: aMessage inClass: aClass inCategory: aSymbol "Create a stub implementation of the missing message and sew it onto the top of the stack, ensuring the context's arguments are set correctly. Debug the new context." + + self + pushStubMethodOnStack: aMessage inClass: aClass inCategory: aSymbol; + removeNotifierContext: self selectedContext sender.! - self pushStubMethodOnStack: aMessage inClass: aClass inCategory: aSymbol. - - "Cut out the sender context. This is the context that signalled the MessageNotUnderstood." - self selectedContext privSender: self selectedContext sender. - self resetContext: self selectedContext. - self debug.! Item was changed: ----- Method: Debugger>>implementOverridingMethod:inClass:inCategory: (in category 'notifier support') ----- implementOverridingMethod: aMessage inClass: aClass inCategory: aSymbol "Create a stub implementation of the overriding message and sew it onto the top of the stack, ensuring the context's arguments are set correctly. Debug the new context." + + self + pushStubMethodOnStack: aMessage inClass: aClass inCategory: aSymbol; + removeNotifierContext: self selectedContext sender sender.! - self pushStubMethodOnStack: aMessage inClass: aClass inCategory: aSymbol. - - "Cut out the sender context. This is the context that signalled the SubclassResponsibility." - self selectedContext privSender: self selectedContext sender sender. - self resetContext: self selectedContext. - self debug.! Item was added: + ----- Method: Debugger>>removeNotifierContext: (in category 'notifier support') ----- + removeNotifierContext: aContext + "Cut out the sender context. This is the context that signalled a notification that triggered the notifier." + + self selectedContext privSender: aContext. + self resetContext: self selectedContext. + self debug; doStep. "for convenient selection"! |
Please note that I removed #implementMissingMethod:inClass: and #askForCategoryIn:default: directly instead of deprecating them (in favor of the new version with an additional #ifCancel: keyword). I think these methods are private enough, would you agree or should we move them into a deprecation category?
And please let me know whether this commit has an appropriate size, I always strive for optimization :-)
Best, Christoph Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Sonntag, 19. Januar 2020 21:56:42 An: [hidden email] Betreff: [squeak-dev] The Inbox: Tools-ct.932.mcz Christoph Thiede uploaded a new version of Tools to project The Inbox:
http://source.squeak.org/inbox/Tools-ct.932.mcz ==================== Summary ==================== Name: Tools-ct.932 Author: ct Time: 19 January 2020, 9:56:38.355545 pm UUID: cfb85c45-de2c-e641-af0f-2cec865baf48 Ancestors: Tools-mt.929 Minor improvements to debugger's notifier support: - Allow to cancel method creation when asked for category - Always offer defaultCategory as first choice - Fix a bug in #askForSuperclassOf:upTo:toImplement:ifCancel: (superclass was not respected*) - Improve multilingual support - Select message to implement after implementing the method (see #removeNotifierContext:) - Refactoring, deduplication *Snippet to reproduce: c1 := Object newSubclass. c1 compile: 'foo'. c2 := c1 newSubclass. c2 compile: 'foo ^ self subclassResponsibility'. c3 := c2 newSubclass. c3 new foo. =============== Diff against Tools-mt.929 =============== Item was removed: - ----- Method: Debugger>>askForCategoryIn:default: (in category 'notifier support') ----- - askForCategoryIn: aClass default: aString - - ^ (Project uiManager - chooseFromOrAddTo: (aClass allMethodCategoriesIntegratedThrough: Object) - lines: #() - title: 'Please provide a good category for the new method' translated) - ifNil: [aString] - ifNotNil: [:newCategory | newCategory ifEmpty: [aString]]! Item was added: + ----- Method: Debugger>>askForCategoryIn:default:ifCancel: (in category 'notifier support') ----- + askForCategoryIn: aClass default: defaultCategory ifCancel: aBlock + + | categories category | + categories := (aClass allMethodCategoriesIntegratedThrough: Object) asOrderedCollection. + categories + remove: defaultCategory ifAbsent: []; + addFirst: defaultCategory. + category := Project uiManager + chooseFromOrAddTo: categories + lines: #(2) + title: 'Please provide a good category for the new method' translated. + category ifNil: [^ aBlock value]. + ^ category ifEmpty: [defaultCategory]! Item was changed: ----- Method: Debugger>>askForSuperclassOf:toImplement:ifCancel: (in category 'notifier support') ----- askForSuperclassOf: aClass toImplement: aSelector ifCancel: cancelBlock + + ^ self + askForSuperclassOf: aClass + upTo: nil + toImplement: aSelector + ifCancel: cancelBlock! - | classes chosenClassIndex | - classes := aClass withAllSuperclasses. - chosenClassIndex := UIManager default - chooseFrom: (classes collect: [:c | c name]) - title: 'Define #', aSelector, ' in which class?'. - chosenClassIndex = 0 ifTrue: [^ cancelBlock value]. - ^ classes at: chosenClassIndex! Item was changed: ----- Method: Debugger>>askForSuperclassOf:upTo:toImplement:ifCancel: (in category 'notifier support') ----- askForSuperclassOf: aClass upTo: superclass toImplement: aSelector ifCancel: cancelBlock + | classes chosenClassIndex | + classes := aClass withAllSuperclasses readStream upTo: superclass. - classes := aClass withAllSuperclasses reject: [:cls | aClass isKindOf: cls]. chosenClassIndex := UIManager default chooseFrom: (classes collect: [:c | c name]) + title: ('Define {1} in which class?' translated + format: {aSelector asSymbol printString}). - title: 'Define #', aSelector, ' in which class?'. chosenClassIndex = 0 ifTrue: [^ cancelBlock value]. ^ classes at: chosenClassIndex! Item was changed: ----- Method: Debugger>>createMethod (in category 'notifier buttons') ----- createMethod + "Should only be called when this Debugger was created in response to a MessageNotUnderstood exception. Create a stub for the method that was missing and proceed into it." - "Should only be called when this Debugger was created in response to a - MessageNotUnderstood exception. Create a stub for the method that was - missing and proceed into it." | msg chosenClass | self initializeFull. msg := self contextStackTop exceptionMessage. chosenClass := self askForSuperclassOf: self contextStackTop receiver class toImplement: msg selector ifCancel: [^self]. + self + implementMissingMethod: msg + inClass: chosenClass + ifCancel: [^self].! - self implementMissingMethod: msg inClass: chosenClass.! Item was removed: - ----- Method: Debugger>>implementMissingMethod:inClass: (in category 'notifier support') ----- - implementMissingMethod: aMessage inClass: aClass - ^ self - implementMissingMethod: aMessage - inClass: aClass - inCategory: (self askForCategoryIn: aClass default: 'as yet unclassified').! Item was added: + ----- Method: Debugger>>implementMissingMethod:inClass:ifCancel: (in category 'notifier support') ----- + implementMissingMethod: aMessage inClass: aClass ifCancel: aBlock + + | category | + category := self + askForCategoryIn: aClass + default: ClassOrganizer default + ifCancel: [^ aBlock value]. + ^ self + implementMissingMethod: aMessage + inClass: aClass + inCategory: category! Item was changed: ----- Method: Debugger>>implementMissingMethod:inClass:inCategory: (in category 'notifier support') ----- implementMissingMethod: aMessage inClass: aClass inCategory: aSymbol "Create a stub implementation of the missing message and sew it onto the top of the stack, ensuring the context's arguments are set correctly. Debug the new context." + + self + pushStubMethodOnStack: aMessage inClass: aClass inCategory: aSymbol; + removeNotifierContext: self selectedContext sender.! - self pushStubMethodOnStack: aMessage inClass: aClass inCategory: aSymbol. - - "Cut out the sender context. This is the context that signalled the MessageNotUnderstood." - self selectedContext privSender: self selectedContext sender. - self resetContext: self selectedContext. - self debug.! Item was changed: ----- Method: Debugger>>implementOverridingMethod:inClass:inCategory: (in category 'notifier support') ----- implementOverridingMethod: aMessage inClass: aClass inCategory: aSymbol "Create a stub implementation of the overriding message and sew it onto the top of the stack, ensuring the context's arguments are set correctly. Debug the new context." + + self + pushStubMethodOnStack: aMessage inClass: aClass inCategory: aSymbol; + removeNotifierContext: self selectedContext sender sender.! - self pushStubMethodOnStack: aMessage inClass: aClass inCategory: aSymbol. - - "Cut out the sender context. This is the context that signalled the SubclassResponsibility." - self selectedContext privSender: self selectedContext sender sender. - self resetContext: self selectedContext. - self debug.! Item was added: + ----- Method: Debugger>>removeNotifierContext: (in category 'notifier support') ----- + removeNotifierContext: aContext + "Cut out the sender context. This is the context that signalled a notification that triggered the notifier." + + self selectedContext privSender: aContext. + self resetContext: self selectedContext. + self debug; doStep. "for convenient selection"!
Carpe Squeak!
|
Free forum by Nabble | Edit this page |