Is there an easy way in Squeak to override a method?
I have created a subclass of a class, and am viewing my subclass in a hierarchy browser. I have clicked on the superclass in the browser and am browsing methods to see what I need to override.
Having discovered a method that I want to override - I was hoping I could right click on that method and select Refactor|Override - but its not there (it is in Dolphin). Failing this I tried drag and drop - but that seems to just move the method (I held the Control key while dragging but I guess thats a Dolphin and a windows thing).
Is there some way to easily and quickly do this without having to cut and paste?
Tim
Hello Tim,
TM> Is there an easy way in Squeak to override a method?
if I don't misunderstand you, you just redefine it in your subclass?
TM> (it is in Dolphin). Failing this I tried drag and drop - but that seems to TM> just move the method (I held the Control key while dragging but I guess thats TM> a Dolphin and a windows thing).
RB uses the shift key to copy a method into another class instead of moving it. Other refactorings are push up, push down moving the method down to every subclass.
Hi Herbert,
if I don't misunderstand you, you just redefine it in your subclass?
Yes but its a nuisance to copy the method signature, click on the class below, click on a method (or the as yes undefined category), and then paste the signature and then enter by override.
I was hoping that there was something like in dolphin - browse my subclass but enable show inherited methods - select the inehrited method, right click and pick Refactoring | Override - this then does then creates me a template that overrides.
RB uses the shift key to copy a method into another class instead of moving it. Other refactorings are push up, push down moving the method down to every subclass.
The shift key wasn't one I thought of - that is a reasonable workaround if a bit mousy. Maybe if I get better at Squeak I will work out how to add a keyboard shortcut.
Thanks for the tips.
Tim
Tim M ha scritto:
Hi Herbert,
if I don't misunderstand you, you just redefine it in your subclass?
Yes but its a nuisance to copy the method signature, click on the class below, click on a method (or the as yes undefined category), and then paste the signature and then enter by override.
I was hoping that there was something like in dolphin - browse my subclass but enable show inherited methods - select the inehrited method, right click and pick Refactoring | Override - this then does then creates me a template that overrides.
Using eCompletion, if you know which method to override you can simply start typing the first few letters of the selector, then press CTRL+space and select the method from the popup window.
Giovanni
On Sat, May 17, 2008 at 12:26:50PM +0000, Tim M wrote:
Hi Herbert,
if I don't misunderstand you, you just redefine it in your subclass?
Yes but its a nuisance to copy the method signature, click on the class below, click on a method (or the as yes undefined category), and then paste the signature and then enter by override.
I was hoping that there was something like in dolphin - browse my subclass but enable show inherited methods - select the inehrited method, right click and pick Refactoring | Override - this then does then creates me a template that overrides.
to show a class with some of it's inherited methods, use the protocol browser (select a class, and alt-P). When you save a method in the protocol browser, it asks you which class to save it under, if I remember correctly.
On May 17, 2008, at 5:26 AM, Tim M wrote:
...Yes but its a nuisance to copy the method signature, click on the class below, click on a method (or the as yes undefined category), and then paste the signature and then enter by override.
I'm surprised no one has mentioned the "copy up or copy down..." feature, available in the "more..." branch of the selector-list menu of any browser or message-list of most versions of Squeak since March 2001.
-- sw
beginners@lists.squeakfoundation.org