"\\[\\]\\s*(" + name + "\\s*\\()\\)", " $1int index)");
stub = stub.replaceFirst("(return\\s+\\w+)(.*?;)", "$1[index]$2");
IMethod inserted = type.createMethod(stub, sibling, false, null);
// format the inserted method according to the user's preferences
Position position = TypeUtils.getPosition(type, inserted);
JavaUtils.format(
src, CodeFormatter.K_COMPILATION_UNIT,
position.getOffset(), position.getLength());
}
}
if (setter != null){
IMethod existing = getBeanMethod(type, setter, TYPE_SET_INDEX);
if (existing == null) {
IJavaElement sibling = getSibling(type, fields, setter, TYPE_SET_INDEX);
String name = GetterSetterUtil.getSetterName(setter, null);
String stub = GetterSetterUtil.getSetterStub(
setter, name, settings.createComments, Modifier.PUBLIC);
stub = stub.replaceFirst(
"\n(\\s*\\*\\s*@param)",
"\n * @param index the index to set\n$1");
stub = stub.replaceFirst(
"(" + name + "\\s*\\()(.*?)\\[\\](\\s*.*?)\\)",
"$1int index, $2$3)");
stub = stub.replaceFirst("(\\w+)(\\s*=\\s*)", "$1[index]$2");
IMethod inserted = type.createMethod(stub, sibling, false, null);
// format the inserted method according to the user's preferences
Position position = TypeUtils.getPosition(type, inserted);
JavaUtils.format(
src, CodeFormatter.K_COMPILATION_UNIT,
position.getOffset(), position.getLength());
}
}
}