[squeak-dev] Please try out | Inspector Refactoring =)

Marcel Taeumel marcel.taeumel at hpi.de
Wed Apr 15 09:37:10 UTC 2020


Hi all! :-)

Christoph (ct) and I did finally finish reviewing his propsed changes and refactorings to our Inspector framework. 

Please find attached a changeset to try out those updates during the next 1-2 days. Of course, we will continue working on related issues even after merging it into Trunk. You should not expect any major UX changes. ;-)

We have now more than 200 tests to check all of the specialized inspector flavors.

First, here is some history and context on this proposal:
- http://forum.world.st/The-Inbox-Tools-ct-900-mcz-td5104860.html [http://forum.world.st/The-Inbox-Tools-ct-900-mcz-td5104860.html]
- http://forum.world.st/Refactoring-Inspectors-td5111788.html [http://forum.world.st/Refactoring-Inspectors-td5111788.html]

Besides some structural clean-up, which you can browse through the message categories of the Inspector class, there are a few new things, Christoph wanted to push out to the Squeak community to enjoy:


1. More Clear Extension Points

Inspectors show fields that expose certain characteristics of the object-under-inspection. InspectorField holds the specification for each field. Starting point is Inspector >> #streamFieldsOn:. A simple example on how to build a field is in #fieldAllInstVars.

Take a look at how MorphInspector, CompiledCodeInspector, BitsetInspector refine the basic Inspector code. Also explore how CollectionInspector adds features to browse and modify collection elements.


2. Custom Fields

You can now add custom fields during your inspector session. Invoke the field-list menu and choose "add field..." at the bottom.

In its current form, simple expressions such as "self color darker" can be used to specify a field's value. If you want to also let the user change a field's value, simple blocks such as "[:newValue | self color: newValue]" can be added, too.

Modifications through the value pane should work for all fields. Just type a valid Smalltalk expression and accept the changes through the menu or by pressing [cmd]+[s].


3. "Copy expression"

It is now possible to retrieve a piece of Smalltalk code for each field that tells you how to retrieve that field's value to be used in you own code.

While fields are usually specified with blocks in a generic form like this ....

...
valueGetter: [:object | object instVarNamed: name];
...

The "copy expression" feature, which you can access from the field-list menu, gives you a more precise answer:

self instVarNamed: 'fullBounds'

Of course, you can then follow up to figure out whether there is an accessor available. But in case you wondered where the contents for "all inst vars" is coming from, "copy expression" gives you this:

self longPrintString

Who of you did already know that? :-) Note that there are still some quirks here and there. We need volunteers to improve it further. ;-) Take a look at InspectorField class >> #generateExpressionFrom:argumentNames:. Well, it is basically an "inline block/method" refactoring where the temps are hopefully literals to be replaced inline. Maybe this can be part of FullBlockClosure in the future. 


4. BasicInspector

It is now possible to safely inspect subclasses of ProtoObject, such as proxies, in the BasicInspector. In an inspector's field-list menu, just click "basic inspect" and compare the differences. The basic inspector uses the VM's mirror primitives, which you can find in Context under "mirror primitives".

This also meant changing some "anObject basicInspect" to "ToolSet basicInspect: anObject" to not send too many messages to the object-under-inspection.

---

As mentioned above, please try out the attached changeset during the next 1-2 days. On file-in, that changeset will close all existing inspectors on re-open them again after loading the code. So please take care of any important information stored in an inspector's code-expression field at the bottom.

Best,
Christoph (ct) & Marcel (mt)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200415/94bf54f2/attachment-0001.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: inspector-refactoring.7.cs
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200415/94bf54f2/attachment-0001.ksh>


More information about the Squeak-dev mailing list