SUBSTITUTE Refactoring

This refactoring is intended to be used as part of a legacy code modernization project. It is unlikely to be used on a day-to-day basis.

This feature assists in the transformation from string concatenation to the use of a single string with SUBSTITUTE. This is done because the full sentence in a single string is easier to translate (for internationalization) than the sentence fragmented into two strings.

Usage

  1. In the Navigator view, select the files, directories, and/or projects to be refactored.
  2. From the Navigator view's context menu, choose ProRefactor > SUBSTITUTE Refactoring.
  3. ProRefactor will parse the selected resources, and find any string concatenations which might require refactoring. It will present the suspect code in the Review Changes dialog.
  4. Review, and then accept or reject the code change. You may make manual changes to the source code before accepting the changes.

In some cases, ProRefactor may be unable to automatically suggest changes to the source code. You will be informed of this by a message, and you will be able to make the code change by hand if desired.

In the Review Changes dialog, the Cancel button will reject the current changes and stop any further processing.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

implicit concatenation not dealt with

The "Message" statement does implicit string concatenation.
E.g.
MESSAGE "Hello" customer.first-name "! How are you?" VIEW-AS ALERT-BOX.
would display something like "Hello Bob ! How are you?".

The SUBSTITUTE refactoring currently does not deal with these cases, but it should (I'm reviewing/translating old code and they are abundant!).

The refactoring should offer the following:
MESSAGE SUBSTITUTE("Hello &1 ! How are you?", customer.first-name) VIEW-AS ALERT-BOX.


john's picture

Re: implicit concatenation not dealt with

That's a good one David, thanks for posting that. It would be a great enhancement. I think it would be fun to work on, but unfortunately I'm swamped with customer contract work at the moment. I'd be happy to provide email help to anybody who wants to take a shot at it though.