Skip to content

abb-iss/NppTransformExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Notepad++ Transform Example

This project is a SrcML Transform project that relies on the ABB Visual Studio Program Transformation tool. This code was used in a tool demonstration given at FSE 2012. The slides are available here.

Background

We want to demonstrate a fairly wide-ranging code transformation on a real piece of software. In this demo, we want to ensure that all uses of the new operator are wrapped in a try/catch block in order to check for errors. This was a compiler change seen in Visual Studio 2005:

By default, any call to new that fails will throw an exception.

Microsoft provided other ways adapt to this change, but for our purposes, we will assume that the best change is to modify the source code in order to reflect the C++ standard.

Setup

In order to run this code, there are a few setup steps.

First, download SrcML.NET and install the program transformation Visual Studio add-in (see the README for details).

Second, download the code for Notepad++ and extract it somewhere on disk. I used version 6.2 in the demonstration, but the transformations should work on other versions as well.

The Demo

The demonstration is fairly straightforward.

  1. Launch Visual Studio
  2. Open the "NPPTransformExample" project
  3. Enable the "Program Transformation" addin from the add-ins menu. The "transformation preview pane" should appear.
  4. Select the first "Browse..." button to select a source folder.
  5. Navigate to the downloaded copy of Notepad++
  6. Select the "PowerEditor" directory
  7. Press "OK"
  8. The buttons will disable briefly while the source code is converted into srcML.
  9. Build the project -- the add-in should update saying that three transformations have been loaded.
  10. You can now play with any of the provided transformations. There are three:
  11. AllNewQuery: This is used to demonstrate a basic query and to explore how the new operator is used in Notepad++. You can use the category view on the left to see what kinds of statements new operators appear in.
  12. NewExpressionTransform: This is used to transform all uses of the new operator that occur in expression statements.
  13. NewDeclarationTransform: This is used to transform all uses of the new operator that occur in declaration statements.

In order to preview a transform, simply press "Test". You can double click on any of the results to see the original source code. Once you're happy with the results, select an output directory (the 2nd "Browse..." button) and then press "Execute." Notepad++ compiles, runs, and operates without error. This is exactly what we want for an adaptive maintenance change!

About

Code for the Notepad++ transformation presented at FSE 2012.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages