Refactoring Browser
For the latest information on the Refactoring Browser see the HyperNews page.
The Refactoring Browser is an advanced browser for VisualWorks,
VisualWorks/ENVY, and IBM Smalltalk. It includes all the features of the
standard browsers plus several enhancements.
Some of its enhancements are:
- Buffers:
You can edit many methods at the same time without opening other browsers. For example, while you are editing one method, you can switch to a new buffer to lookup some value in another method, and then return back to your edited method without opening a new browser.
|
- Drag & drop:
You can drag & drop methods on classes or protocols; protocols on other classes or on protocols; classes on other categories; and categories on other categories.
|

|
- Hierarchy:
You can easily switch between a hierarchy view and the normal category view without spawning a hierarchy view window. This picture shows the hierarchy view on the VisualLauncher class. Also, it shows a resource viewer displaying an icon.
|
|
- Menus:
The browser has window menus, so you can use the short-cut keys for selecting items from the menu and rely less on the mouse.
|
- Multi-window:
You can have many different code tools in different windows with only one navigator controlling them. In this mode, only the top most code tool will be updated when you change the navigators selection. If you want to use the multi-window browser, see the customization section below.
|

|
- Old methods:
No more accidentally accepting changed methods. Whenever you change a method in one window, all other browsers viewing the methods will turn their code tools red until you update their code or accept the method. If you do not like the color selection, you can change it in BrowserCodeTool>>modifiedTextColor .
|
- Refactorings: Automatically perform some behavior preserving transformations such as abstracting references to an instance variable. Many of the refactorings are from Bill Opdyke's thesis.
|
- Resource viewers:
View resource methods in their more natural look instead of text. For example, a menu resource method appears as menu, not as text, although you can switch to a textual view if you want. This picture shows a canvas viewer viewing the ClassNavigator>windowSpec method.
|

|
- Rewrite tool:
Specify new rules to make source to source transformations. For example, you can create a rule to automatically convert uses of "aCollection size == 0" to be "aCollection isEmpty". Documentation for the rewrite tool can be found on this page.
|
The
icons signify that the
feature is not implemented for IBM Smalltalk.
To install the Refactoring Browser, you will need to download either the
compressed tar file or all the .st files in this
directory. If you are installing the browser under an ENVY environment,
then you just need the
ENVY-Browser.zip file. This file contains both the VisualWorks and the VisualAge versions.
To install the browser in an ENVY environment, you need to decompress the
ENVY-Browser.zip file to create the Browser.dat file. Once you have done this,
you'll first import the "Refactoring Browser" configuration map for the
browser into ENVY and then load the config map for the browser.
If you are using plain VisualWorks, then there are two ways to install the Refactoring Browser. You can either file-in the install.st file or file-in the files by hand. The install.st file tries to analyze your system to see what files are needed and should work for most installations. If you wish to install the browser manually, you'll need to file-in these files:
- Uninstall-old.st
- File-in this file if you have installed a previous version of the Refactoring Browser. Since the new version has refactored many classes significantly, it is easier to uninstall the old version instead of filing-in fixes.
- Parser.st
- This is a parser that is portable between VisualWorks and IBM ST.
- Browser.st
- This is the main sources file for the browser.
- ProgressWidget.st
- This file is not included with the browser, but it can be found in the /pub/Smalltalk/st80_vw directory on st. More information about the progress widgets can be found on this page.
- Launcher.st
- This file adds the buttons to start the browser and lint tools to the launcher and opens a new launcher. If you don't want to modify your launcher, you can evaluate "RefactoringBrowser open" to open the browser and "Smalllint open" to open the lint tool.
- DragDropLauncher.st
- This file adds the drag & drop support for the refactoring browser to the icon on the launcher. It should only be filed-in if you have filed-in both the DragDrop.st and Launcher.st files above.
- Fixes files
- You should also file in all of the fixes files from the browser's source directory. These files include both fixes and enhancements to the browser.
Other Refactoring Information:
User instructions:
To open the refactoring browser select the
button or evaluate "RefactoringBrowser open". If you're using ENVY, then you can select the "RefactoringBrowser" from the ENVY menu in the launcher. This will open a window that is similar to this picture.
The refactoring browser should be very familiar to people using the standard system browser since many of its items are the same. As a result, only the new menu items are listed:
- Buffers
- Create buffer
: Creates a new code tool and makes it the current code tool. You can switch back to the other code tool by selecting it at the bottom of the Buffers menu.
- Remove buffer
: Removes the current code tool from the list of available code tools.
- Create window
: Creates a new code tool window. This is only available in multi-window mode.
- Class->class
- create subclass...
: Creates an subclass of the currently selected class. It allows you to choose which subclasses of the selected class should be subclasses of the new class.
- rename as...
: Renames a class, but unlike the standard browser rename, it also changes the source code to refer to the new name.
- safe remove
: Removes a class only if it is not referenced.
- inspect all instances…
: Opens an inspector on all instances of the selected class.
- check protocols…
: Checks that all methods are defined under a protocol and that the protocol is the same as the superclass' protocol for redefined methods.
- Class->instance variables
- add...
: Adds a new instance variable to the selected class.
- rename as...
: Renames an instance variable and patches the source to refer to the new variable name.
- remove...
: Removes an instance variable from the selected class only if it is not used.
- push down...
: Moves an instance variable from the selected class to its subclasses.
- pull up...
: Moves instance variables with the same name from the selected class' subclasses to the selected class.
- create accessors…: Adds a getter and setter method for a particular variable.
- abstract...
: Converts all direct references to an instance variable to go through getter and setter methods.
- convert to value holder...
: Converts the contents of a variable to hold a value holder on a value instead of the value itself.
- Class->class variables
- add...
: Adds a new class variable to the selected class.
- rename as...
: Renames a class variable and patches the source to refer to the new variable name.
- remove...
: Removes an unreferenced class variable.
- create accessors…
: Adds a getter and setter method for a particular class variable.
- abstract...
: Converts direct references to the class variable to go through getter and setter methods.
- Selector
- rename...
: Rename a method, and patch the caller's source.
- safe remove
: Remove a method only if there are no senders or if it is equivalent to the superclass method.
- push up
: Move the method definition to the superclass, if the superclass does not define such a method. Also, if multiple subclasses of the superclass define the same method (same source) then it will ask if you want to also remove them.
- Tool
(when viewing methods)
- extract method…
: Extracts the selected text as a method. It replaces the extracted statements with a self send of the new message.
- variables
(only available when a variable name is selected and the method has been accepted)
- convert to instance variable
: Converts a temporary variable to an instance variable. This refactoring is not behavior preserving if the method is recursive.
- rename temporary…
: Renames a block or temporary variable.
- move to inner scope
: Moves the definition of a temporary variable to the inner most block that can contain its definition. This is useful for converting full blocks into copying or optimized blocks.
- rewrite…
: Opens a tool that can be used to define transformation rules for source code transformations. Here are some instructions for using the rewrite tool.
All of the menu items above are refactorings except for the Buffer menu items and the rewrite editor.
The new browser was designed to be extensible and customizable. There are several methods that you can modify and/or execute to change its behavior.
- Multi-window support: You can change the browser so that each code tool is opened in a new window, instead of creating buffers for each tool. To change the browser to be multi-window evaluate "RefactoringBrowser beMultiWindow", and to change it back to single window mode evaluate "RefactoringBrowser beSingleWindow". Once you evaluate either selection, you must open a new browser.
|
|
- Vertical navigators: You can change the navigator from it's default horizontal position to a vertical one by evaluating "RefactoringBrowser beVertical" and switch it back to horizontal by evaluating "RefactoringBrowser beHorizontal".
|
- Resource editors: You can change the editor and/or viewer for a resource (menus, canvases, etc.) by changing ResourceTool>initialize method. For example, to change the menu editor, so that the new VisualWorks 2.5 enhanced menu editor is opened, change UIMenuEditor to MenuEditor, and then re-initialize the ResourceTool class.
|
|
- Code tools: You can create a new code tool and add it to the browser by modifying the CodeModel>codeToolClass method. This method determines which code tool is used for the navigator's selection. Code tools can be created by creating a subclass of CodeTool, defining its interface functions, and defining the updateContents method. The updateContents message is sent to the code tool so that the code tool can stay current with the navigator's selection.
|
Bugs/Limitations:
This section lists the known bugs and their work arounds (if they exist). If you know of a bug that is not listed in this section, please mail us. If we know of the bug, we might fix it, but we can't fix bugs that we don't know about
.
- Class Variables in VisualWorks ENVY: The
Class>>removeClassVarName: in VisualWorks ENVY has a bug in that it
doesn't remove the class variable. This bug affects the push up/down class
variable, remove class variable, and rename class variable refactorings.
For the rename class variable refactoring, the code will be transformed, but
the renamed variable will not be removed. One fix for the problem is to
change the code in Class>>removeClassVarName: from:
self classVarNames asOrderedCollection
remove: existingClassVarName asString ifAbsent:[];
yourself
to:
self classVarNames asOrderedCollection
remove: existingClassVarName asSymbol ifAbsent:[];
yourself
Since class variables are symbols in VisualWorks, the "existingClassVarName asString" will never be found as a class variable name.
Spawn hierarchy: If you add a new class in a "spawned hierarchy" browser, you may not be able to see the new protocols that you add for the new class. Furthermore, in ENVY this may cause an exception.
Undefined classes: Under ENVY classes that are in applications but do not have a definition loaded, can cause exceptions if you try to perform operations on them (e.g., browse references).
Drag & Drop: If you drag a selection from the browser that has multiple categories or protocols selected and drop it on the original VisualWorks browser icon, you can generate exceptions if the first class/method selected is not in the first category/protocol selected.
Symbol References: When you are "safe removing" a class and there are references, the option to browse the references doesn't not browse the indirect references through symbols.
Comments in extracted code: When extracting code, the comments in that are in the extracted code, will appear both in the method that was extracted as well as the method it was extracted from.
Hierarchy in IBM: The first time you switch from the application view to the hierarchy view in IBM ST, the hierarchy is not displayed properly. If you just switch back to the application view and then to the hierarchy everything will display proper. Also, you could just double click the selected class to refresh the view.
Shortcut keys in VW: Some of the shortcut keys in the VW text editor do not work with the browser since the browser uses continuousAccept on its text widget.
"Safe removing" classes: Safe remove on a group of classes only removes the first one selected (unlike the other removes).
Spawn browser: When you select spawn browser from the editor for the "Missing subclassResponsibility" lint rule, you will get a doesNotUnderstand: error. This does not affect any of the other browsers or lint rule editors, only the missing subclassResponsibility rule.
Dialog: When you open a browser and there are no methods for it to inspect, it will open a dialog saying "Nobody". If there are no active controllers, then it will fail with a doesNotUnderstand: message. You can either terminate this process, or open the debugger and restart the method.
Slow response: When running the multi-window browser under Motif (maybe other unix window managers?), it may take longer to update the window. Since only the top most window is updated after a change, the program must get the stacked window order from a primitive. While this primitive is fast on MS-Windows, it is slow under Motif so the resulting update is slow for Motif. If you have a better way to get the stacked order of the windows, please mail us.
Slow dialog close: When running VisualWorks 2.5 with the events file-in, the dialog warning takes longer to close after the close button is pressed. This is probably a bug in VisualWorks 2.5 events code.
Menu bug: When running VisualWorks 2.5 with the events file in, the pop-up menu automatically select the first item that has a submenu instead of the top-most item. Again, this is probably a bug in VisualWorks 2.5 event code.
File out: Selecting file out from the category, class or protocol menu will file out all methods for the selection, instead of filing out only the methods that you are browsing. For example, if you spawn class Object and then select file out from the category menu, you will file out all classes in the Kernel-Objects category instead of just Object.
Comments or suggestions can be sent to
brant@cs.uiuc.edu
and droberts@cs.uiuc.edu.
Last updated on 29-Apr-97.