f



How to refactor a Symbol in Dolphin

In my application I'm using Symbols as placeholders for Strings to 
provide multi language support. To refactor the symbol names I wouuld 
like to click on my Symbol in the MethodWorkspace and start refactoring 
with an hit on F2. But the refactor dialog shows the active method name 
and not the symbol.

Is there an other way to refactor symbols.

At the moment I have to define a method with the same name as my Symbol 
saving it. Refactor the symbol method and deleting the method. Most 
times I like to refactor a bunch of symbols. So this way is very 
unconvinient.

Any suggestions appriciated.

thanks
cjb
0
Christoph
12/12/2009 10:35:49 AM
comp.lang.smalltalk.dolphin 3769 articles. 0 followers. Post Follow

6 Replies
318 Views

Similar Articles

[PageSpeed] 54

Hi!

Maybe you should use PoolDictionaries (and write keys) instead of
symbols. I don't say that PoolDictionaries are the best solution but
are comparable with your current implementation.

Another solution we have implemented is using Strings, but no as
placeholders. String was extended with #translated implementing the
translation logic for the current language of the user.
i.e.

'Helo' translated  -> If the user has english as language, #translated
answers 'Hello', but 'Hola' if the user is in spanish.
'I'm <1d> years old' translated expandMacrosWith: 20 (on my dreams) ->
'Tengo 20 a=F1os' if the user is in spanish

All the translations are mantained in a LookupTable that can be
exported in xml.

Additionally we mark all the translatable strings with the character @
as the first character so find all translatable strings
is as easy as "String allInstances select: [:each | each firstOrNil =3D=3D
$@]".
Using this technique you should remove @ as the first character in the
#translate implementation of String (If you mask @ with @ i.e.
'@@domain' you ends with '@domain' so there are no problems).

Cheers
Sebastian Calvo



On 12 dic, 07:35, "Christoph J. Bachinger" <bachinger.softw...@t-
online.de> wrote:
> In my application I'm using Symbols as placeholders for Strings to
> provide multi language support. To refactor the symbol names I wouuld
> like to click on my Symbol in the MethodWorkspace and start refactoring
> with an hit on F2. But the refactor dialog shows the active method name
> and not the symbol.
>
> Is there an other way to refactor symbols.
>
> At the moment I have to define a method with the same name as my Symbol
> saving it. Refactor the symbol method and deleting the method. Most
> times I like to refactor a bunch of symbols. So this way is very
> unconvinient.
>
> Any suggestions appriciated.
>
> thanks
> cjb

0
GallegO
12/12/2009 2:20:35 PM
Christoph J. Bachinger wrote:
> In my application I'm using Symbols as placeholders for Strings to
> provide multi language support. To refactor the symbol names I wouuld
> like to click on my Symbol in the MethodWorkspace and start refactoring
> with an hit on F2. But the refactor dialog shows the active method name
> and not the symbol.
> 
> Is there an other way to refactor symbols.
> 
> At the moment I have to define a method with the same name as my Symbol
> saving it. Refactor the symbol method and deleting the method. Most
> times I like to refactor a bunch of symbols. So this way is very
> unconvinient.
> 
> Any suggestions appriciated.

You can use the Code Rewriter if you want to rename the symbols. For
example, to rename #foo to #bar: select your packages, switch to the
code rewriter, enter #foo at the top, #bar at the bottom, and hit the
Replace button. This will open another window with all of the potential
changes that you can accept or reject.


John Brant
0
John
12/12/2009 3:11:16 PM
Hi John,

How to select the packages or only one Package. Normaly im using the 
Sytembrowser to code for my application. So my Package is already 
selected. If I switch to the Code Rewriter I can change the #foo to #bar
and hit the Replace button. But the change is only in this method and 
not in the Package or Class.

cjb

John Brant schrieb:
> Christoph J. Bachinger wrote:
>> In my application I'm using Symbols as placeholders for Strings to
>> provide multi language support. To refactor the symbol names I wouuld
>> like to click on my Symbol in the MethodWorkspace and start refactoring
>> with an hit on F2. But the refactor dialog shows the active method name
>> and not the symbol.
>>
>> Is there an other way to refactor symbols.
>>
>> At the moment I have to define a method with the same name as my Symbol
>> saving it. Refactor the symbol method and deleting the method. Most
>> times I like to refactor a bunch of symbols. So this way is very
>> unconvinient.
>>
>> Any suggestions appriciated.
> 
> You can use the Code Rewriter if you want to rename the symbols. For
> example, to rename #foo to #bar: select your packages, switch to the
> code rewriter, enter #foo at the top, #bar at the bottom, and hit the
> Replace button. This will open another window with all of the potential
> changes that you can accept or reject.
> 
> 
> John Brant
0
Christoph
12/13/2009 4:49:34 PM
Hi GallegO

> Maybe you should use PoolDictionaries (and write keys) instead of
> symbols. I don't say that PoolDictionaries are the best solution but
> are comparable with your current implementation.

The symbols are the keys in the dictionary of the langugage instance.

> 
> Another solution we have implemented is using Strings, but no as
> placeholders. String was extended with #translated implementing the
> translation logic for the current language of the user.
> i.e.
> 
> 'Helo' translated  -> If the user has english as language, #translated
> answers 'Hello', but 'Hola' if the user is in spanish.
> 'I'm <1d> years old' translated expandMacrosWith: 20 (on my dreams) ->
> 'Tengo 20 a´┐Żos' if the user is in spanish
> 
> All the translations are mantained in a LookupTable that can be
> exported in xml.
> 
> Additionally we mark all the translatable strings with the character @
> as the first character so find all translatable strings
> is as easy as "String allInstances select: [:each | each firstOrNil ==
> $@]".
> Using this technique you should remove @ as the first character in the
> #translate implementation of String (If you mask @ with @ i.e.
> '@@domain' you ends with '@domain' so there are no problems).

The idea is not bad. But I don't like to change the horse at the end of 
a development.

Thanks
cbj

> 
> Cheers
> Sebastian Calvo
> 
> 
> 
> On 12 dic, 07:35, "Christoph J. Bachinger" <bachinger.softw...@t-
> online.de> wrote:
>> In my application I'm using Symbols as placeholders for Strings to
>> provide multi language support. To refactor the symbol names I wouuld
>> like to click on my Symbol in the MethodWorkspace and start refactoring
>> with an hit on F2. But the refactor dialog shows the active method name
>> and not the symbol.
>>
>> Is there an other way to refactor symbols.
>>
>> At the moment I have to define a method with the same name as my Symbol
>> saving it. Refactor the symbol method and deleting the method. Most
>> times I like to refactor a bunch of symbols. So this way is very
>> unconvinient.
>>
>> Any suggestions appriciated.
>>
>> thanks
>> cjb
> 
0
Christoph
12/13/2009 4:58:58 PM
Christoph J. Bachinger wrote:

> How to select the packages or only one Package. Normaly im using the
> Sytembrowser to code for my application. So my Package is already
> selected. If I switch to the Code Rewriter I can change the #foo to #bar
> and hit the Replace button. But the change is only in this method and
> not in the Package or Class.

You'll need to deselect your class/method. Otherwise, it will run on
only the class/method that you have selected.


John Brant
0
John
12/14/2009 1:16:35 PM
John Brant schrieb:
> Christoph J. Bachinger wrote:
> 
>> How to select the packages or only one Package. Normaly im using the
>> Sytembrowser to code for my application. So my Package is already
>> selected. If I switch to the Code Rewriter I can change the #foo to #bar
>> and hit the Replace button. But the change is only in this method and
>> not in the Package or Class.
> 
> You'll need to deselect your class/method. Otherwise, it will run on
> only the class/method that you have selected.

Sorry to be so annoying to you, but I see only one method in the list 
while if I do a shift F12 I see much more senders of my Symbol but this 
is in a Methodbrowser and not in the code rewriter methodlist.

Deselection the only message highlights all menu entries without "Accept 
all changes". Selecting it does only a change in the one method listed.

cjb
0
Christoph
12/14/2009 6:18:23 PM
Reply: