auto format methods

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

auto format methods

TedVanGaalen
Pharo 1.4 Nautilus
can't find source code auto format option.
also not in the settings browser
but maybe I haven't been looking good enough..
anyone?
thanks
Ted
Reply | Threaded
Open this post in threaded view
|

Re: auto format methods

Bernat Romagosa
It's on schedule, check http://code.google.com/p/pharo/issues/detail?id=5664&q=nautilus&colspec=ID%20Type%20Status%20Summary%20Milestone%20Difficulty

:)

2012/5/18 Ted F.A. van Gaalen <[hidden email]>
Pharo 1.4 Nautilus
can't find source code auto format option.
also not in the settings browser
but maybe I haven't been looking good enough..
anyone?
thanks
Ted



--
Bernat Romagosa.
Reply | Threaded
Open this post in threaded view
|

Re: auto format methods

Goubier Thierry
In reply to this post by TedVanGaalen
Le 18/05/2012 01:01, Ted F.A. van Gaalen a écrit :
> Pharo 1.4 Nautilus
> can't find source code auto format option.
> also not in the settings browser
> but maybe I haven't been looking good enough..
> anyone?
> thanks
> Ted

I added it myself because I like that functionality. But I still loose
the Cmd+r shortcut, since it's used for something else.

in NautilusRefactoring class >> sourceCodeRefactoringMenu:

(aBuilder item: #'Format')
                        action: [ | source tree formatted morph |
                                morph := target sourceTextArea.
                                source  := morph text asString.
                                tree := RBParser
                                        parseMethod: source
                                        onError: [ :msg :pos | ^ target ].
                                formatted := tree formattedCode.
                                formatted = source
                                        ifTrue: [ ^ self].
                                morph editString: formatted; hasUnacceptedEdits: true
                                ];
                        parent: #'Source code refactoring';
                        order: 50.

Thierry
--
Thierry Goubier
CEA list
Laboratoire des Fondations des Systèmes Temps Réel Embarqués
91191 Gif sur Yvette Cedex
France
Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95

Reply | Threaded
Open this post in threaded view
|

Re: auto format methods

Stéphane Ducasse
cool we should add it :)

On May 21, 2012, at 11:09 AM, Goubier Thierry wrote:

> Le 18/05/2012 01:01, Ted F.A. van Gaalen a écrit :
>> Pharo 1.4 Nautilus
>> can't find source code auto format option.
>> also not in the settings browser
>> but maybe I haven't been looking good enough..
>> anyone?
>> thanks
>> Ted
>
> I added it myself because I like that functionality. But I still loose the Cmd+r shortcut, since it's used for something else.
>
> in NautilusRefactoring class >> sourceCodeRefactoringMenu:
>
> (aBuilder item: #'Format')
> action: [ | source tree formatted morph |
> morph := target sourceTextArea.
> source  := morph text asString.
> tree := RBParser
> parseMethod: source
> onError: [ :msg :pos | ^ target ].
> formatted := tree formattedCode.
> formatted = source
> ifTrue: [ ^ self].
> morph editString: formatted; hasUnacceptedEdits: true
> ];
> parent: #'Source code refactoring';
> order: 50.
>
> Thierry
> --
> Thierry Goubier
> CEA list
> Laboratoire des Fondations des Systèmes Temps Réel Embarqués
> 91191 Gif sur Yvette Cedex
> France
> Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95
>


Reply | Threaded
Open this post in threaded view
|

Re: auto format methods

Goubier Thierry
Le 21/05/2012 14:42, Stéphane Ducasse a écrit :
> cool we should add it :)

Beware: I think I left a mistake in there, here :

 >> formatted = source
 >> ifTrue: [ ^ self].

Probably fails since can't return from block ?

And I believe it needs two suggestions :
* A shortcut (because I really liked doing Cmd+r Cmd+s in Pharo 1.3, but
Cmd+r does sometimes something else now, such as rename method)
* And maybe a better place (it appears in the refactoring submenu, not
the main edit menu).

Thierry

> On May 21, 2012, at 11:09 AM, Goubier Thierry wrote:
>
>> Le 18/05/2012 01:01, Ted F.A. van Gaalen a écrit :
>>> Pharo 1.4 Nautilus
>>> can't find source code auto format option.
>>> also not in the settings browser
>>> but maybe I haven't been looking good enough..
>>> anyone?
>>> thanks
>>> Ted
>>
>> I added it myself because I like that functionality. But I still loose the Cmd+r shortcut, since it's used for something else.
>>
>> in NautilusRefactoring class>>  sourceCodeRefactoringMenu:
>>
>> (aBuilder item: #'Format')
>> action: [ | source tree formatted morph |
>> morph := target sourceTextArea.
>> source  := morph text asString.
>> tree := RBParser
>> parseMethod: source
>> onError: [ :msg :pos | ^ target ].
>> formatted := tree formattedCode.
>> formatted = source
>> ifTrue: [ ^ self].
>> morph editString: formatted; hasUnacceptedEdits: true
>> ];
>> parent: #'Source code refactoring';
>> order: 50.
>>
>> Thierry
>> --
>> Thierry Goubier
>> CEA list
>> Laboratoire des Fondations des Systèmes Temps Réel Embarqués
>> 91191 Gif sur Yvette Cedex
>> France
>> Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95
>>
>
>
>
>


--
Thierry Goubier
CEA list
Laboratoire des Fondations des Systèmes Temps Réel Embarqués
91191 Gif sur Yvette Cedex
France
Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95

Reply | Threaded
Open this post in threaded view
|

Re: auto format methods

TedVanGaalen
C'est merveilleux, merci Thierry!

plugged it in,
At first sight, it works OK in
Pharo1.4  Latest update #14437

indeed, a bit nested in the menutree

Why can't I return ^  from a block
it just did, e.g. does it leave problems e.g. uncollectable garbage?

Thanks
Ted
(floating (sinking?) in unemployment, web design, php (jikes!) typo3,  Smalltalk Seaside, any IT, nevertheless having fun)

ted van gaalen it services

www.tedvg.com

Ted F.A. van Gaalen
Hauptstr.19/3
D-88636 Illmensee
Germany
T: +49 7558 92 17 840
M: +49 151 587 86 247


On 21.05.2012 14:50, Goubier Thierry wrote:
Le 21/05/2012 14:42, Stéphane Ducasse a écrit :
cool we should add it :)

Beware: I think I left a mistake in there, here :

>>                 formatted = source
>>                     ifTrue: [ ^ self].

Probably fails since can't return from block ?

And I believe it needs two suggestions :
* A shortcut (because I really liked doing Cmd+r Cmd+s in Pharo 1.3, but Cmd+r does sometimes something else now, such as rename method)
* And maybe a better place (it appears in the refactoring submenu, not the main edit menu).

Thierry

On May 21, 2012, at 11:09 AM, Goubier Thierry wrote:

Le 18/05/2012 01:01, Ted F.A. van Gaalen a écrit :
Pharo 1.4 Nautilus
can't find source code auto format option.
also not in the settings browser
but maybe I haven't been looking good enough..
anyone?
thanks
Ted

I added it myself because I like that functionality. But I still loose the Cmd+r shortcut, since it's used for something else.

in NautilusRefactoring class>>  sourceCodeRefactoringMenu:

(aBuilder item: #'Format')
            action: [ | source tree formatted morph |
                morph := target sourceTextArea.
                source  := morph text asString.
                tree := RBParser
                    parseMethod: source
                    onError: [ :msg :pos | ^ target ].
                formatted := tree formattedCode.
                formatted = source
                    ifTrue: [ ^ self].
                morph editString: formatted; hasUnacceptedEdits: true
                ];
            parent: #'Source code refactoring';
            order: 50.

Thierry
--
Thierry Goubier
CEA list
Laboratoire des Fondations des Systèmes Temps Réel Embarqués
91191 Gif sur Yvette Cedex
France
Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95







Reply | Threaded
Open this post in threaded view
|

Re: auto format methods

TedVanGaalen
...
it does (of course)
only get the BlockCannotReturn error
when attempting to re-format
unchanged code

removed the return from

(aBuilder item: #'Format')
            action: [ | source tree formatted morph |
                morph := target sourceTextArea.
                source  := morph text asString.
                tree := RBParser
                    parseMethod: source
                    onError: [ :msg :pos | ^ target ].
                formatted := tree formattedCode.
                formatted = source
                 ifFalse:
                [  
                     morph editString: formatted;
                     hasUnacceptedEdits: true]         "<-= here"
                ];
            parent: #'Source code refactoring';

works ok now,
however not really tested..

ted

On 21.05.2012 16:11, Ted F.A. van Gaalen wrote:
C'est merveilleux, merci Thierry!

plugged it in,
At first sight, it works OK in
Pharo1.4  Latest update #14437

indeed, a bit nested in the menutree

Why can't I return ^  from a block
it just did, e.g. does it leave problems e.g. uncollectable garbage?

Thanks
Ted
(floating (sinking?) in unemployment, web design, php (jikes!) typo3,  Smalltalk Seaside, any IT, nevertheless having fun)

ted van gaalen it services

www.tedvg.com

Ted F.A. van Gaalen
Hauptstr.19/3
D-88636 Illmensee
Germany
T: +49 7558 92 17 840
M: +49 151 587 86 247


On 21.05.2012 14:50, Goubier Thierry wrote:
Le 21/05/2012 14:42, Stéphane Ducasse a écrit :
cool we should add it :)

Beware: I think I left a mistake in there, here :

>>                 formatted = source
>>                     ifTrue: [ ^ self].

Probably fails since can't return from block ?

And I believe it needs two suggestions :
* A shortcut (because I really liked doing Cmd+r Cmd+s in Pharo 1.3, but Cmd+r does sometimes something else now, such as rename method)
* And maybe a better place (it appears in the refactoring submenu, not the main edit menu).

Thierry

On May 21, 2012, at 11:09 AM, Goubier Thierry wrote:

Le 18/05/2012 01:01, Ted F.A. van Gaalen a écrit :
Pharo 1.4 Nautilus
can't find source code auto format option.
also not in the settings browser
but maybe I haven't been looking good enough..
anyone?
thanks
Ted

I added it myself because I like that functionality. But I still loose the Cmd+r shortcut, since it's used for something else.

in NautilusRefactoring class>>  sourceCodeRefactoringMenu:

(aBuilder item: #'Format')
            action: [ | source tree formatted morph |
                morph := target sourceTextArea.
                source  := morph text asString.
                tree := RBParser
                    parseMethod: source
                    onError: [ :msg :pos | ^ target ].
                formatted := tree formattedCode.
                formatted = source
                    ifTrue: [ ^ self].
                morph editString: formatted; hasUnacceptedEdits: true
                ];
            parent: #'Source code refactoring';
            order: 50.

Thierry
--
Thierry Goubier
CEA list
Laboratoire des Fondations des Systèmes Temps Réel Embarqués
91191 Gif sur Yvette Cedex
France
Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95







Reply | Threaded
Open this post in threaded view
|

Re: auto format methods

Goubier Thierry
Le 21/05/2012 16:34, Ted F.A. van Gaalen a écrit :
> ...
> it does (of course)
> only get the BlockCannotReturn error
> when attempting to re-format
> unchanged code

Yes, it was that.

Now, no suggestions about putting it somewhere else in the menu ? I'm
not yet too familiar with the GUI architecture of Pharo to find of a
nice way to put it in the top-level menu and link it to a keyboard shortcut.

Thierry

> removed the return from
>
> (aBuilder item: #'Format')
> action: [ | source tree formatted morph |
> morph := target sourceTextArea.
> source := morph text asString.
> tree := RBParser
> parseMethod: source
> onError: [ :msg :pos | ^ target ].
> formatted := tree formattedCode.
> formatted = source
> ifFalse:
> [
> morph editString: formatted;
> hasUnacceptedEdits: true] "<-= here"
> ];
> parent: #'Source code refactoring';
>
> works ok now,
> however not really tested..
>
> ted
>
> On 21.05.2012 16:11, Ted F.A. van Gaalen wrote:
>> C'est merveilleux, merci Thierry!
>>
>> plugged it in,
>> At first sight, it works OK in
>> Pharo1.4 Latest update #14437
>>
>> indeed, a bit nested in the menutree
>>
>> Why can't I return ^ from a block
>> it just did, e.g. does it leave problems e.g. uncollectable garbage?
>>
>> Thanks
>> Ted
>> (floating (sinking?) in unemployment, web design, php (jikes!) typo3,
>> Smalltalk Seaside, any IT, nevertheless having fun)
>>
>> ted van gaalen *it* services
>>
>> www.tedvg.com <http://www.tedvg.com/>
>>
>> Ted F.A. van Gaalen
>> Hauptstr.19/3
>> D-88636 Illmensee
>> Germany
>> T: +49 7558 92 17 840
>> M: +49 151 587 86 247
>>
>>
>> On 21.05.2012 14:50, Goubier Thierry wrote:
>>> Le 21/05/2012 14:42, Stéphane Ducasse a écrit :
>>>> cool we should add it :)
>>>
>>> Beware: I think I left a mistake in there, here :
>>>
>>> >> formatted = source
>>> >> ifTrue: [ ^ self].
>>>
>>> Probably fails since can't return from block ?
>>>
>>> And I believe it needs two suggestions :
>>> * A shortcut (because I really liked doing Cmd+r Cmd+s in Pharo 1.3,
>>> but Cmd+r does sometimes something else now, such as rename method)
>>> * And maybe a better place (it appears in the refactoring submenu,
>>> not the main edit menu).
>>>
>>> Thierry
>>>
>>>> On May 21, 2012, at 11:09 AM, Goubier Thierry wrote:
>>>>
>>>>> Le 18/05/2012 01:01, Ted F.A. van Gaalen a écrit :
>>>>>> Pharo 1.4 Nautilus
>>>>>> can't find source code auto format option.
>>>>>> also not in the settings browser
>>>>>> but maybe I haven't been looking good enough..
>>>>>> anyone?
>>>>>> thanks
>>>>>> Ted
>>>>>
>>>>> I added it myself because I like that functionality. But I still
>>>>> loose the Cmd+r shortcut, since it's used for something else.
>>>>>
>>>>> in NautilusRefactoring class>> sourceCodeRefactoringMenu:
>>>>>
>>>>> (aBuilder item: #'Format')
>>>>> action: [ | source tree formatted morph |
>>>>> morph := target sourceTextArea.
>>>>> source := morph text asString.
>>>>> tree := RBParser
>>>>> parseMethod: source
>>>>> onError: [ :msg :pos | ^ target ].
>>>>> formatted := tree formattedCode.
>>>>> formatted = source
>>>>> ifTrue: [ ^ self].
>>>>> morph editString: formatted; hasUnacceptedEdits: true
>>>>> ];
>>>>> parent: #'Source code refactoring';
>>>>> order: 50.
>>>>>
>>>>> Thierry
>>>>> --
>>>>> Thierry Goubier
>>>>> CEA list
>>>>> Laboratoire des Fondations des Systèmes Temps Réel Embarqués
>>>>> 91191 Gif sur Yvette Cedex
>>>>> France
>>>>> Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>


--
Thierry Goubier
CEA list
Laboratoire des Fondations des Systèmes Temps Réel Embarqués
91191 Gif sur Yvette Cedex
France
Phone/Fax: +33 (0) 1 69 08 32 92 / 83 95

Reply | Threaded
Open this post in threaded view
|

Nautilus subclassing

djuber
I ran into a surprise today, and I'm not sure if it's by design or
accident that I saw it.

In Pharo-2.0, if I'm in Nautilus looking at class side definitions, and
I click on the class to Refactoring -> Class Refactoring -> Generate
Subclass..., I find that a subclass is attempting to be created on
MetaObject, which fails due to not understanding the #category message.
This is not the same behavior as happens when looking at instance side,
which created a named subclass of the class.

If this is wrong behavior, I will open an issue. If this is something
that surprised me because I'm new, I'd be happy to hear a rationale, and
I will open an issue, since the option fails, it should either not be
present, or not send category.

I guess I'd just like to know what the expected behavior is when
creating a subclass and viewing class side in the browser.

Thanks,

Daniel Uber

Reply | Threaded
Open this post in threaded view
|

Re: Nautilus subclassing

djuber
my apologies, this should have had its own thread.

Dan Uber
Reply | Threaded
Open this post in threaded view
|

Re: Nautilus subclassing

Benjamin Van Ryseghem (Pharo)
Basically, I think this is a mistake I made :)

It should always use the nonMetaClass side of the current selectedClass :)


Thank you for feedback :)
Could you simply open a bug entry, to be sure I do not forget about it ? :)

Thanks in advance,

Ben

On May 22, 2012, at 4:40 PM, djuber wrote:

> my apologies, this should have had its own thread.
>
> Dan Uber
>
> --
> View this message in context: http://forum.world.st/auto-format-methods-tp4630741p4631398.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: Nautilus subclassing

djuber
Opened issue 5954 for this.

Thanks,

Dan

On 05/22/2012 10:10 AM, Benjamin wrote:

> Basically, I think this is a mistake I made :)
>
> It should always use the nonMetaClass side of the current selectedClass :)
>
>
> Thank you for feedback :)
> Could you simply open a bug entry, to be sure I do not forget about it ? :)
>
> Thanks in advance,
>
> Ben
>
> On May 22, 2012, at 4:40 PM, djuber wrote:
>
>> my apologies, this should have had its own thread.
>>
>> Dan Uber
>>
>> --
>> View this message in context: http://forum.world.st/auto-format-methods-tp4630741p4631398.html
>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Nautilus subclassing

djuber
In reply to this post by Benjamin Van Ryseghem (Pharo)

I added a new comment to Issue 5954 regarding Nautilus and groups. I'm
having an issue adding any package containing class side extension
methods to a group. If this should be a separate issue please let me
know and I will open one. I think it's similar enough to clump together
with the original problem.

Dan Uber

On 05/22/2012 10:10 AM, Benjamin wrote:

> Basically, I think this is a mistake I made :)
>
> It should always use the nonMetaClass side of the current selectedClass :)
>
>
> Thank you for feedback :)
> Could you simply open a bug entry, to be sure I do not forget about it ? :)
>
> Thanks in advance,
>
> Ben
>
> On May 22, 2012, at 4:40 PM, djuber wrote:
>
>> my apologies, this should have had its own thread.
>>
>> Dan Uber
>>
>> --
>> View this message in context: http://forum.world.st/auto-format-methods-tp4630741p4631398.html
>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Nautilus subclassing

Stéphane Ducasse
Thanks dan!

Stef

>
> I added a new comment to Issue 5954 regarding Nautilus and groups. I'm having an issue adding any package containing class side extension methods to a group. If this should be a separate issue please let me know and I will open one. I think it's similar enough to clump together with the original problem.
>
> Dan Uber
>
> On 05/22/2012 10:10 AM, Benjamin wrote:
>> Basically, I think this is a mistake I made :)
>>
>> It should always use the nonMetaClass side of the current selectedClass :)
>>
>>
>> Thank you for feedback :)
>> Could you simply open a bug entry, to be sure I do not forget about it ? :)
>>
>> Thanks in advance,
>>
>> Ben
>>
>> On May 22, 2012, at 4:40 PM, djuber wrote:
>>
>>> my apologies, this should have had its own thread.
>>>
>>> Dan Uber
>>>
>>> --
>>> View this message in context: http://forum.world.st/auto-format-methods-tp4630741p4631398.html
>>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>>
>>
>
>