Some cool RewriteTool tricks
David Mitchell
dmitchell4 at kc.rr.com
Sun Feb 27 05:00:07 UTC 2005
Thanks Ned.
The rewrite tool was always one of my favorite tools when I did
Smalltalk for a living. I've been Squeaking for a long time (1.18), but
I haven't kept current on the development tools since 3.x.
This was the impetus that I needed to try things out.
I am passing on the (small) hurdles I had to cross to get this working,
in case there are other newbish folks out who want to see some cool
refactoring stuff.
a 3.8 gamma image (I got 3.8g 6548).
Load code updates (I moved to 6590).
Open SqueakMap to get Monticello (I got 219 because 223 gave me a
debugger on load).
Took me a minute to figure out that the SqueakMap version of Refactory
was called the Refactoring Browser for 3.8.
Learned how to load a Monticello file distribution.
But then everything worked.
very cool!
--David Mitchell
P.S. -- It was nice to good doc for MC (on wiresong.ca) that answered my
questions. Chris Muller had shown me MC a few months ago, but I didn't
get how to use it (as I was blinded by some other cool things he was
showing me).
Ned Konz wrote:
> Assuming that you've loaded:
> * Monticello
> * the SqueakMap version of Refactory (Refactory-md.3.8.12)
> * my latest RB improvements
> (http://bike-nomad.com/squeak/Refactory-nk.3830.mcd)
>
> you can try out some interesting tricks with the FinderTool and the new
> RewriteTool:
>
> For instance:
>
> * to find sends to globals that they don't understand (I have a Lint rule for
> this, but...) (this could also be done in the search pattern, as in the
> second example):
>
> search for:
> `{:node :context | node isVariable and: [ Smalltalk includesKey: node name
> asSymbol ] } `@message: `@args
>
> and use this condition:
> | what | what := Smalltalk at: aNode receiver name asSymbol.
> what notNil
> and: [ what ~~ Preferences
> and: [ (what respondsTo: aNode selector) not ]]
>
> * to find references to all globals that aren't classes, search for:
>
> `{:node :context | | what | node isVariable and: [ (what := Smalltalk at: node
> name ifAbsent: []) notNil and: [ what isBehavior not ] ] }
>
> * to replace all menu constructors that use #labels:lines:selections: to use
> #addTranslatedList: instead (changing three parameters into one):
>
> search for:
> `@Expression labels: `#labels lines: `#lines selections: `#selections
>
> replace with:
> `@Expression addTranslatedList: `{:a | | labels lines selections list |
> labels := (a valueForPatternVariableNode: '`#labels') value findTokens:
> Character cr.
> lines := (a valueForPatternVariableNode: '`#lines') value.
> selections := (a valueForPatternVariableNode: '`#selections') value.
> list := labels with: selections collect: [ :l :s | { l. s. } ].
> list := Array streamContents: [ :strm | list withIndexDo: [ :l :i | strm
> nextPut: l.
> (lines includes: i) ifTrue: [ strm nextPut: '-' ]]].
> RBParser parseExpression: list storeString }
>
> Enjoy,
More information about the Squeak-dev
mailing list
|