Bug 11314 Replace package name fragments should always be smaller
Build 20020214 If you enter "2~." in the 'Replace package name fragments with:' field in the preferences (Java->Work in progress), com.ibm.foobar is replaced with co~.ib~.foobar. I believe that package name compression should only replace a fragment if the compressed name is actually smaller. Thus com. would not be replaced in this example, since co~. is the same length, and contains less info.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementLabels.java
if (getFlag(flags, I_POST_QUALIFIED)) {
			buf.append(CONCAT_STRING);
			getTypeLabel(initializer.getDeclaringType(), T_FULLY_QUALIFIED, buf);
		}
	}
	/**
	 * Appends the label for a type to a StringBuffer. Considers the T_* flags.
	 */		
	public static void getTypeLabel(IType type, int flags, StringBuffer buf) {
		if (getFlag(flags, T_FULLY_QUALIFIED)) {
			buf.append(JavaModelUtil.getFullyQualifiedName(type));
		} else if (getFlag(flags, T_CONTAINER_QUALIFIED)) {
			buf.append(JavaModelUtil.getTypeQualifiedName(type));
		} else {
			buf.append(type.getElementName());
		}
		
		if (getFlag(flags, T_POST_QUALIFIED)) {
			buf.append(CONCAT_STRING);
			IType declaringType= type.getDeclaringType();
			if (declaringType != null) {
				buf.append(JavaModelUtil.getFullyQualifiedName(declaringType));
			} else {
				getPackageFragmentLabel(type.getPackageFragment(), 0, buf);
			}
		}
	}
	/**
	 * Appends the label for a declaration to a StringBuffer. Considers the D_* flags.