Squeak – Message Bookmarks

Add a #browseSelectionAsMethods method to PluggableTextMorphPlus class. File it in with Shift-Cmd-G or add it in Browser.

PluggableTextMorphPlus>>#browseSelectionAsMethods

'From Squeak5.0 of 9 August 2016 [latest update: #15120] on 19 March 2017 at 10:35:58 pm'!

!PluggableTextMorphPlus methodsFor: 'menu' stamp: 'mva 3/19/2017 22:26'!
browseSelectionAsMethods
    | list |
    list := self textMorph editor selection asString lines.
    MessageSet
        openMessageList: list allButFirst
        name: list first.
! !

Add a menu item ‘browse selection as methods’

        #-.
        {'browse selection as methods' translated. #browseSelectionAsMethods}.
        #-.

to the local menu in Workspace text editor. You will find the items for the local menu in the method #yellowButtonMenuItems in StringHolder class on the class side. The … stands for elided code. Don’t replace the method, just add the code between … and … to it.

StringHolder class>>#yellowButtonMenuItems

'From Squeak5.0 of 9 August 2016 [latest update: #15120] on 19 March 2017 at 10:35:56 pm'!

!StringHolder class methodsFor: 'menu' stamp: 'mva 3/19/2017 22:24'!
yellowButtonMenuItems
    "Returns the standard yellow button menu items"
    ^{
        ...
        #-.
        {'browse selection as methods' translated. #browseSelectionAsMethods}.
        #-.
        ...
    }! !

Now you can select a block of text that looks like this

MessageSet
MessageSet>>#Definition
MessageSet class>>#Definition
MessageSet>>#Comment
MessageSet>>#Hierarchy
MessageSet class>>#openMessageList:name:

Right click it, select  ‘browse selection as methods’ from the local menu and you will get a Message Set Browser with the given methods.

The first line will become the window’s title. The following lines are expected to be method references. Read more about those below.

Squeak – How to bookmark a set of methods

list :=
'MessageSet
MessageSet>>#Definition
MessageSet class>>#Definition
MessageSet>>#Comment
MessageSet>>#Hierarchy
MessageSet class>>#openMessageList:name:
'
lines.

MessageSet
	openMessageList: list allButFirst
	name: list first.

Do-it to get a message list.
MessageSet
    openMessageList:
        #(
            'MessageSet>>#Definition'
            'MessageSet class>>#Definition'
            'MessageSet>>#Comment'
            'MessageSet>>#Hierarchy'
            'MessageSet class>>#openMessageList:name:'
        )
    name:
        'Bookmarks-1'
.

MessageSet
    openMessageList:

'
MessageSet>>#Definition
MessageSet class>>#Definition
MessageSet>>#Comment
MessageSet>>#Hierarchy
MessageSet class>>#openMessageList:name:
'
lines

    name:
        'Bookmarks-2'
.

To get a method reference of a method to clipboard :-

In Browser or Message list
right-click (yellow click) a message selector,
click 'copy reference (C)'

You get something like

MessageSet class>>#openMessageList:name:

Synthetic method selectors

The selectors
#Definition
#Comment
#Hierarchy
are ‘synthetic’ in that they refer not to a method but to
– the definition of the class
– the class comment
– the class hierarchy of the class

#Definition is the definition of the class as it would appear in code pane in Browser – either instance side or class side definition of the class. You only get one – either instance or class side definition. If you want to see both you need to have two method references. One for instance and one for class side definition of the class.

#Comment is the class comment of the class as it would appear in code pane in Browser when you press the ‘?’ button.

#Hierarchy is the class hierarchy of the class as it would appear in code pane in Browser when you press the ‘?’ button twice – the first press shows class comment, the second class hierarchy.

An Array Of Method References

Put apostrophes around method references and put one per line to get a list you can use in the code snippet above

        #(
            'MessageSet>>#Definition'
            'MessageSet class>>#Definition'
            'MessageSet>>#Comment'
            'MessageSet>>#Hierarchy'
            'MessageSet class>>#openMessageList:name:'
        )

.

 

 

Via CompiledMethod

compiledMethods := {
    MessageSet class>>#openMessageList:name: .
    MessageSet class>>#messageList: .
    MessageSet>>#initializeMessageList: .
    MethodReference>>#isMethodReference .
    OrderedCollection>>#addLast: .
}. 

MessageSet
    openMessageList:
        (compiledMethods collect: [:compiledMethod |
            MethodReference
               class: compiledMethod methodClass
               selector: compiledMethod selector ])
    name:
        'bookmarks'.

If any of the CompiledMethods does not exist, you get an error.

The textual variant will silently ignore non-existent methods.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s