Source:
<code>public IContentType addContentType(String id, String name, IContentType baseType) throws CoreException { if (id == null) { throw new IllegalArgumentException("Content-type 'id' mustn't be null"); } if (id.contains(ContentType.PREF_USER_DEFINED__SEPARATOR)) { throw new IllegalArgumentException( "Content-Type id mustn't contain '" + ContentType.PREF_USER_DEFINED__SEPARATOR + '\''); } if (getContentType(id) != null) { throw new IllegalArgumentException("Content-type '" + id + "' already exists."); } ContentType contentType = ContentType.createContentType(getCatalog(), id, name, (byte) 0, new String[0], new String[0], baseType != null ? baseType.getId() : null, null, null, null); getCatalog().addContentType(contentType); String currentUserDefined = getContext().getNode(ContentType.PREF_USER_DEFINED) .get(ContentType.PREF_USER_DEFINED, ContentType.EMPTY_STRING); if (currentUserDefined.length() > 0) { currentUserDefined += ContentType.PREF_USER_DEFINED__SEPARATOR; } getContext().getNode(ContentType.PREF_USER_DEFINED).put(ContentType.PREF_USER_DEFINED, currentUserDefined + id); contentType.setValidation(ContentType.STATUS_UNKNOWN); IEclipsePreferences contextTypeNode = getContext().getNode(contentType.getId()); contextTypeNode.put(ContentType.PREF_USER_DEFINED__NAME, name); if (baseType != null) { contextTypeNode.put(ContentType.PREF_USER_DEFINED__BASE_TYPE_ID, baseType.getId()); } try { getContext().getNode(ContentType.PREF_USER_DEFINED).flush(); contextTypeNode.flush(); } catch (BackingStoreException e) { String message = NLS.bind(ContentMessages.content_errorSavingSettings, id); IStatus status = new Status(IStatus.ERROR, ContentMessages.OWNER_NAME, 0, message, e); throw new CoreException(status); } getCatalog().organize(); <START> fireContentTypeChangeEvent(contentType); <END> return contentType; }</code><technical_language>Optional suggestion: fire events asynchronously</technical_language>

Target:
public final IContentType addContentType(String id, String name, IContentType baseType) throws CoreException { if (id == null) { throw new IllegalArgumentException("Content-type 'id' mustn't be null"); } if (id.contains(ContentType.PREF_USER_DEFINED__SEPARATOR)) { throw new IllegalArgumentException( "Content-Type id mustn't contain '" + ContentType.PREF_USER_DEFINED__SEPARATOR + '\''); } if (getContentType(id) != null) { throw new IllegalArgumentException("Content-type '" + id + "' already exists."); } ContentType contentType = ContentType.createContentType(getCatalog(), id, name, (byte) 0, new String[0], new String[0], baseType != null ? baseType.getId() : null, null, null, null); getCatalog().addContentType(contentType); String currentUserDefined = getContext().getNode(ContentType.PREF_USER_DEFINED) .get(ContentType.PREF_USER_DEFINED, ContentType.EMPTY_STRING); if (currentUserDefined.length() > 0) { currentUserDefined += ContentType.PREF_USER_DEFINED__SEPARATOR; } getContext().getNode(ContentType.PREF_USER_DEFINED).put(ContentType.PREF_USER_DEFINED, currentUserDefined + id); contentType.setValidation(ContentType.STATUS_UNKNOWN); IEclipsePreferences contextTypeNode = getContext().getNode(contentType.getId()); contextTypeNode.put(ContentType.PREF_USER_DEFINED__NAME, name); if (baseType != null) { contextTypeNode.put(ContentType.PREF_USER_DEFINED__BASE_TYPE_ID, baseType.getId()); } try { getContext().getNode(ContentType.PREF_USER_DEFINED).flush(); contextTypeNode.flush(); } catch (BackingStoreException e) { String message = NLS.bind(ContentMessages.content_errorSavingSettings, id); IStatus status = new Status(IStatus.ERROR, ContentMessages.OWNER_NAME, 0, message, e); throw new CoreException(status); } getCatalog().organize(); fireContentTypeChangeEvent(contentType); return contentType; }