The Recorded Refactoring Format (RRF)

Johannes Henkel, 7/13/2004, henkel@cs.colorado.edu

XML Serialized Format

Example:

<?xml version="1.0" encoding="UTF-8"?>
<refactoringsession>
    <refactoring name="Rename Type">
        <parameter name="new name">ExampleClassRenamed</parameter>
        <parameter name="type">examplepackage.ExampleClass</parameter>
        <comment>We renamed class ExampleClass to ExampleClassRenamed since that's the better style.</comment>
    </refactoring>
    <refactoring name="Rename Type">
        <parameter name="new name">ExampleInnerClassRenamed</parameter>
        <parameter name="type">examplepackage.ExampleClassRenamed$ExampleInnerClass</parameter>
    </refactoring>
    <refactoring name="Rename Type">
        <parameter name="new name">AnotherClassRenamed</parameter>
        <parameter name="type">examplepackage.anotherpackage.AnotherClass</parameter>
    </refactoring>
</refactoringsession>

In other words, it's really quite trivial. There is always a root-node refactoringsession. It contains one or more refactoring elements, which have a name-attribute. The value of this attribute (e.g., "Rename Type") describes which refactoring took place. The children of a refactoring element are the parameter elements, which have a name attribute (e.g., "new name") and a value that is modeled as the text inside the element. Each refactoring can have at most one comment element, where the users can annotate and explain why they are doing a particular refactoring.

Supported Refactorings

refactoring name
description
parameter name
description
Rename Type
rename a class or an interface
type
The fully qualified type name of the type to be renamed, including package and inner type stuff etc. E.g., "com.xyz.OuterClass$InnerClass".


new name
The new name of the type, without full qualification. E.g., "InnerClassRenamed".
Move Java Element
move one Java element to a new destination
element kind
The kind of element we are moving.
Currently supported: "type".


element
If "element type" is "type", then this parameter specifies a type with its fully qualified name. E.g., "com.xyz.OuterClass$InnerClass".


destination kind
To what kind of destination are we moving the element?
Currently supported: "package", "type"


destination
If "destination type" is "package", then this parameter specifies a package by providing its name, e.g. com.xyz.
If "destination type" is "type", then this parameter specifies a type with its fully qualified name. E.g., "com.xyz.OuterClass$InnerClass".
Move Static Member
(not tested yet)

member kind
The kind of member we are moving.
Currently supported: "type","method","field"


declaring type
The type in which the member is declared. Specified with its fully qualified name. E.g., "com.xyz.OuterClass$InnerClass"


member
If "member kind" is "type", then this parameter specifies a type by its name, e.g. "InnerClass".
If "member kind" is "method", then this parameter specifies a method by the format <methodName>":"<signature>, where <methodName> is the name of the method and <signature> is the signature of the method. Example: "main:(Ljava.lang.String;)V".
If "member kind" is "field", then this parameter specifies a field by its name, e.g. "lastElement".


destination type
The type to which the member is moved. Specified with its fully qualified name. E.g., "com.xyz.OuterClass$InnerClassDestination"
Change Signature
change the signature of a method
declaring type
The type in which the method is declared. Specified with its fully qualified name. E.g., "com.xyz.OuterClass$InnerClass"


method
This parameter specifies a method by the format <methodName>":"<signature>, where <methodName> is the name of the method and <signature> is the signature of the method. Example: "main:(Ljava.lang.String;)V".


new method name
the new name for the method, e.g. "newMain"


new return type
the new return type for the method, e.g. "void". This is a type you would write in Java source code.


new visibility
the new visibility.
Currently supported: "public","protected","","private"


number of parameter infos
How many parameter infos will we provide? E.g., 3. A parameter info would really be an object in an ideal world ... In this world, it's split up into a number of parameters by using the prefix "parameter <n>" for the parameter name, where <n> is a number between 0 and "number of parameter infos". The parameter info parameters are listed below this parameter.


parameter <n> old index
Which index did this parameter have before - a number >=0. Note that this number is unrelevant if "is added" is true.


parameter <n> old name
The old name of parameter <n>. E.g., "args"


parameter <n> old type name
The old name of the type for parameter <n>. E.g. "java.lang.String[]"


parameter <n> new name
A new name for parameter <n>


parameter <n> new type name
The name of the new type for parameter <n>. E.g. "java.lang.String[]"


parameter <n> is added
Are we adding parameter <n>?


parameter <n> is deleted
Are we deleting parameter <n>?


parameter <n> default value
a Java expression, e.g. "new LinkedList()", which will then be used within the source-code of the client wherever the new parameter is needed.


number of exception infos
How many exception infos will we provide? E.g., 3. An exception info would really be an object in an ideal world ... In this world, it's split up into a number of parameters by using the prefix "exception <n>" for the parameter name, where <n> is a number between 0 and "number of exception infos". The exception info parameters are listed below this parameter.


exception <n> type name
The type name of the exception, e.g. java.lang.Exception


exception <n> status
Did we add or delete this or has it been there before?
Currently supported: "added", "deleted", "old"
Rename Non Virtual Method
(recording support only)
rename a non-virtual method
declaring type
The type in which the method is declared. Specified with its fully qualified name. E.g., "com.xyz.OuterClass$InnerClass"


method
This parameter specifies a method by the format <methodName>":"<signature>, where <methodName> is the name of the method and <signature> is the signature of the method. Example: "main:(Ljava.lang.String;)V".


new name
the new name for the method, e.g. "newMain"
Rename Virtual Method
(recording support only)
rename a virtual method
declaring type
The type in which the method is declared. Specified with its fully qualified name. E.g., "com.xyz.OuterClass$InnerClass"


method
This parameter specifies a method by the format <methodName>":"<signature>, where <methodName> is the name of the method and <signature> is the signature of the method. Example: "main:(Ljava.lang.String;)V".


new name
the new name for the method, e.g. "newMain"
Change Type
(recording support only)
generalize the type of a field, a parameter, or a return type
element kind
We will change the type for element. So what kind of element are we working on?
Currently supported: "field", "parameter".
Note: parameter includes return type!


declaring type
Which type declares the element? Qualified name, e.g. "com.xyz.OuterClass.InnerClass" for an element that is a member of "com.xyz.OuterClass.InnerClass"


element
If "element kind" is "field", then this is parameter contains the name of a field within the declaring type.
If "element kind" is "parameter", then this parameter contains <name>":"<signature>":"<parameterIndex>, where <name> is the name of the methond (e.g., "main"), <signature> is the signature, e.g. "(QString;)V", and <parameterIndex> is the index of the parameter that is being manipulated. <parameterIndex>=-1 means that we'll be working on the return type. The parameters are numbered beginning with 0. Example: "main:(QString;)V:0".


new type
The qualified name of the new type, e.g. "com.xyz.OuterClass.InnerClass"
Rename Field
(replay untested)
rename a field, and optionally rename getters and setters
declaring type
In which type is the field declared? Fully qualified name, e.g. "com.xyz.OuterClass$InnerClass"


old name
e.g. "oldName"


new name
e.g. "newName"


rename getter
Should we rename the getter accordingly? Either "true" or "false".


rename setter
Should we rename the setter accordingly? Either "true" or "false".
Use Supertype Where Possible
(recording support only)
Whenever the type occurs in the code, replace the occurrence with a particular supertype instead
type
The fully qualified name of the type, e.g. "com.xyz.OuterClass$InnerClass"


supertype to use
the fully qualified name of the super type to use, e.g.
"com.xyz.SuperTypeOfInnerClass"


use supertype in instanceof
Should the supertype even be used for instanceof checks? "true" or "false".
Introduce Factory
(recording support only)
Introduce a factory method, make the constructor private (optionally) and make sure that clients use the factory method instead of the constructor
declaring type
fully qualified name of declaring type, e.g. "com.xyz.OuterClass$InnerClass"


constructor
This parameter specifies a constructor by the format <methodName>":"<signature>, where <methodName> is the name of the constructor (always "<init>") and <signature> is the signature of the constructor. Example: "<init>:(Ljava.lang.String;)V


factory class name
the name of the new factory class


new method name
the name of the new factory method


protect constructor
should we protect the constructor?
possible values: true or false