Home > Overview > Refactorings preview hinting

Refactorings preview hinting

September 24th, 2010

Almost all refactorings have a preview hint which allows you to see the resulting code before a particular refactoring is performed. This is very useful, because it is a great help to understand what will happen in the code once an action is taken. Moving among available refactorings in the Refactor! popup menu or a SmartTag popup menu will be reflected in the preview for each one. Here are previews of some possible refactorings you can perform using the Refactor! popup menu:

Refactor! Refactoring sample

Refactor! Refactoring sample

Refactor! Refactoring sample

While the Refactor! popup menu is up, you are able to control preview hinting by holding the following keys:

  • CTRL – will hide the menu and the big yellow hint with a description of a refactoring.
  • SHIFT – will hide the resulting code preview window with a blue arrow pointing to the target code location

NOTE: these two keys aren’t available if you’re using a different way of listing available refactorings, e.g. SmartTag popup menu.

Products: Refactor Pro and Refactor free editions
Versions: 10.2 and up
VS IDEs: any
Updated: Mar/23/2011
ID: R016

Similar Posts:

  1. Robert Leahey
    December 22nd, 2010 at 09:18 | #1

    Hi Alex, I realize that this is only remotely related, but I was wondering if you might share how to draw a Strikethrough using the new VS2010-style adornments. My refactoring plugin correctly draws its preview window, but I want to render a strikethrough of the existing code.
    The current sample code I have is old; it creates and draws a Strikethrough in the EventNexus.EditorPaintForeground event. Is there a preferred event now?

  2. December 22nd, 2010 at 12:47 | #2

    @Robert Leahey
    Hi Robert, inside of a PreparePreview event handler you can draw a strikethrough, using the AddStrikethgough method of the PrepareContentPreviewEventArgs. I’ll write a post on how to draw such elements soon.

  3. Robert Leahey
    December 23rd, 2010 at 05:22 | #3

    Success! Thanks Alex.

  4. Robert Leahey
    December 23rd, 2010 at 12:25 | #4

    Hey Alex, do you have any posts that could direct me on utilizing the Rename refactoring within my own refactoring?
    Or rather, how best to handle a rename, since my refactoring plug-in is allowing the rename of an element and I want to the new name propagate throughout the code as it would using the Rename refactoring. If that makes sense…

  5. December 25th, 2010 at 09:32 | #5

    @Robert Leahey
    Hi Robert, here is the post: How to perform an existing refactoring from another one