Inspector "Copy name"

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

Inspector "Copy name"

Christoph Thiede

Hi all,


as you might know, I'm currently refactoring the inspectors (@Chris - the idea with InspectorFieldSpec was fabulous, it improves the overall design a lot!). One short question regarding the menu action "Copy name":




As you can see in the screenshot, the current implementation has a weird edge case:


sel := ...

(self selection isKindOf: Collection)

ifTrue: [sel := '(' , sel , ' at: 1)'].
^ sel


I cannot see any sense in it. In my eyes, it's just confusing. Can I remove that edge case?


Best,

Christoph



Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: Inspector "Copy name"

marcel.taeumel
Looks like that #copyName works similar to #storeOn:? There are 10 implementors of #copyName to learn from.

I would rather not remove that feature. Instead, extract it to CollectionInspector to avoid that #isKindOf: check.

Best,
Marcel

Am 16.12.2019 19:55:33 schrieb Thiede, Christoph <[hidden email]>:

Hi all,


as you might know, I'm currently refactoring the inspectors (@Chris - the idea with InspectorFieldSpec was fabulous, it improves the overall design a lot!). One short question regarding the menu action "Copy name":




As you can see in the screenshot, the current implementation has a weird edge case:


sel := ...

(self selection isKindOf: Collection)

ifTrue: [sel := '(' , sel , ' at: 1)'].
^ sel


I cannot see any sense in it. In my eyes, it's just confusing. Can I remove that edge case?


Best,

Christoph



Reply | Threaded
Open this post in threaded view
|

Re: Inspector "Copy name"

Christoph Thiede

Hi Marcel,


I'm not sure whether I understand you correctly. The current documentation comment of Inspector >> #copyName says:


"Copy the name of the current variable, so the user can paste it into the window below and work with is. If collection, do (xxx at: 1)."
(emphasis mine)


I like the feature and would never ask to remove it - but my question is, why do we have this edge case?

From the screenshot below, if you store 42 in the current selected field, copyName will give you: (self basicAt: 1).

But if you replace its content with '42' (a string) instead, copyName will give you: ((self basicAt: 2) at: 1).


I can't find any #copyName implementation that handles this edge case outside of the inspectors. What is this edge case for? How helps it "store" the value?


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Dienstag, 17. Dezember 2019 12:14:39
An: John Pfersich via Squeak-dev
Betreff: Re: [squeak-dev] Inspector "Copy name"
 
Looks like that #copyName works similar to #storeOn:? There are 10 implementors of #copyName to learn from.

I would rather not remove that feature. Instead, extract it to CollectionInspector to avoid that #isKindOf: check.

Best,
Marcel

Am 16.12.2019 19:55:33 schrieb Thiede, Christoph <[hidden email]>:

Hi all,


as you might know, I'm currently refactoring the inspectors (@Chris - the idea with InspectorFieldSpec was fabulous, it improves the overall design a lot!). One short question regarding the menu action "Copy name":




As you can see in the screenshot, the current implementation has a weird edge case:


sel := ...

(self selection isKindOf: Collection)

ifTrue: [sel := '(' , sel , ' at: 1)'].
^ sel


I cannot see any sense in it. In my eyes, it's just confusing. Can I remove that edge case?


Best,

Christoph



Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: Inspector "Copy name"

K K Subbu
In reply to this post by marcel.taeumel
Marcel,

When I tried

Class allSubInstances inspect. "try copyname on index 2 in the inspector"

I got a subscript out of bounds error in line 10. This happens because:

aClass isVariable. "false"

aClass is OrderedCollection, so why would this check fail?

Also, copyName just copies the name referencing an instance variable to
clipboard. Why check if this is scalar or a collection? E.g. If I select
"submorphs" and do a copyName, I expect to be able to paste "submorphs"
not "submorphs at: 1".

Regards .. Subbu

On 17/12/19 4:44 PM, Marcel Taeumel wrote:

> Looks like that #copyName works similar to #storeOn:? There are 10
> implementors of #copyName to learn from.
>
> I would rather not remove that feature. Instead, extract it to
> CollectionInspector to avoid that #isKindOf: check.
>
> Best,
> Marcel
>>
>> Am 16.12.2019 19:55:33 schrieb Thiede, Christoph
>> <[hidden email]>:
>>
>> Hi all,
>>
>>
>> as you might know, I'm currently refactoring the inspectors (@Chris -
>> the idea with InspectorFieldSpec was fabulous, it improves the overall
>> design a lot!). One short question regarding the menu action "Copy name":
>>
>>
>>
>>
>> As you can see in the screenshot, the current implementation has a
>> weird edge case:
>>
>>
>> sel := ...
>>
>> *(self selection isKindOf: Collection)
>> *
>>
>> *ifTrue: [sel := '(' , sel , ' at: 1)'].*
>> ^ sel
>>
>>
>> I cannot see any sense in it. In my eyes, it's just confusing. Can I
>> remove that edge case?
>>
>>
>> Best,
>>
>> Christoph
>>
>
>