[squeak-dev] The Inbox: Protocols-jr.82.mcz
Jakob Reschke
jakres+squeak at gmail.com
Fri May 14 13:55:49 UTC 2021
Note that I only briefly tested this as follows: open another Lexicon,
see whether any errors pop up, search for a selector, change the
selection, drag out a method. As you can see that I uploaded this, I
saw no regressions during these steps.
Am Fr., 14. Mai 2021 um 15:52 Uhr schrieb <commits at source.squeak.org>:
>
> A new version of Protocols was added to project The Inbox:
> http://source.squeak.org/inbox/Protocols-jr.82.mcz
>
> ==================== Summary ====================
>
> Name: Protocols-jr.82
> Author: jr
> Time: 14 May 2021, 3:52:50.855866 pm
> UUID: fa44c7c0-1902-5140-be89-51048d272a3c
> Ancestors: Protocols-nice.81
>
> Use MethodReferences in "browse protocol". Enables to drag methods out to the World and have CodeHolders opened on them, like it was introduced in Morphic-mt.1733.
>
> =============== Diff against Protocols-nice.81 ===============
>
> Item was changed:
> ----- Method: Lexicon>>displaySelector: (in category 'basic operation') -----
> displaySelector: aSelector
> "Set aSelector to be the one whose source shows in the browser. If there is a category list, make it highlight a suitable category"
>
> | detectedItem messageIndex |
> self chooseCategory: (self categoryDefiningSelector: aSelector).
> detectedItem := messageList detect:
> + [:anItem | anItem selector == aSelector] ifNone: [^ Beeper beep].
> - [:anItem | (anItem asString copyUpTo: Character space) asSymbol == aSelector] ifNone: [^ Beeper beep].
> messageIndex := messageList indexOf: detectedItem.
> self messageListIndex: messageIndex!
>
> Item was changed:
> ----- Method: Lexicon>>initListFrom:highlighting: (in category 'initialization') -----
> initListFrom: selectorCollection highlighting: aClass
> "Make up the messageList with items from aClass in boldface. Provide a final filtering in that only selectors whose implementations fall within my limitClass will be shown."
>
>
> messageList := OrderedCollection new.
> selectorCollection do:
> + [:selector | | item text defClass |
> + defClass := aClass whichClassIncludesSelector: selector.
> - [:selector | | item defClass | defClass := aClass whichClassIncludesSelector: selector.
> (defClass notNil and: [defClass includesBehavior: self limitClass]) ifTrue:
> + [item := MethodReference class: defClass selector: selector.
> + text := selector, ' (' , defClass name , ')'.
> + text := text asText.
> + defClass == aClass ifTrue: [text allBold].
> + item stringVersion: text.
> - [item := selector, ' (' , defClass name , ')'.
> - item := item asText.
> - defClass == aClass ifTrue: [item allBold].
> "(self isThereAnOverrideOf: selector) ifTrue: [item addAttribute: TextEmphasis struckOut]."
> "The above has a germ of a good idea but could be very slow"
> messageList add: item]]!
>
> Item was changed:
> ----- Method: Lexicon>>selectSelectorItsNaturalCategory: (in category 'selection') -----
> selectSelectorItsNaturalCategory: aSelector
> "Make aSelector be the current selection of the receiver, with the category being its home category."
>
> | cat catIndex detectedItem |
> cat := self categoryOfSelector: aSelector.
> catIndex := categoryList indexOf: cat ifAbsent:
> ["The method's own category is not seen in this browser; the method probably occurs in some other category not known directly to the class, but for now, we'll just use the all category"
> 1].
> self categoryListIndex: catIndex.
> detectedItem := messageList detect:
> + [:anItem | anItem selector == aSelector] ifNone: [^ self].
> - [:anItem | (anItem asString copyUpTo: Character space) asSymbol == aSelector] ifNone: [^ self].
> self messageListIndex: (messageList indexOf: detectedItem ifAbsent: [^ self])!
>
> Item was changed:
> ----- Method: Lexicon>>selectWithinCurrentCategory: (in category 'selection') -----
> selectWithinCurrentCategory: aSelector
> "If aSelector is one of the selectors seen in the current category, select it"
>
> | detectedItem |
> detectedItem := self messageList detect:
> + [:anItem | anItem selector == aSelector] ifNone: [^ self].
> - [:anItem | (anItem asString copyUpTo: Character space) asSymbol == aSelector] ifNone: [^ self].
> self messageListIndex: (messageList indexOf: detectedItem ifAbsent: [^ self])!
>
> Item was changed:
> ----- Method: Lexicon>>selectWithinCurrentCategoryIfPossible: (in category 'category list') -----
> selectWithinCurrentCategoryIfPossible: aSelector
> "If the receiver's message list contains aSelector, navigate right to it without changing categories"
>
> | detectedItem messageIndex |
> aSelector ifNil: [^ self].
> detectedItem := messageList detect:
> + [:anItem | anItem selector == aSelector] ifNone: [^ self].
> - [:anItem | (anItem asString copyUpTo: $ ) asSymbol == aSelector] ifNone: [^ self].
> messageIndex := messageList indexOf: detectedItem.
> self messageListIndex: messageIndex
> !
>
> Item was changed:
> ----- Method: Lexicon>>setToShowSelector:selectCategory: (in category 'selection') -----
> setToShowSelector: selectorString selectCategory: aBoolean
> "Set up the receiver so that it will show the given selector"
> | catName catIndex messageIndex aList |
> catName := aBoolean
> ifTrue:
> [ (aList := currentVocabulary
> categoriesContaining: selectorString
> forClass: targetClass)
> at: 1
> ifAbsent: [ self class allCategoryName ] ]
> ifFalse: [ self class allCategoryName ].
> catIndex := categoryList
> indexOf: catName
> ifAbsent: [ 1 ].
> self categoryListIndex: catIndex.
> messageList
> detect:
> + [ : anItem | anItem selector == selectorString ]
> - [ : anItem | (anItem copyUpTo: Character space) asString asSymbol == selectorString ]
> ifFound:
> [ : detectedItem | messageIndex := messageList indexOf: detectedItem.
> self messageListIndex: messageIndex ]
> ifNone: [ ^ self ]!
>
>
More information about the Squeak-dev
mailing list
|