VSE Refactoring Browser User's Guide

Contents:

Requirements
Installation
Opening the Browser
Environment Selection and Viewing
Global Menu Refactoring Operations
    Class
    Inst Vars
    Class vars
Method Menu Refactoring Operations
Environment Selection Operations and Tools
    Module selection
    Class selection
    Browse environment methods
    Contents Pane Selection
Lint Tool
Code Rewrite Tool
Non-Team Refactoring Browser
Additional Information

Requirements

Visual Smalltalk Enterprise 3.1.2c for Win32 or OS/2 with WindowBuilder Pro Runtime files.  The following libraries need to be bound.  Replace the letter x in the file name entries in the table below with W if the target platform is Win32 or O if the platform is OS/2.
 
teamvtol.bnd Exposed Team tools bind file.  Include as '@teamvtol.bnd' in Vdevx.bnd 
Vprg31x.sll Progress bar control
Vstp31x.sll Status pane
VlstC31.sll List Choice Dialogs
WB31RBx.sll WindowBuilder Pro runtime base files 

Installation

Ensure that the image has the required libraries above included in the image bind file or loaded before starting.  To install the VSE refactoring browser from source files select Install from the File menu and pick the files RBBase.st and RBTeam.st.  Alternately, you can evaluate the following in a workspace or browser:

    (File pathName:'RBBase.st') fileIn.
  (File pathName:'RBTeam.st') fileIn.

If you have the Team/V repository you may load the VSE refactoring browser by loading the clusters named Refactoring Browser 3.0.0 and Team Refactoring Components from the repository.

Note it isn't suitable to store the refactoring browser code in the form of SLL libraries since the method categories or protocols are not stored in the library.  The lint tool gathers its rules by searching for class method categories in the BlockLintRule, TransformationRule, and ParseTreeLintRule classes.  If the refactoring browser is loaded from SLLs the lint tool will not load its rules.

Opening the Browser


 

To open the refactoring browser evaluate RefactoringBrowser open in the Transcript or a workspace.  A sample refactoring browser window appears above with each of its panes identified.

Environment Selection and Viewing

The scope a refactoring browser applies its operations to is limited by its selected environment.  This environment may be selected from the module and global list panes.  The refactoring browser module, global, protocol, and method lists all have environment filter modes that select their view of the environment.  This mode may be changed by selecting the Filter... menu item for the module, global, and method list menus.  Each brings up a dialog to change the list filtering.  When the Environment box is checked only items visible to the environment are shown in the list.  When the Environment box is checked off all items including those in the environment are visible.  In this inclusive mode the module and global lists show environment items with a checkmark beside them.  The module list also distinguishes clusters with a bold checkmark if all items of the cluster are selected and a thin checkmark if some are.  The figure above shows the module list with its filter dialog open and the list with its environment filter in effect.  This figure shows the module list without environment filtering.  The remaining figures on this page show the module list with its environment filter unchecked.

Double clicking on a selection in the list will either add it to or remove it from the environment.

If any list filter has its filter dialog radio button Show all selected all items in its list are shown and shown unchecked regardless of the browser environment.  Operations of the refactoring browser still apply to its environment although the list no longer distinguishes which items belong to it.

Note the response of the browser list panes will decrease as the selected environment increases in size and granularity.  That is, as the number of incompletely selected clusters, packages, and classes  added to the environment increases the response is poorer.  Reduce or consolidate the selections then select Optimize from the Environment menu to improve performance.

Global Menu Refactoring Operations


 
 

Class

    Create subclass...
     Create a subclass for the selected class and optionally move any of its subclasses to be the new class' subclasses.

    Convert to sibling...
     Create a class to be the superclass of the selected class and subclass of its superclass.  When requested, enter the name of the class to be created.

     Rename...
     Renames the selected class and all its references.

    Remove
     Removes with confirmation the selected class and all its subclasses.

    Safe Remove
    Unless the selected class is referenced remove it and subclass any of its subclasses from its superclass.  Show any references in a method browser.

    Inspect All Instances
    Open an inspector on all instances of the selected class.

    Find Reference Path to Instance
    Search reference paths to an instance of the selected class and open an inspector on these paths.  The inspector holds an OrderedCollection of the links traversing the reference path, the first entry being the global the reference originates from and the last entry the instance itself. Expect to wait since this search is time consuming.

    Find All Reference Paths to Instances
    Find reference paths to all instances of the selected class and open an inspector on the paths to each instance.  The inspector holds the collection of reference paths to each instance.  Each entry is an OrderedCollection of the links traversing its reference path, the first entry the global the reference originates from and the last entry the instance itself. Expect to wait since this search is time consuming.

Inst Vars

    Readers...
    This opens a browser on methods that access a selected variable.

    Writers...
    This opens a browser on methods that set the value of a selected variable.

    Add...
    Select a class in the environment then perform this menu function. You will be prompted for a new variable to add to the class.

    Rename...
    Select an instance variable and provide the new name.  This will rename the variable and all references to the variable in the class or its subclasses.  Note that if an instance variable exists by the new name you choose already a dialog showing this error will be displayed.

    Remove...
    Select an instance variable to remove.  If there are any references to the variable a method browser will open displaying methods where the variable is used.  The variable will be removed from the class if there are no references to it.

    Push Down...
 This operation will move an instance variable of your choice into the class definitions of its immediate subclasses.  If there are no methods that reference the variable in a subclass it will not be moved to this class. First, ensure that all methods that reference the variable appear in its subclasses.  Select all variables you wish to move to the subclasses when requested.

    Pull Up...
 This operation moves an instance variable definition from a subclass into the selected class.  Select all variables you wish to move when requested.

   Create Accessors...
 Choose any or all instance variables and the class setter and getter functions will be created for each.

   Abstract...
  Converts all direct references to all instance variables you select to go through getter and setter methods.
 

Class vars

    Add...
    Select a class in the environment then perform this menu function. You will be prompted for a new variable to add to the class.

    Rename...
    Select a class variable and provide the new name.  This will rename the variable and all references to the variable in the class or its subclasses. Note that if a class variable exists by the new name you choose already a dialog showing this error will be displayed.

    Remove...
    Select a class variable to remove.  If there are any references to the variable a method browser will open displaying methods where the variable is used.  The variable will be removed from the class if there are no references to it.

    Push Down...
    This operation will move a class variable of your choice into the class definitions of its immediate subclasses.  If there are no methods that reference  the variable in a subclass it will not be moved to this class. First, ensure that all methods that reference the variable appear in its subclasses.  Select all variables you wish to move to the subclasses when requested.

    Pull Up...
    This operation moves a class variable definition from a subclass into the selected class.  Select all variables you wish to move when requested.

    Create Accessors...
Choose any or all class variables and the class setter and getter functions will be created for each.

   Abstract...
  Converts direct references to all class variables selected to use getter and  setter methods where they are used.
 

Method Menu Refactoring Operations

    Rename
    Renames the selected method and all its references to the name you choose.

    Safe Remove
    Unless the selected method is referenced remove it.  Show any references in a method browser.

    Push Down
    Move the selected method into each immediate subclass of this class.  If any subclass already defines this method its implementation is not replaced.

    Pull Up
    Moves the selected method into the superclass.  If any subclass of this superclass defines this method equivalently a request to delete equivalent methods will be made.

Code

The following choices modify code or variables selected in the contents pane.

    Convert to InstVar
    Convert the selected temporary variable in the method to a instance variable for the class.

    Rename Temp...
    Rename the temporary variable selected in the method.

    Move to Inner Scope
    Unless the temporary variable is used in an outer scope, move the declaration of a selected temporary variable into an inner scope in the method (e.g. a block).

    Extract Method...
    Create a new method from the selected code and replace the code with a matching message send.  Note the method created will not be added automatically to the environment and consequently may not be visible in the refactoring browser's method list.  Re-add the method's class to the environment to show all its methods.
 

Environment Selection Operations and Tools

The Environment menu item in the menu bar is a feature of the refactoring browser.

    Undo
    This selection will undo the last refactoring operation.  The selection in the menu will indicate the last type of refactoring.  If no refactoring operations have been performed the choice will be disabled.

    Redo
    Redo the last refactoring operation undone by choosing Undo above.  The selection in the menu will indicate the last refactoring undone.  The choice will be disabled if no operations have been undone.

    Caption...
    Select to rename the window caption of the browser.

    Optimize
    Remove deleted classes from the environment and promote it to a more minimal, abstract environment if possible.

Module selection

    This submenu adds to selectively adds or removes modules in the environment.

    Add
    Add the currently selected module in the module list.  If the module is not already included in the environment double clicking on the selection will do this as well.

    Remove
    Remove the currently selected module from the environment.  If the module is already included in the environment double clicking on the selection will remove it.

    Add all... / Remove all...
    Add to or remove from the environment all modules shown in the module list that match in name to a user entered string.  The wild card '*' may be used.

Class selection

    This submenu adds to selectively adds or removes classes in the environment.

    Add
    Add the currently selected class in the global list.  If the class is not already included in the environment double clicking on the selection will do this as well.

    Remove
    Remove the currently selected class from the environment.  If the class is already included in the environment double clicking on the class will remove it.

    Add all... / Remove all...
    Add to or remove from the environment all classes shown in the global list that match in name to a user entered string.  The wild card '*' may be used.

    Add Superclasses / Remove Superclasses
    Add or remove the superclasses of the selected class in the environment.

    Add Subclasses / Remove Subclasses
    Add or remove the subclasses of the selected class in the environment.

Browse environment methods

    Symbol References
    Search for all methods in the environment that use a symbol matching the user entry.

    String References
    Search for all methods in the environment that use a string matching the user entry.
 

Contents Pane Selection

    These menu selections toggle the mode of the refactoring browser contents pane.

    Rewrite
    Opens the code rewrite tool in the contents pane.  Menu choices associated with browsing code or definitions in the refactoring browser will be disabled.

    Lint
    Opens the lint tool in the contents pane.  Menu choices associated with browsing code or definitions in the refactoring browser will be disabled.

    Global
    Restores the typical use of the contents pane to browse and edit code.
 

Lint Tool

When the Lint tool is selected from the Environment menu the contents pane becomes its interface.  Any rule or group in the lint tool tree view may be selected to apply any or all checks or transformations to the selected environment.  The Run button starts the selected checks on the browser environment, Abort cancels the checks in progress, Results opens a result list from which the user may selectively examine results of each rule, and Empty cache resets the lint tool.

Advanced

A lint tool may be opened independently of the refactoring browser by evaluating either of the following expressions in the Transcript or a workspace:
 
Smalllint runAllChecks. Run all lint checks with the entire image as the environment.  The environment may be edited when the window opens.
Smalllint runRule: aRule.  Run lint rule aRule with the entire image as the environment.   The environment may be edited when the window opens.
Smalllint runRule: aRule onEnvironment: anEnvironment. Run lint rule aRule on the environment anEnvironment

where aRule is the result of any of the following choices:

    CompositeRule allRules
    CompositeRule class methods appearing in protocol 'all checks'.
    BlockLintRule class methods appearing in all protocols but 'private'.
    TransformationRule class methods appearing in protocol 'transformations'.

and anEnvironment is an instance of BrowserEnvironment or its subclasses.

Code Rewrite Tool

The code rewrite tool opens in the contents pane when the Rewrite mode is selected from the browser Environment menu.  It consists of a Search for: text pane to enter the code pattern to search for in the environment and a Replace with: text pane to enter the pattern to replace the code found.  The Search... button opens a browser listing all methods that match the search pattern without replacing code.  The Replace... button opens a list of all methods found that match the search pattern shown modified to the replace pattern.  The user may choose to make the changes to the image for any or all of the methods listed by selecting this action from the result list popup menu.

Advanced

A code rewrite tool may be opened independently of the refactoring browser by evaluating the following:

    RewriteRuleEditor rewrite: aString.

where aString is the contents to appear in the Search for: text pane.  The environment is set for the entire image when the image opens but may be further edited.
 

Non-Team Refactoring Browser

A simple refactoring browser subclassed from the class hierarchy browser that performs refactoring operations but does not include lint or code rewrite functions may be opened by evaluating:

    OSLRefactoringBrowser open

The advantage of this browser is this goodie's team refactoring components (i.e. RBTeam.st) do not need to be installed to take advantage of the refactoring functions.
 

Additional Information

General information and usage instructions upon the Refactoring Browser may be found at the home page maintained by it's creators.  Also, see its HyperNews page for its latest comments and information.


Links to:
The ObjectShare web site
VisualSmalltalk Product Support
ObjectShare's Online Documentation Site