On 2012-09-11, at 01:43, Chris Cunnington <[email protected]> wrote:

> On 12-09-10 7:34 PM, Andy Burnett wrote:
>> Hello,
>> 
>> Is there a method - or other mechanism - that would let me find all 
>> instances of 'foo' and replace them with 'bar' within an image? I imagine 
>> there must be, but I can't find it.
>> 
>> Cheers
>> Andy
>> 
>> 
>> _______________________________________________
>> Beginners mailing list
>> 
>> [email protected]
>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
> Try this: 
> 
> OrderedCollection allInstances size
> 
> Print that. That's the number of instances of OC in the image. Now try 
> 
> OrderedCollection allInstances 
> 
> or 
> 
> OrderedCollection allInstances first
> 
> And take a look at the living instances inside the image. That's how you find 
> instances. Replacing them is kind of a different issue. I'd say two things 
> about that. The first is you don't want to just replace instances in the 
> image. You need to be more specific of the context of your instances. Are 
> they in an OrderedCollection or an Array? If so, find that instance and 
> change them inside. 
> 
> The second thing is you wouldn't generally replace instances in the image. 
> Just wait and they'll be eaten by the garbage collector. 
> 
> So finding instances is not to hard. Use #allInstances. To replace them you 
> need to look not so much at the whole image but the application those 
> instances are in. Inside your app. 
> 
> Oh, yea. You can use OrderedCollection allIstances and both explore and 
> inspect. You can see inside the instances that way. (Explore and inspect are 
> one of the main menus.) 
> 
> Hope that helps, 
> Chris 

I thought Andy was talking about source code. 

Personally, if I have to rename a method, I search for all senders and fix them 
with copy&paste. Same for class renames, inst var renames, etc. There just are 
not that many occurrences, so fixing each one individually is quick, plus I get 
to verify that the change is indeed what I wanted.

There is a tool to automate a lot of this called the Refactoring Browser, which 
many developers like, but I don't even have it in my image.

- Bert -


_______________________________________________
Beginners mailing list
[email protected]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to