/**
* Adds {@link TextEdit}s into existing Java file {@link Change}.
*/
private void addHandlerMethodChanges(CompositeChange compositeChange, IProgressMonitor pm)
throws Exception {
TextChange change = new CompilationUnitChange("(No matter)", m_field.getCompilationUnit());
change.setEdit(new MultiTextEdit());
// update handler methods
String oldMethodPrefix = "on" + StringUtils.capitalize(m_oldName);
String newMethodPrefix = "on" + StringUtils.capitalize(m_newName);
IType type = (IType) m_field.getParent();
for (IMethod method : type.getMethods()) {
// prepare @UiHandler annotation
IAnnotation annotation = getHandlerAnnotation(method);
if (annotation == null) {
continue;
}
// update @UiHandler name
{
ISourceRange annoRange = annotation.getSourceRange();
ISourceRange nameRange = annotation.getNameRange();
int nameEnd = nameRange.getOffset() + nameRange.getLength();
int annoEnd = annoRange.getOffset() + annoRange.getLength();
change.addEdit(new ReplaceEdit(nameEnd, annoEnd - nameEnd, "(\"" + m_newName + "\")"));
}
// rename method
String methodName = method.getElementName();
if (methodName.startsWith(oldMethodPrefix)) {
String newName = newMethodPrefix + StringUtils.removeStart(methodName, oldMethodPrefix);