Rename module
The rename module refactoring renames a module with the given new name. Renames the file and make changes in other file where this module is referenced. In the example the mod1 module is renamed to newmod. The file is also renamed to newmod.erl.
Renaming module mod1 to newmod:
-module(mod1). -export([add/2]). add(A,B) -> A + B.
-module(mod2). -export([add/1]). add([]) -> []; add[{A,B}|Tail]) -> [mod1:add(A,B) |add(Tail)].
Result:
-module(newmod). -export([add/2]). add(A,B) -> A + B.
-module(mod2). -export([add/1]). add([]) -> []; add[{A,B}|Tail]) -> [newmod:add(A,B) |add(Tail)].
Side conditions
- The given new name should be a legal file name.
- There must not exist another module with the given new name in the graph.
- There must not exist another file with the given new name in the directory of the module to be renamed.
- If one of the above conditions fails, the transformation starts an interaction to ask for a new module name.
Transformation steps and compensations
- Rename the current module name to the new name.
- Rename the collected module qualifiers to the given new name.
- Rename the references to the module in the import lists.
- Rename the file to the new name.
Last modified 13 years ago
Last modified on Feb 17, 2012, 5:28:11 PM