for (IFile drlFile : drlFiles) {
if ((content = readFile(drlFile))==null)
return null;
TextFileChange change = new TextFileChange(drlFile.getName(), drlFile);
MultiTextEdit mte = new MultiTextEdit();
change.setEdit(mte);
// rename the field name
Pattern pattern = Pattern.compile(FIELD_NAME.replaceAll("FIELD_NAME", currentName));
matcher = pattern.matcher(content);
while (matcher.find()) {
ReplaceEdit replace = new ReplaceEdit(matcher.start(), currentName.length(), newName);
mte.addChild(replace);
}
// search all the variables of the type to replace the getters/setters
pattern = Pattern.compile(VARIABLE_ASSIGNED.replace("TYPE", typeName));
matcher = pattern.matcher(content);
while (matcher.find()) {
if (matcher.group().length() > 0) {
String variableNameAssigned = matcher.group();
if (renameFieldProcessor.getRenameGetter()) {
String newGetterName = renameFieldProcessor.getNewGetterName();
String currentGetterName = renameFieldProcessor.getGetter().getElementName();
String regexp = GETTER_NAME.replace("VARIABLE_NAME", variableNameAssigned).replace("CURRENT_GETTER_NAME", currentGetterName);
createFieldRenameChanges(mte, content, regexp, currentGetterName, newGetterName);
}
if (renameFieldProcessor.getRenameSetter()) {
String newSetterName = renameFieldProcessor.getNewSetterName();
String currentSetterName = renameFieldProcessor.getSetter().getElementName();
String regexp = SETTER_NAME.replace("VARIABLE_NAME", variableNameAssigned).replace("CURRENT_SETTER_NAME", currentSetterName);
createFieldRenameChanges(mte, content, regexp, currentSetterName, newSetterName);
}
}
}
if (change.getEdit().getChildrenSize() > 0)
changes.add(change);
}
}
return (changes.getChildren().length > 0)?changes:null;