The following Pharo script takes a String with the first letters of a package as input (pkgPrefix) and a two-letter String used to prefix all its classes. It creates then a refactoring environment for such packages and renames all its classes with the provided newClassPrefix:
| pkgPrefix newClassPrefix env model | pkgPrefix := ''. newClassPrefix := 'NP'. env := RBBrowserEnvironment new forPackageNames: (RPackage organizer packageNames select: [ : pkgName | (pkgName beginsWith: pkgPrefix) ]). model := (RBClassModelFactory rbNamespace onEnvironment: env) name: 'ModelName'; yourself. RBClassRegexRefactoring new model: model; renameClasses; replace: '^(.*)$' with: newClassPrefix , '$1'; execute.
0 comentarios:
Publicar un comentario