Christoph Thiede uploaded a new version of Tools to project The Inbox:
http://source.squeak.org/inbox/Tools-ct.933.mcz ==================== Summary ==================== Name: Tools-ct.933 Author: ct Time: 19 January 2020, 11:30:07.448545 pm UUID: 07b49992-f5e3-f14a-af86-82ed4b35cee6 Ancestors: Tools-mt.929 Slightly revise stub method generation. - In case of multiple-keyword messages, don't leave a space at the end of the header line - In case of exactly two keywords of the same class, name them 'anObject' and 'anotherObject' rather than numbering them - Eliminate unwanted 'anUndefinedObject' arguments and replace them with 'anObject' instead - Refactoring/decomposition =============== Diff against Tools-mt.929 =============== Item was added: + ----- Method: Message>>createStubArguments (in category '*Tools-Debugger') ----- + createStubArguments + + | argNames canonicalNames canonicalQuantities | + argNames := OrderedCollection new: self arguments size. + canonicalNames := self arguments collect: #canonicalArgumentName. + canonicalQuantities := canonicalNames asBag valuesAndCounts. + canonicalNames withIndexDo: [:canonicalName :index | + | argName | + argName := canonicalName in: [:name | + (name first isVowel ifTrue: ['an'] ifFalse: ['a']), name]. + (argNames includes: argName) ifTrue: [ + (canonicalQuantities at: canonicalName) = 2 + ifTrue: [ + argName := 'another' , canonicalName] + ifFalse: [ + [argNames includes: argName] + whileTrue: [argName := argName , index]]]. + argNames add: argName]. + ^ argNames! Item was changed: ----- Method: Message>>createStubMethod (in category '*Tools-Debugger') ----- createStubMethod + | argNames | argNames := Set new. + ^ String streamContents: [ :stream | + self printStubPatternOn: stream. + stream + crtab; + nextPutAll: '^ self shouldBeImplemented' ]! - ^ String streamContents: [ :s | - self selector keywords doWithIndex: [ :key :i | - | aOrAn argName arg argClassName | - s nextPutAll: key. - ((key last = $:) or: [self selector isInfix]) ifTrue: [ - arg := self arguments at: i. - argClassName := arg canonicalArgumentName. - aOrAn := argClassName first isVowel ifTrue: ['an'] ifFalse: ['a']. - argName := aOrAn, argClassName. - [argNames includes: argName] whileTrue: [argName := argName, i asString]. - argNames add: argName. - s nextPutAll: ' '; nextPutAll: argName; space - ]. - ]. - s cr; tab. - s nextPutAll: 'self shouldBeImplemented' - ].! Item was added: + ----- Method: Message>>printStubPatternOn: (in category '*Tools-Debugger') ----- + printStubPatternOn: aStream + + | arguments | + self selector isUnary + ifTrue: [^ aStream nextPutAll: self selector]. + arguments := self createStubArguments. + self selector keywords with: arguments do: [:key :argName | + aStream + nextPutAll: key; + space; + nextPutAll: argName; + space]. + aStream skip: -1.! Item was added: + ----- Method: UndefinedObject>>canonicalArgumentName (in category '*Tools-Debugger') ----- + canonicalArgumentName + "It is never useful to expect nil as an argument" + ^ self class superclass name! |
> - In case of multiple-keyword messages, don't leave a space at the end of the header line For illustration: This (though absolutely minor) bug has already affected more than 15 % of all methods in a pure Trunk image.* It is great that so many people use this exciting workflow! :D
*Vivide users can convince themselves of this statistic by running (takes a few seconds):
Best,
Christoph
Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Sonntag, 19. Januar 2020 23:30 Uhr An: [hidden email] Betreff: [squeak-dev] The Inbox: Tools-ct.933.mcz Christoph Thiede uploaded a new version of Tools to project The Inbox:
http://source.squeak.org/inbox/Tools-ct.933.mcz ==================== Summary ==================== Name: Tools-ct.933 Author: ct Time: 19 January 2020, 11:30:07.448545 pm UUID: 07b49992-f5e3-f14a-af86-82ed4b35cee6 Ancestors: Tools-mt.929 Slightly revise stub method generation. - In case of multiple-keyword messages, don't leave a space at the end of the header line - In case of exactly two keywords of the same class, name them 'anObject' and 'anotherObject' rather than numbering them - Eliminate unwanted 'anUndefinedObject' arguments and replace them with 'anObject' instead - Refactoring/decomposition =============== Diff against Tools-mt.929 =============== Item was added: + ----- Method: Message>>createStubArguments (in category '*Tools-Debugger') ----- + createStubArguments + + | argNames canonicalNames canonicalQuantities | + argNames := OrderedCollection new: self arguments size. + canonicalNames := self arguments collect: #canonicalArgumentName. + canonicalQuantities := canonicalNames asBag valuesAndCounts. + canonicalNames withIndexDo: [:canonicalName :index | + | argName | + argName := canonicalName in: [:name | + (name first isVowel ifTrue: ['an'] ifFalse: ['a']), name]. + (argNames includes: argName) ifTrue: [ + (canonicalQuantities at: canonicalName) = 2 + ifTrue: [ + argName := 'another' , canonicalName] + ifFalse: [ + [argNames includes: argName] + whileTrue: [argName := argName , index]]]. + argNames add: argName]. + ^ argNames! Item was changed: ----- Method: Message>>createStubMethod (in category '*Tools-Debugger') ----- createStubMethod + | argNames | argNames := Set new. + ^ String streamContents: [ :stream | + self printStubPatternOn: stream. + stream + crtab; + nextPutAll: '^ self shouldBeImplemented' ]! - ^ String streamContents: [ :s | - self selector keywords doWithIndex: [ :key :i | - | aOrAn argName arg argClassName | - s nextPutAll: key. - ((key last = $:) or: [self selector isInfix]) ifTrue: [ - arg := self arguments at: i. - argClassName := arg canonicalArgumentName. - aOrAn := argClassName first isVowel ifTrue: ['an'] ifFalse: ['a']. - argName := aOrAn, argClassName. - [argNames includes: argName] whileTrue: [argName := argName, i asString]. - argNames add: argName. - s nextPutAll: ' '; nextPutAll: argName; space - ]. - ]. - s cr; tab. - s nextPutAll: 'self shouldBeImplemented' - ].! Item was added: + ----- Method: Message>>printStubPatternOn: (in category '*Tools-Debugger') ----- + printStubPatternOn: aStream + + | arguments | + self selector isUnary + ifTrue: [^ aStream nextPutAll: self selector]. + arguments := self createStubArguments. + self selector keywords with: arguments do: [:key :argName | + aStream + nextPutAll: key; + space; + nextPutAll: argName; + space]. + aStream skip: -1.! Item was added: + ----- Method: UndefinedObject>>canonicalArgumentName (in category '*Tools-Debugger') ----- + canonicalArgumentName + "It is never useful to expect nil as an argument" + ^ self class superclass name!
Carpe Squeak!
|
Ah, and just another concern (sorry for triple-posting ...):
This commit breaks DebuggerExtensionsTest >> #testOtherObjectsDontGeneralise, which expects nil canonicalArgumentName to return 'UndefinedObject'. Honestly, I do not really understand the motivation of this test suite's granularity. It tests each single related trivial one-liner! My experience with this kind of tests is that they slow down the everyday workflow - you have a notable overhead by patching them to follow the implementation. And this isn't even a critical domain where a wrong character would blow everything up.
Opinions? Would anyone disagree with the proposed change of UndefinedObject >> #canonicalArgumentName?
Best, Christoph Von: Squeak-dev <[hidden email]> im Auftrag von Thiede, Christoph
Gesendet: Sonntag, 19. Januar 2020 23:37:52 An: [hidden email] Betreff: Re: [squeak-dev] The Inbox: Tools-ct.933.mcz > - In case of multiple-keyword messages, don't leave a space at the end of the header line For illustration: This (though absolutely minor) bug has already affected more than 15 % of all methods in a pure Trunk image.* It is great that so many people use this exciting workflow! :D
*Vivide users can convince themselves of this statistic by running (takes a few seconds):
Best,
Christoph
Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Sonntag, 19. Januar 2020 23:30 Uhr An: [hidden email] Betreff: [squeak-dev] The Inbox: Tools-ct.933.mcz Christoph Thiede uploaded a new version of Tools to project The Inbox:
http://source.squeak.org/inbox/Tools-ct.933.mcz ==================== Summary ==================== Name: Tools-ct.933 Author: ct Time: 19 January 2020, 11:30:07.448545 pm UUID: 07b49992-f5e3-f14a-af86-82ed4b35cee6 Ancestors: Tools-mt.929 Slightly revise stub method generation. - In case of multiple-keyword messages, don't leave a space at the end of the header line - In case of exactly two keywords of the same class, name them 'anObject' and 'anotherObject' rather than numbering them - Eliminate unwanted 'anUndefinedObject' arguments and replace them with 'anObject' instead - Refactoring/decomposition =============== Diff against Tools-mt.929 =============== Item was added: + ----- Method: Message>>createStubArguments (in category '*Tools-Debugger') ----- + createStubArguments + + | argNames canonicalNames canonicalQuantities | + argNames := OrderedCollection new: self arguments size. + canonicalNames := self arguments collect: #canonicalArgumentName. + canonicalQuantities := canonicalNames asBag valuesAndCounts. + canonicalNames withIndexDo: [:canonicalName :index | + | argName | + argName := canonicalName in: [:name | + (name first isVowel ifTrue: ['an'] ifFalse: ['a']), name]. + (argNames includes: argName) ifTrue: [ + (canonicalQuantities at: canonicalName) = 2 + ifTrue: [ + argName := 'another' , canonicalName] + ifFalse: [ + [argNames includes: argName] + whileTrue: [argName := argName , index]]]. + argNames add: argName]. + ^ argNames! Item was changed: ----- Method: Message>>createStubMethod (in category '*Tools-Debugger') ----- createStubMethod + | argNames | argNames := Set new. + ^ String streamContents: [ :stream | + self printStubPatternOn: stream. + stream + crtab; + nextPutAll: '^ self shouldBeImplemented' ]! - ^ String streamContents: [ :s | - self selector keywords doWithIndex: [ :key :i | - | aOrAn argName arg argClassName | - s nextPutAll: key. - ((key last = $:) or: [self selector isInfix]) ifTrue: [ - arg := self arguments at: i. - argClassName := arg canonicalArgumentName. - aOrAn := argClassName first isVowel ifTrue: ['an'] ifFalse: ['a']. - argName := aOrAn, argClassName. - [argNames includes: argName] whileTrue: [argName := argName, i asString]. - argNames add: argName. - s nextPutAll: ' '; nextPutAll: argName; space - ]. - ]. - s cr; tab. - s nextPutAll: 'self shouldBeImplemented' - ].! Item was added: + ----- Method: Message>>printStubPatternOn: (in category '*Tools-Debugger') ----- + printStubPatternOn: aStream + + | arguments | + self selector isUnary + ifTrue: [^ aStream nextPutAll: self selector]. + arguments := self createStubArguments. + self selector keywords with: arguments do: [:key :argName | + aStream + nextPutAll: key; + space; + nextPutAll: argName; + space]. + aStream skip: -1.! Item was added: + ----- Method: UndefinedObject>>canonicalArgumentName (in category '*Tools-Debugger') ----- + canonicalArgumentName + "It is never useful to expect nil as an argument" + ^ self class superclass name!
Carpe Squeak!
|
Free forum by Nabble | Edit this page |