RefactorScript – VisualGDB Documentation (original) (raw)

Contents

Overview
Running RefactorScripts
RefactorScript Window
RefactorScript Language
Data Model
Common RefactorScripts

Overview

RefactorScript is a mechanism for generating boilerplate code based on the existing C/C++ structures or functions. The typical uses for RefactorScript are:

RefactorScript is supported in VisualGDB Custom Edition and higher.

Running RefactorScripts

There are 2 ways of running a RefactorScript:

  1. Selecting one or more classes, fields, methods, variables, etc. in Code Explorer -> Outline, and using the Run RefactorScript button.
  2. Using the smart tags directly in the code editor

RefactorScript Window

Running a RefactorScript using either of the ways opens the RefactorScript window with the following controls:

The script editor provides very basic suggestion popups triggered by the ‘$’ and ‘.’ symbols:The suggestion popups work by quickly running the script until the edited position. This ensures accurate results, but will not work for the code branches that are never executed (e.g. disabled via main generator arguments).

RefactorScript Language

RefactorScripts are an advanced form of code snippets. Lines prefixed with “>” are copied to the output, while expanding the $-expressions. Lines not prefixed with “>” follow C#-like syntax and are used to iterate over arrays, check conditions (e.g. skip non-pointers) and define intermediate variables.

You can find a detailed description of the RefactorScript language on this page.

Data Model

RefactorScripts can access exhaustive information about the selected classes, functions, fields or other C/C++ entities, that can be used to fine-tune their output. You can easily explore this information via the right side of the RefactorScript window, or see our RefactorScript data model reference for the full list of all provided fields.

Common RefactorScripts

See this section for a list of RefactorScripts shipped with VisualGDB, along with practical use examples.