Skip to content

Basic Refactoring Commands

This page describes the use of the basic Refactor commands.

  1. Refactoring
  2. Refactor Sub-Commands

The Refactor Commands directs the translator to make changes to the low-level semantic model of your codebase as it moves from source form to target form. These changes will be propagated across the codebase as appropriate.

Within gmStudio the transformation of a source codebase to a target codebase proceeds in 8 steps:

  1. Loading the source code
  2. Pre-Processing the source code (optional)
  3. Building a detailed symbol table from the identifiers declared in the source code and in the external libraries referenced by the source code
  4. Building a low-level semantic model from the logic in the source code
  5. Analyzing the symbol table and semantic model and transforming it to fit the target requirements
  6. Authoring the target code for the semantic model and symbol table
  7. Post-Processing the target code (optional)
  8. Authoring the target code

During this process there are 3 points at which refactoring operations can be made; shown here in the context of a Translation Script.

<gmBasic>
...
<Compile Project="%SrcPath%" >
' step 1: load code
' step 2: pre-process code
' step 3: build symbol table
First, after step 3, which builds the symbol table. This is
a very effective place to strengthen the specifications of
the symbols so that the compiler can take advantage of this
additional information while generating the pseudo-code.
<Refactor ... >
' step 4: compile program logic into semantic model
</Compile>
Second, after step 4 when the compiler has completed but the code analyzer
has not yet run. This is an excellent time to introduce .NET types
explicitly and to do any removals.
<Refactor ... >
' step 5: analyze the semantic model
<Analyse />
Third, after step 5, when the analyzer has run, but before the author has
executed. This is the best time to do symbol renaming and code re-authoring.
<Refactor ... >
<Author />
...
<gmBasic>

The Refactor command has five sub-commands:

  • FixType: Specifies the binary type of a component or group of components
  • Remove: Removes component from being authored
  • Rename: Changes the authored name of components
  • Reauthor: Replaces the authored content of a subprogram
  • Migrate: Specifies a wide range of code re-engineering operations
  • Transform: Specifies a wide range of code re-engineering operations

Additional details are presented in the Reference section.