Source:
static String computeDefaultNameWithIncrementFromBase(String base, Collection<?> contents, EObject elementToRename, String separator) { final IPreferenceStore store = Activator.getDefault().getPreferenceStore(); final String preferenceValue = store.getString(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION); if (null != preferenceValue) { if (null != elementToRename && elementToRename instanceof NamedElement && null != ((NamedElement) elementToRename).getName() && false == ((NamedElement) elementToRename).getName().isEmpty()) { if (null != elementToRename.eContainer()) { return ((NamedElement) elementToRename).getName(); } } if (NamedElementIndexNamingStrategyEnum.NO_INDEX_INITIALIZATION.getName().equals(preferenceValue)) { return base; } if (NamedElementIndexNamingStrategyEnum.QUICK_INDEX_INITIALIZATION.getName().equals(preferenceValue)) { return base + separator + contents.size() + 1; } } if (elementToRename != null) { if (!isAutoNamed(elementToRename)) { return null; } if (contents.contains(elementToRename)) { if (elementToRename instanceof ENamedElement) { ENamedElement eNamedElement = (ENamedElement) elementToRename; if (eNamedElement.getName() != null) { return eNamedElement.getName(); } } if (elementToRename instanceof NamedElement) { NamedElement namedElement = (NamedElement) elementToRename; if (namedElement.getName() != null) { return namedElement.getName(); } } } } int nextNumber = 1; if ("property".equalsIgnoreCase(base)) { base = "Attribute"; } for (Object o : contents) { if (o instanceof EObject && o != elementToRename) { String name = EMFCoreUtil.getName((EObject) o); if (name != null && name.startsWith(base)) { String end = name.substring(base.length()); int nextNumberTmp = 1; try { nextNumberTmp = Integer.parseInt(end) + 1; } catch (NumberFormatException ex) { } if (nextNumberTmp > nextNumber) { nextNumber = nextNumberTmp; } } } } return base + separator + nextNumber; }

Target:
static String computeDefaultNameWithIncrementFromBase(String base, Collection<?> contents, EObject elementToRename, String separator) { final IPreferenceStore store = Activator.getDefault().getPreferenceStore(); final String preferenceValue = store.getString(NameElementNamingStrategyPreferenceInitializer.NAMED_ELEMENT_INDEX_INITIALIZATION); if (null != preferenceValue) { if (elementToRename instanceof NamedElement && null != ((NamedElement) elementToRename).getName() && false == ((NamedElement) elementToRename).getName().isEmpty()) { if (null != elementToRename.eContainer()) { return ((NamedElement) elementToRename).getName(); } } if (NamedElementIndexNamingStrategyEnum.NO_INDEX_INITIALIZATION.getName().equals(preferenceValue)) { return base; } if (NamedElementIndexNamingStrategyEnum.QUICK_INDEX_INITIALIZATION.getName().equals(preferenceValue)) { final StringBuilder builder = new StringBuilder(base); builder.append(separator); builder.append(contents.size()); return builder.toString(); } } if (elementToRename != null) { if (!isAutoNamed(elementToRename)) { return null; } if (contents.contains(elementToRename)) { if (elementToRename instanceof ENamedElement) { ENamedElement eNamedElement = (ENamedElement) elementToRename; if (eNamedElement.getName() != null) { return eNamedElement.getName(); } } if (elementToRename instanceof NamedElement) { NamedElement namedElement = (NamedElement) elementToRename; if (namedElement.getName() != null) { return namedElement.getName(); } } } } int nextNumber = 1; if ("property".equalsIgnoreCase(base)) { base = "Attribute"; } for (Object o : contents) { if (o instanceof EObject && o != elementToRename) { String name = EMFCoreUtil.getName((EObject) o); if (name != null && name.startsWith(base)) { String end = name.substring(base.length()); int nextNumberTmp = 1; try { nextNumberTmp = Integer.parseInt(end) + 1; } catch (NumberFormatException ex) { } if (nextNumberTmp > nextNumber) { nextNumber = nextNumberTmp; } } } } return base + separator + nextNumber; }